summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 2bdab3a6..ec333ae7 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -131,6 +131,10 @@ of a project from server.
131The -c/--current-branch option can be used to only fetch objects that 131The -c/--current-branch option can be used to only fetch objects that
132are on the branch specified by a project's revision. 132are on the branch specified by a project's revision.
133 133
134The --optimized-fetch option can be used to only fetch projects that
135are fixed to a sha1 revision if the sha1 revision does not already
136exist locally.
137
134SSH Connections 138SSH Connections
135--------------- 139---------------
136 140
@@ -206,6 +210,9 @@ later is required to fix a server side protocol bug.
206 p.add_option('--no-tags', 210 p.add_option('--no-tags',
207 dest='no_tags', action='store_true', 211 dest='no_tags', action='store_true',
208 help="don't fetch tags") 212 help="don't fetch tags")
213 p.add_option('--optimized-fetch',
214 dest='optimized_fetch', action='store_true',
215 help='only fetch projects fixed to sha1 if revision does not exist locally')
209 if show_smart: 216 if show_smart:
210 p.add_option('-s', '--smart-sync', 217 p.add_option('-s', '--smart-sync',
211 dest='smart_sync', action='store_true', 218 dest='smart_sync', action='store_true',
@@ -275,7 +282,8 @@ later is required to fix a server side protocol bug.
275 quiet=opt.quiet, 282 quiet=opt.quiet,
276 current_branch_only=opt.current_branch_only, 283 current_branch_only=opt.current_branch_only,
277 clone_bundle=not opt.no_clone_bundle, 284 clone_bundle=not opt.no_clone_bundle,
278 no_tags=opt.no_tags, archive=self.manifest.IsArchive) 285 no_tags=opt.no_tags, archive=self.manifest.IsArchive,
286 optimized_fetch=opt.optimized_fetch)
279 self._fetch_times.Set(project, time.time() - start) 287 self._fetch_times.Set(project, time.time() - start)
280 288
281 # Lock around all the rest of the code, since printing, updating a set 289 # Lock around all the rest of the code, since printing, updating a set
@@ -509,6 +517,9 @@ later is required to fix a server side protocol bug.
509 self.manifest.Override(opt.manifest_name) 517 self.manifest.Override(opt.manifest_name)
510 518
511 manifest_name = opt.manifest_name 519 manifest_name = opt.manifest_name
520 smart_sync_manifest_name = "smart_sync_override.xml"
521 smart_sync_manifest_path = os.path.join(
522 self.manifest.manifestProject.worktree, smart_sync_manifest_name)
512 523
513 if opt.smart_sync or opt.smart_tag: 524 if opt.smart_sync or opt.smart_tag:
514 if not self.manifest.manifest_server: 525 if not self.manifest.manifest_server:
@@ -575,17 +586,16 @@ later is required to fix a server side protocol bug.
575 [success, manifest_str] = server.GetManifest(opt.smart_tag) 586 [success, manifest_str] = server.GetManifest(opt.smart_tag)
576 587
577 if success: 588 if success:
578 manifest_name = "smart_sync_override.xml" 589 manifest_name = smart_sync_manifest_name
579 manifest_path = os.path.join(self.manifest.manifestProject.worktree,
580 manifest_name)
581 try: 590 try:
582 f = open(manifest_path, 'w') 591 f = open(smart_sync_manifest_path, 'w')
583 try: 592 try:
584 f.write(manifest_str) 593 f.write(manifest_str)
585 finally: 594 finally:
586 f.close() 595 f.close()
587 except IOError: 596 except IOError as e:
588 print('error: cannot write manifest to %s' % manifest_path, 597 print('error: cannot write manifest to %s:\n%s'
598 % (smart_sync_manifest_path, e),
589 file=sys.stderr) 599 file=sys.stderr)
590 sys.exit(1) 600 sys.exit(1)
591 self._ReloadManifest(manifest_name) 601 self._ReloadManifest(manifest_name)
@@ -602,6 +612,13 @@ later is required to fix a server side protocol bug.
602 % (self.manifest.manifest_server, e.errcode, e.errmsg), 612 % (self.manifest.manifest_server, e.errcode, e.errmsg),
603 file=sys.stderr) 613 file=sys.stderr)
604 sys.exit(1) 614 sys.exit(1)
615 else: # Not smart sync or smart tag mode
616 if os.path.isfile(smart_sync_manifest_path):
617 try:
618 os.remove(smart_sync_manifest_path)
619 except OSError as e:
620 print('error: failed to remove existing smart sync override manifest: %s' %
621 e, file=sys.stderr)
605 622
606 rp = self.manifest.repoProject 623 rp = self.manifest.repoProject
607 rp.PreSync() 624 rp.PreSync()
@@ -615,7 +632,8 @@ later is required to fix a server side protocol bug.
615 if not opt.local_only: 632 if not opt.local_only:
616 mp.Sync_NetworkHalf(quiet=opt.quiet, 633 mp.Sync_NetworkHalf(quiet=opt.quiet,
617 current_branch_only=opt.current_branch_only, 634 current_branch_only=opt.current_branch_only,
618 no_tags=opt.no_tags) 635 no_tags=opt.no_tags,
636 optimized_fetch=opt.optimized_fetch)
619 637
620 if mp.HasChanges: 638 if mp.HasChanges:
621 syncbuf = SyncBuffer(mp.config) 639 syncbuf = SyncBuffer(mp.config)