diff options
author | Mike Frysinger <vapier@google.com> | 2021-04-13 14:57:40 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-04-13 22:25:17 +0000 |
commit | 9180a07b8fb33d5ba0b82facf987b51ca7b15dc4 (patch) | |
tree | 4c815bea7136115bf382a1bb75b89b67bd39bd61 /subcmds | |
parent | f32f243ff8aaabe5287235015e1ce189da0123e3 (diff) | |
download | git-repo-9180a07b8fb33d5ba0b82facf987b51ca7b15dc4.tar.gz |
command: make --verbose/--quiet available to all subcommands
Add new CommonOptions entry points to move the existing --jobs to,
and relocate all --verbose/--quiet options to that. This provides
both a consistent interface for users as well as for code.
Change-Id: Ifaf83b88872421f4749b073c472b4a67ca6c0437
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303224
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/abandon.py | 4 | ||||
-rw-r--r-- | subcmds/cherry_pick.py | 3 | ||||
-rw-r--r-- | subcmds/diff.py | 1 | ||||
-rw-r--r-- | subcmds/forall.py | 7 | ||||
-rw-r--r-- | subcmds/grep.py | 5 | ||||
-rw-r--r-- | subcmds/init.py | 6 | ||||
-rw-r--r-- | subcmds/rebase.py | 6 | ||||
-rw-r--r-- | subcmds/stage.py | 3 | ||||
-rw-r--r-- | subcmds/start.py | 1 | ||||
-rw-r--r-- | subcmds/status.py | 3 | ||||
-rw-r--r-- | subcmds/sync.py | 14 |
11 files changed, 15 insertions, 38 deletions
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index b82a2dbf..ea3f4ed0 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
@@ -37,10 +37,6 @@ It is equivalent to "git branch -D <branchname>". | |||
37 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 37 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
38 | 38 | ||
39 | def _Options(self, p): | 39 | def _Options(self, p): |
40 | super()._Options(p) | ||
41 | p.add_option('-q', '--quiet', | ||
42 | action='store_true', default=False, | ||
43 | help='be quiet') | ||
44 | p.add_option('--all', | 40 | p.add_option('--all', |
45 | dest='all', action='store_true', | 41 | dest='all', action='store_true', |
46 | help='delete all branches in all projects') | 42 | help='delete all branches in all projects') |
diff --git a/subcmds/cherry_pick.py b/subcmds/cherry_pick.py index 4b7f1412..fc4998c3 100644 --- a/subcmds/cherry_pick.py +++ b/subcmds/cherry_pick.py | |||
@@ -32,9 +32,6 @@ The change id will be updated, and a reference to the old | |||
32 | change id will be added. | 32 | change id will be added. |
33 | """ | 33 | """ |
34 | 34 | ||
35 | def _Options(self, p): | ||
36 | pass | ||
37 | |||
38 | def ValidateOptions(self, opt, args): | 35 | def ValidateOptions(self, opt, args): |
39 | if len(args) != 1: | 36 | if len(args) != 1: |
40 | self.Usage() | 37 | self.Usage() |
diff --git a/subcmds/diff.py b/subcmds/diff.py index 81868176..cdc262e6 100644 --- a/subcmds/diff.py +++ b/subcmds/diff.py | |||
@@ -32,7 +32,6 @@ to the Unix 'patch' command. | |||
32 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 32 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
33 | 33 | ||
34 | def _Options(self, p): | 34 | def _Options(self, p): |
35 | super()._Options(p) | ||
36 | p.add_option('-u', '--absolute', | 35 | p.add_option('-u', '--absolute', |
37 | dest='absolute', action='store_true', | 36 | dest='absolute', action='store_true', |
38 | help='Paths are relative to the repository root') | 37 | help='Paths are relative to the repository root') |
diff --git a/subcmds/forall.py b/subcmds/forall.py index f0ce97cb..4a631fb7 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -129,8 +129,6 @@ without iterating through the remaining projects. | |||
129 | del parser.rargs[0] | 129 | del parser.rargs[0] |
130 | 130 | ||
131 | def _Options(self, p): | 131 | def _Options(self, p): |
132 | super()._Options(p) | ||
133 | |||
134 | p.add_option('-r', '--regex', | 132 | p.add_option('-r', '--regex', |
135 | dest='regex', action='store_true', | 133 | dest='regex', action='store_true', |
136 | help="Execute the command only on projects matching regex or wildcard expression") | 134 | help="Execute the command only on projects matching regex or wildcard expression") |
@@ -153,13 +151,10 @@ without iterating through the remaining projects. | |||
153 | help='Silently skip & do not exit non-zero due missing ' | 151 | help='Silently skip & do not exit non-zero due missing ' |
154 | 'checkouts') | 152 | 'checkouts') |
155 | 153 | ||
156 | g = p.add_option_group('Output') | 154 | g = p.get_option_group('--quiet') |
157 | g.add_option('-p', | 155 | g.add_option('-p', |
158 | dest='project_header', action='store_true', | 156 | dest='project_header', action='store_true', |
159 | help='Show project headers before output') | 157 | help='Show project headers before output') |
160 | g.add_option('-v', '--verbose', | ||
161 | dest='verbose', action='store_true', | ||
162 | help='Show command error messages') | ||
163 | p.add_option('--interactive', | 158 | p.add_option('--interactive', |
164 | action='store_true', | 159 | action='store_true', |
165 | help='force interactive usage') | 160 | help='force interactive usage') |
diff --git a/subcmds/grep.py b/subcmds/grep.py index 49feaf6b..9a4a8a36 100644 --- a/subcmds/grep.py +++ b/subcmds/grep.py | |||
@@ -82,8 +82,11 @@ contain a line that matches both expressions: | |||
82 | if value is not None: | 82 | if value is not None: |
83 | pt.append(value) | 83 | pt.append(value) |
84 | 84 | ||
85 | def _CommonOptions(self, p): | ||
86 | """Override common options slightly.""" | ||
87 | super()._CommonOptions(p, opt_v=False) | ||
88 | |||
85 | def _Options(self, p): | 89 | def _Options(self, p): |
86 | super()._Options(p) | ||
87 | g = p.add_option_group('Sources') | 90 | g = p.add_option_group('Sources') |
88 | g.add_option('--cached', | 91 | g.add_option('--cached', |
89 | action='callback', callback=self._carry_option, | 92 | action='callback', callback=self._carry_option, |
diff --git a/subcmds/init.py b/subcmds/init.py index a23e529d..4182262e 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -79,6 +79,9 @@ manifest, a subsequent `repo sync` (or `repo sync -d`) is necessary | |||
79 | to update the working directory files. | 79 | to update the working directory files. |
80 | """ | 80 | """ |
81 | 81 | ||
82 | def _CommonOptions(self, p): | ||
83 | """Disable due to re-use of Wrapper().""" | ||
84 | |||
82 | def _Options(self, p, gitc_init=False): | 85 | def _Options(self, p, gitc_init=False): |
83 | Wrapper().InitParser(p, gitc_init=gitc_init) | 86 | Wrapper().InitParser(p, gitc_init=gitc_init) |
84 | 87 | ||
@@ -436,9 +439,6 @@ to update the working directory files. | |||
436 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), | 439 | % ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),), |
437 | file=sys.stderr) | 440 | file=sys.stderr) |
438 | 441 | ||
439 | opt.quiet = opt.output_mode is False | ||
440 | opt.verbose = opt.output_mode is True | ||
441 | |||
442 | rp = self.manifest.repoProject | 442 | rp = self.manifest.repoProject |
443 | 443 | ||
444 | # Handle new --repo-url requests. | 444 | # Handle new --repo-url requests. |
diff --git a/subcmds/rebase.py b/subcmds/rebase.py index cf536e9d..e0186d4d 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.py | |||
@@ -39,7 +39,8 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
39 | """ | 39 | """ |
40 | 40 | ||
41 | def _Options(self, p): | 41 | def _Options(self, p): |
42 | p.add_option('-i', '--interactive', | 42 | g = p.get_option_group('--quiet') |
43 | g.add_option('-i', '--interactive', | ||
43 | dest="interactive", action="store_true", | 44 | dest="interactive", action="store_true", |
44 | help="interactive rebase (single project only)") | 45 | help="interactive rebase (single project only)") |
45 | 46 | ||
@@ -52,9 +53,6 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
52 | p.add_option('--no-ff', | 53 | p.add_option('--no-ff', |
53 | dest='ff', default=True, action='store_false', | 54 | dest='ff', default=True, action='store_false', |
54 | help='Pass --no-ff to git rebase') | 55 | help='Pass --no-ff to git rebase') |
55 | p.add_option('-q', '--quiet', | ||
56 | dest='quiet', action='store_true', | ||
57 | help='Pass --quiet to git rebase') | ||
58 | p.add_option('--autosquash', | 56 | p.add_option('--autosquash', |
59 | dest='autosquash', action='store_true', | 57 | dest='autosquash', action='store_true', |
60 | help='Pass --autosquash to git rebase') | 58 | help='Pass --autosquash to git rebase') |
diff --git a/subcmds/stage.py b/subcmds/stage.py index 98b30221..ff0f1738 100644 --- a/subcmds/stage.py +++ b/subcmds/stage.py | |||
@@ -38,7 +38,8 @@ The '%prog' command stages files to prepare the next commit. | |||
38 | """ | 38 | """ |
39 | 39 | ||
40 | def _Options(self, p): | 40 | def _Options(self, p): |
41 | p.add_option('-i', '--interactive', | 41 | g = p.get_option_group('--quiet') |
42 | g.add_option('-i', '--interactive', | ||
42 | dest='interactive', action='store_true', | 43 | dest='interactive', action='store_true', |
43 | help='use interactive staging') | 44 | help='use interactive staging') |
44 | 45 | ||
diff --git a/subcmds/start.py b/subcmds/start.py index 04589fb2..2593ace6 100644 --- a/subcmds/start.py +++ b/subcmds/start.py | |||
@@ -38,7 +38,6 @@ revision specified in the manifest. | |||
38 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 38 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
39 | 39 | ||
40 | def _Options(self, p): | 40 | def _Options(self, p): |
41 | super()._Options(p) | ||
42 | p.add_option('--all', | 41 | p.add_option('--all', |
43 | dest='all', action='store_true', | 42 | dest='all', action='store_true', |
44 | help='begin branch in all projects') | 43 | help='begin branch in all projects') |
diff --git a/subcmds/status.py b/subcmds/status.py index 6c8e22e5..dc223a00 100644 --- a/subcmds/status.py +++ b/subcmds/status.py | |||
@@ -80,12 +80,9 @@ the following meanings: | |||
80 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS | 80 | PARALLEL_JOBS = DEFAULT_LOCAL_JOBS |
81 | 81 | ||
82 | def _Options(self, p): | 82 | def _Options(self, p): |
83 | super()._Options(p) | ||
84 | p.add_option('-o', '--orphans', | 83 | p.add_option('-o', '--orphans', |
85 | dest='orphans', action='store_true', | 84 | dest='orphans', action='store_true', |
86 | help="include objects in working directory outside of repo projects") | 85 | help="include objects in working directory outside of repo projects") |
87 | p.add_option('-q', '--quiet', action='store_true', | ||
88 | help="only print the name of modified projects") | ||
89 | 86 | ||
90 | def _StatusHelper(self, quiet, project): | 87 | def _StatusHelper(self, quiet, project): |
91 | """Obtains the status for a specific project. | 88 | """Obtains the status for a specific project. |
diff --git a/subcmds/sync.py b/subcmds/sync.py index b8abb1a7..e7079879 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -167,13 +167,14 @@ later is required to fix a server side protocol bug. | |||
167 | """ | 167 | """ |
168 | PARALLEL_JOBS = 1 | 168 | PARALLEL_JOBS = 1 |
169 | 169 | ||
170 | def _Options(self, p, show_smart=True): | 170 | def _CommonOptions(self, p): |
171 | try: | 171 | try: |
172 | self.PARALLEL_JOBS = self.manifest.default.sync_j | 172 | self.PARALLEL_JOBS = self.manifest.default.sync_j |
173 | except ManifestParseError: | 173 | except ManifestParseError: |
174 | pass | 174 | pass |
175 | super()._Options(p) | 175 | super()._CommonOptions(p) |
176 | 176 | ||
177 | def _Options(self, p, show_smart=True): | ||
177 | p.add_option('--jobs-network', default=None, type=int, metavar='JOBS', | 178 | p.add_option('--jobs-network', default=None, type=int, metavar='JOBS', |
178 | help='number of network jobs to run in parallel (defaults to --jobs)') | 179 | help='number of network jobs to run in parallel (defaults to --jobs)') |
179 | p.add_option('--jobs-checkout', default=None, type=int, metavar='JOBS', | 180 | p.add_option('--jobs-checkout', default=None, type=int, metavar='JOBS', |
@@ -211,12 +212,6 @@ later is required to fix a server side protocol bug. | |||
211 | p.add_option('-c', '--current-branch', | 212 | p.add_option('-c', '--current-branch', |
212 | dest='current_branch_only', action='store_true', | 213 | dest='current_branch_only', action='store_true', |
213 | help='fetch only current branch from server') | 214 | help='fetch only current branch from server') |
214 | p.add_option('-v', '--verbose', | ||
215 | dest='output_mode', action='store_true', | ||
216 | help='show all sync output') | ||
217 | p.add_option('-q', '--quiet', | ||
218 | dest='output_mode', action='store_false', | ||
219 | help='only show errors') | ||
220 | p.add_option('-m', '--manifest-name', | 215 | p.add_option('-m', '--manifest-name', |
221 | dest='manifest_name', | 216 | dest='manifest_name', |
222 | help='temporary manifest to use for this sync', metavar='NAME.xml') | 217 | help='temporary manifest to use for this sync', metavar='NAME.xml') |
@@ -770,9 +765,6 @@ later is required to fix a server side protocol bug. | |||
770 | soft_limit, _ = _rlimit_nofile() | 765 | soft_limit, _ = _rlimit_nofile() |
771 | self.jobs = min(self.jobs, (soft_limit - 5) // 3) | 766 | self.jobs = min(self.jobs, (soft_limit - 5) // 3) |
772 | 767 | ||
773 | opt.quiet = opt.output_mode is False | ||
774 | opt.verbose = opt.output_mode is True | ||
775 | |||
776 | if opt.manifest_name: | 768 | if opt.manifest_name: |
777 | self.manifest.Override(opt.manifest_name) | 769 | self.manifest.Override(opt.manifest_name) |
778 | 770 | ||