diff options
author | Mike Frysinger <vapier@google.com> | 2021-03-01 02:03:44 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-03-01 15:57:32 +0000 |
commit | 179a242caa31ca4b96ada240fa6a6fef7509aa27 (patch) | |
tree | b5bcdddac211f1eeaf66a2278b2b3c40b37fec7f /subcmds/forall.py | |
parent | 31fabeed54f3cbf9495e559dce60f58e126f58d5 (diff) | |
download | git-repo-179a242caa31ca4b96ada240fa6a6fef7509aa27.tar.gz |
forall: move nested func out to the class
This is in preparation for simplifying the jobs support. The nested
function is referenced in the options object which can't be pickled,
so pull it out into a static method instead.
Change-Id: I01d3c4eaabcb8b8775ddf22312a6e142c84cb77d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298722
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/forall.py')
-rw-r--r-- | subcmds/forall.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 4ea7db66..a2ccb7b6 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -115,13 +115,15 @@ without iterating through the remaining projects. | |||
115 | """ | 115 | """ |
116 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 116 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
117 | 117 | ||
118 | @staticmethod | ||
119 | def _cmd_option(option, _opt_str, _value, parser): | ||
120 | setattr(parser.values, option.dest, list(parser.rargs)) | ||
121 | while parser.rargs: | ||
122 | del parser.rargs[0] | ||
123 | |||
118 | def _Options(self, p): | 124 | def _Options(self, p): |
119 | super()._Options(p) | 125 | super()._Options(p) |
120 | 126 | ||
121 | def cmd(option, opt_str, value, parser): | ||
122 | setattr(parser.values, option.dest, list(parser.rargs)) | ||
123 | while parser.rargs: | ||
124 | del parser.rargs[0] | ||
125 | p.add_option('-r', '--regex', | 127 | p.add_option('-r', '--regex', |
126 | dest='regex', action='store_true', | 128 | dest='regex', action='store_true', |
127 | help="Execute the command only on projects matching regex or wildcard expression") | 129 | help="Execute the command only on projects matching regex or wildcard expression") |
@@ -136,7 +138,7 @@ without iterating through the remaining projects. | |||
136 | help='Command (and arguments) to execute', | 138 | help='Command (and arguments) to execute', |
137 | dest='command', | 139 | dest='command', |
138 | action='callback', | 140 | action='callback', |
139 | callback=cmd) | 141 | callback=self._cmd_option) |
140 | p.add_option('-e', '--abort-on-errors', | 142 | p.add_option('-e', '--abort-on-errors', |
141 | dest='abort_on_errors', action='store_true', | 143 | dest='abort_on_errors', action='store_true', |
142 | help='Abort if a command exits unsuccessfully') | 144 | help='Abort if a command exits unsuccessfully') |