From 53d6f4d17e0cb4eabcd604d584a1132a51cc8bf3 Mon Sep 17 00:00:00 2001 From: Anatol Pomazau Date: Thu, 25 Aug 2011 17:21:47 -0700 Subject: Add a sync flag that fetches only current branch There is also shortcuts in case if the "current branch" is a persistent revision such as tag or sha1. We check if the persistent revision is present locally and if it does - do no fetch anything from the server. This greately reduces sync time and size of the on-disk repo Change-Id: I23c6d95185474ed6e1a03c836a47f489953b99be --- subcmds/sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index a3d06922..c5955a38 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -131,6 +131,9 @@ later is required to fix a server side protocol bug. p.add_option('-d','--detach', dest='detach_head', action='store_true', help='detach projects back to manifest revision') + p.add_option('-c','--current-branch', + dest='current_branch_only', action='store_true', + help='fetch only current branch from server') p.add_option('-q','--quiet', dest='quiet', action='store_true', help='be more quiet') @@ -179,7 +182,8 @@ later is required to fix a server side protocol bug. # - We always make sure we unlock the lock if we locked it. try: try: - success = project.Sync_NetworkHalf(quiet=opt.quiet) + success = project.Sync_NetworkHalf(quiet=opt.quiet, + current_branch_only=opt.current_branch_only) # Lock around all the rest of the code, since printing, updating a set # and Progress.update() are not thread safe. @@ -212,7 +216,8 @@ later is required to fix a server side protocol bug. if self.jobs == 1: for project in projects: pm.update() - if project.Sync_NetworkHalf(quiet=opt.quiet): + if project.Sync_NetworkHalf(quiet=opt.quiet, + current_branch_only=opt.current_branch_only): fetched.add(project.gitdir) else: print >>sys.stderr, 'error: Cannot fetch %s' % project.name @@ -388,7 +393,8 @@ uncommitted changes are present' % project.relpath _PostRepoUpgrade(self.manifest) if not opt.local_only: - mp.Sync_NetworkHalf(quiet=opt.quiet) + mp.Sync_NetworkHalf(quiet=opt.quiet, + current_branch_only=opt.current_branch_only) if mp.HasChanges: syncbuf = SyncBuffer(mp.config) -- cgit v1.2.3-54-g00ecf