summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-02-16 01:43:31 -0500
committerMike Frysinger <vapier@google.com>2021-02-22 22:51:07 +0000
commit6a2400a4d097b6e510dc9b8ec06283517b9ca3ad (patch)
tree55ad212633615a1d0ea1bb3f5c294f495bd223a7 /subcmds/sync.py
parentc5bbea8db364b88558acc434be16ec82c04737e5 (diff)
downloadgit-repo-6a2400a4d097b6e510dc9b8ec06283517b9ca3ad.tar.gz
command: unify --job option & default values
Extend the Command class to support adding the --jobs option to the parser if the command declares it supports running in parallel. Also pull the default value used for the number of local jobs into the command module so local commands can share it. Change-Id: I22b0f8d2cf69875013cec657b8e6c4385549ccac Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297024 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 5b1024df..18d2256e 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -177,12 +177,14 @@ If the remote SSH daemon is Gerrit Code Review, version 2.0.10 or
177later is required to fix a server side protocol bug. 177later is required to fix a server side protocol bug.
178 178
179""" 179"""
180 PARALLEL_JOBS = 1
180 181
181 def _Options(self, p, show_smart=True): 182 def _Options(self, p, show_smart=True):
182 try: 183 try:
183 self.jobs = self.manifest.default.sync_j 184 self.PARALLEL_JOBS = self.manifest.default.sync_j
184 except ManifestParseError: 185 except ManifestParseError:
185 self.jobs = 1 186 pass
187 super()._Options(p)
186 188
187 p.add_option('-f', '--force-broken', 189 p.add_option('-f', '--force-broken',
188 dest='force_broken', action='store_true', 190 dest='force_broken', action='store_true',
@@ -222,9 +224,6 @@ later is required to fix a server side protocol bug.
222 p.add_option('-q', '--quiet', 224 p.add_option('-q', '--quiet',
223 dest='output_mode', action='store_false', 225 dest='output_mode', action='store_false',
224 help='only show errors') 226 help='only show errors')
225 p.add_option('-j', '--jobs',
226 dest='jobs', action='store', type='int',
227 help="projects to fetch simultaneously (default %d)" % self.jobs)
228 p.add_option('-m', '--manifest-name', 227 p.add_option('-m', '--manifest-name',
229 dest='manifest_name', 228 dest='manifest_name',
230 help='temporary manifest to use for this sync', metavar='NAME.xml') 229 help='temporary manifest to use for this sync', metavar='NAME.xml')