diff options
author | Anatol Pomazau <anatol@google.com> | 2011-08-25 17:21:47 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-11-03 13:08:27 -0700 |
commit | 53d6f4d17e0cb4eabcd604d584a1132a51cc8bf3 (patch) | |
tree | c9effdc3a5d890ac55fb8a9f2aa68ac0d500873e /subcmds/sync.py | |
parent | 9d8f914fe8ac75e18e0da2b7ce4886a2ba490fc6 (diff) | |
download | git-repo-53d6f4d17e0cb4eabcd604d584a1132a51cc8bf3.tar.gz |
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
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 12 |
1 files changed, 9 insertions, 3 deletions
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. | |||
131 | p.add_option('-d','--detach', | 131 | p.add_option('-d','--detach', |
132 | dest='detach_head', action='store_true', | 132 | dest='detach_head', action='store_true', |
133 | help='detach projects back to manifest revision') | 133 | help='detach projects back to manifest revision') |
134 | p.add_option('-c','--current-branch', | ||
135 | dest='current_branch_only', action='store_true', | ||
136 | help='fetch only current branch from server') | ||
134 | p.add_option('-q','--quiet', | 137 | p.add_option('-q','--quiet', |
135 | dest='quiet', action='store_true', | 138 | dest='quiet', action='store_true', |
136 | help='be more quiet') | 139 | help='be more quiet') |
@@ -179,7 +182,8 @@ later is required to fix a server side protocol bug. | |||
179 | # - We always make sure we unlock the lock if we locked it. | 182 | # - We always make sure we unlock the lock if we locked it. |
180 | try: | 183 | try: |
181 | try: | 184 | try: |
182 | success = project.Sync_NetworkHalf(quiet=opt.quiet) | 185 | success = project.Sync_NetworkHalf(quiet=opt.quiet, |
186 | current_branch_only=opt.current_branch_only) | ||
183 | 187 | ||
184 | # Lock around all the rest of the code, since printing, updating a set | 188 | # Lock around all the rest of the code, since printing, updating a set |
185 | # and Progress.update() are not thread safe. | 189 | # and Progress.update() are not thread safe. |
@@ -212,7 +216,8 @@ later is required to fix a server side protocol bug. | |||
212 | if self.jobs == 1: | 216 | if self.jobs == 1: |
213 | for project in projects: | 217 | for project in projects: |
214 | pm.update() | 218 | pm.update() |
215 | if project.Sync_NetworkHalf(quiet=opt.quiet): | 219 | if project.Sync_NetworkHalf(quiet=opt.quiet, |
220 | current_branch_only=opt.current_branch_only): | ||
216 | fetched.add(project.gitdir) | 221 | fetched.add(project.gitdir) |
217 | else: | 222 | else: |
218 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name | 223 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name |
@@ -388,7 +393,8 @@ uncommitted changes are present' % project.relpath | |||
388 | _PostRepoUpgrade(self.manifest) | 393 | _PostRepoUpgrade(self.manifest) |
389 | 394 | ||
390 | if not opt.local_only: | 395 | if not opt.local_only: |
391 | mp.Sync_NetworkHalf(quiet=opt.quiet) | 396 | mp.Sync_NetworkHalf(quiet=opt.quiet, |
397 | current_branch_only=opt.current_branch_only) | ||
392 | 398 | ||
393 | if mp.HasChanges: | 399 | if mp.HasChanges: |
394 | syncbuf = SyncBuffer(mp.config) | 400 | syncbuf = SyncBuffer(mp.config) |