summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py43
-rw-r--r--subcmds/sync.py13
2 files changed, 31 insertions, 25 deletions
diff --git a/project.py b/project.py
index 376af7a9..57a5832e 100644
--- a/project.py
+++ b/project.py
@@ -1427,6 +1427,7 @@ class Project(object):
1427 1427
1428 def Sync_NetworkHalf(self, 1428 def Sync_NetworkHalf(self,
1429 quiet=False, 1429 quiet=False,
1430 verbose=False,
1430 is_new=None, 1431 is_new=None,
1431 current_branch_only=False, 1432 current_branch_only=False,
1432 force_sync=False, 1433 force_sync=False,
@@ -1509,16 +1510,17 @@ class Project(object):
1509 else: 1510 else:
1510 depth = self.manifest.manifestProject.config.GetString('repo.depth') 1511 depth = self.manifest.manifestProject.config.GetString('repo.depth')
1511 1512
1512 need_to_fetch = not (optimized_fetch and 1513 # See if we can skip the network fetch entirely.
1513 (ID_RE.match(self.revisionExpr) and 1514 if not (optimized_fetch and
1514 self._CheckForImmutableRevision())) 1515 (ID_RE.match(self.revisionExpr) and
1515 if (need_to_fetch and 1516 self._CheckForImmutableRevision())):
1516 not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, 1517 if not self._RemoteFetch(
1517 current_branch_only=current_branch_only, 1518 initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir,
1518 no_tags=no_tags, prune=prune, depth=depth, 1519 current_branch_only=current_branch_only,
1519 submodules=submodules, force_sync=force_sync, 1520 no_tags=no_tags, prune=prune, depth=depth,
1520 clone_filter=clone_filter)): 1521 submodules=submodules, force_sync=force_sync,
1521 return False 1522 clone_filter=clone_filter):
1523 return False
1522 1524
1523 mp = self.manifest.manifestProject 1525 mp = self.manifest.manifestProject
1524 dissociate = mp.config.GetBoolean('repo.dissociate') 1526 dissociate = mp.config.GetBoolean('repo.dissociate')
@@ -2193,6 +2195,7 @@ class Project(object):
2193 current_branch_only=False, 2195 current_branch_only=False,
2194 initial=False, 2196 initial=False,
2195 quiet=False, 2197 quiet=False,
2198 verbose=False,
2196 alt_dir=None, 2199 alt_dir=None,
2197 no_tags=False, 2200 no_tags=False,
2198 prune=False, 2201 prune=False,
@@ -2223,7 +2226,7 @@ class Project(object):
2223 2226
2224 if is_sha1 or tag_name is not None: 2227 if is_sha1 or tag_name is not None:
2225 if self._CheckForImmutableRevision(): 2228 if self._CheckForImmutableRevision():
2226 if not quiet: 2229 if verbose:
2227 print('Skipped fetching project %s (already have persistent ref)' 2230 print('Skipped fetching project %s (already have persistent ref)'
2228 % self.name) 2231 % self.name)
2229 return True 2232 return True
@@ -2400,17 +2403,13 @@ class Project(object):
2400 # got what we wanted, else trigger a second run of all 2403 # got what we wanted, else trigger a second run of all
2401 # refs. 2404 # refs.
2402 if not self._CheckForImmutableRevision(): 2405 if not self._CheckForImmutableRevision():
2403 if current_branch_only and depth: 2406 # Sync the current branch only with depth set to None.
2404 # Sync the current branch only with depth set to None 2407 # We always pass depth=None down to avoid infinite recursion.
2405 return self._RemoteFetch(name=name, 2408 return self._RemoteFetch(
2406 current_branch_only=current_branch_only, 2409 name=name, quiet=quiet, verbose=verbose,
2407 initial=False, quiet=quiet, alt_dir=alt_dir, 2410 current_branch_only=current_branch_only and depth,
2408 depth=None, clone_filter=clone_filter) 2411 initial=False, alt_dir=alt_dir,
2409 else: 2412 depth=None, clone_filter=clone_filter)
2410 # Avoid infinite recursion: sync all branches with depth set to None
2411 return self._RemoteFetch(name=name, current_branch_only=False,
2412 initial=False, quiet=quiet, alt_dir=alt_dir,
2413 depth=None, clone_filter=clone_filter)
2414 2413
2415 return ok 2414 return ok
2416 2415
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 3d42a0a7..cb285290 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -234,9 +234,12 @@ later is required to fix a server side protocol bug.
234 p.add_option('-c', '--current-branch', 234 p.add_option('-c', '--current-branch',
235 dest='current_branch_only', action='store_true', 235 dest='current_branch_only', action='store_true',
236 help='fetch only current branch from server') 236 help='fetch only current branch from server')
237 p.add_option('-v', '--verbose',
238 dest='output_mode', action='store_true',
239 help='show all sync output')
237 p.add_option('-q', '--quiet', 240 p.add_option('-q', '--quiet',
238 dest='quiet', action='store_true', 241 dest='output_mode', action='store_false',
239 help='be more quiet') 242 help='only show errors')
240 p.add_option('-j', '--jobs', 243 p.add_option('-j', '--jobs',
241 dest='jobs', action='store', type='int', 244 dest='jobs', action='store', type='int',
242 help="projects to fetch simultaneously (default %d)" % self.jobs) 245 help="projects to fetch simultaneously (default %d)" % self.jobs)
@@ -332,6 +335,7 @@ later is required to fix a server side protocol bug.
332 try: 335 try:
333 success = project.Sync_NetworkHalf( 336 success = project.Sync_NetworkHalf(
334 quiet=opt.quiet, 337 quiet=opt.quiet,
338 verbose=opt.verbose,
335 current_branch_only=opt.current_branch_only, 339 current_branch_only=opt.current_branch_only,
336 force_sync=opt.force_sync, 340 force_sync=opt.force_sync,
337 clone_bundle=not opt.no_clone_bundle, 341 clone_bundle=not opt.no_clone_bundle,
@@ -835,7 +839,7 @@ later is required to fix a server side protocol bug.
835 """Fetch & update the local manifest project.""" 839 """Fetch & update the local manifest project."""
836 if not opt.local_only: 840 if not opt.local_only:
837 start = time.time() 841 start = time.time()
838 success = mp.Sync_NetworkHalf(quiet=opt.quiet, 842 success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose,
839 current_branch_only=opt.current_branch_only, 843 current_branch_only=opt.current_branch_only,
840 no_tags=opt.no_tags, 844 no_tags=opt.no_tags,
841 optimized_fetch=opt.optimized_fetch, 845 optimized_fetch=opt.optimized_fetch,
@@ -883,6 +887,9 @@ later is required to fix a server side protocol bug.
883 soft_limit, _ = _rlimit_nofile() 887 soft_limit, _ = _rlimit_nofile()
884 self.jobs = min(self.jobs, (soft_limit - 5) // 3) 888 self.jobs = min(self.jobs, (soft_limit - 5) // 3)
885 889
890 opt.quiet = opt.output_mode is False
891 opt.verbose = opt.output_mode is True
892
886 if opt.manifest_name: 893 if opt.manifest_name:
887 self.manifest.Override(opt.manifest_name) 894 self.manifest.Override(opt.manifest_name)
888 895