summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/sync.py150
-rw-r--r--tests/test_subcmds_sync.py2
2 files changed, 83 insertions, 69 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 3451ab6b..9a66e48b 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -170,9 +170,9 @@ later is required to fix a server side protocol bug.
170 PARALLEL_JOBS = 1 170 PARALLEL_JOBS = 1
171 171
172 def _CommonOptions(self, p): 172 def _CommonOptions(self, p):
173 if self.manifest: 173 if self.outer_client and self.outer_client.manifest:
174 try: 174 try:
175 self.PARALLEL_JOBS = self.manifest.default.sync_j 175 self.PARALLEL_JOBS = self.outer_client.manifest.default.sync_j
176 except ManifestParseError: 176 except ManifestParseError:
177 pass 177 pass
178 super()._CommonOptions(p) 178 super()._CommonOptions(p)
@@ -270,25 +270,32 @@ later is required to fix a server side protocol bug.
270 dest='repo_upgraded', action='store_true', 270 dest='repo_upgraded', action='store_true',
271 help=SUPPRESS_HELP) 271 help=SUPPRESS_HELP)
272 272
273 def _GetBranch(self): 273 def _GetBranch(self, manifest_project):
274 """Returns the branch name for getting the approved manifest.""" 274 """Returns the branch name for getting the approved smartsync manifest.
275 p = self.manifest.manifestProject 275
276 b = p.GetBranch(p.CurrentBranch) 276 Args:
277 manifest_project: the manifestProject to query.
278 """
279 b = manifest_project.GetBranch(manifest_project.CurrentBranch)
277 branch = b.merge 280 branch = b.merge
278 if branch.startswith(R_HEADS): 281 if branch.startswith(R_HEADS):
279 branch = branch[len(R_HEADS):] 282 branch = branch[len(R_HEADS):]
280 return branch 283 return branch
281 284
282 def _GetCurrentBranchOnly(self, opt): 285 def _GetCurrentBranchOnly(self, opt, manifest):
283 """Returns whether current-branch or use-superproject options are enabled. 286 """Returns whether current-branch or use-superproject options are enabled.
284 287
288 Args:
289 opt: Program options returned from optparse. See _Options().
290 manifest: The manifest to use.
291
285 Returns: 292 Returns:
286 True if a superproject is requested, otherwise the value of the 293 True if a superproject is requested, otherwise the value of the
287 current_branch option (True, False or None). 294 current_branch option (True, False or None).
288 """ 295 """
289 return git_superproject.UseSuperproject(opt.use_superproject, self.manifest) or opt.current_branch_only 296 return git_superproject.UseSuperproject(opt.use_superproject, manifest) or opt.current_branch_only
290 297
291 def _UpdateProjectsRevisionId(self, opt, args, load_local_manifests, superproject_logging_data): 298 def _UpdateProjectsRevisionId(self, opt, args, load_local_manifests, superproject_logging_data, manifest):
292 """Update revisionId of every project with the SHA from superproject. 299 """Update revisionId of every project with the SHA from superproject.
293 300
294 This function updates each project's revisionId with SHA from superproject. 301 This function updates each project's revisionId with SHA from superproject.
@@ -300,6 +307,7 @@ later is required to fix a server side protocol bug.
300 docstring for details. 307 docstring for details.
301 load_local_manifests: Whether to load local manifests. 308 load_local_manifests: Whether to load local manifests.
302 superproject_logging_data: A dictionary of superproject data that is to be logged. 309 superproject_logging_data: A dictionary of superproject data that is to be logged.
310 manifest: The manifest to use.
303 311
304 Returns: 312 Returns:
305 Returns path to the overriding manifest file instead of None. 313 Returns path to the overriding manifest file instead of None.
@@ -312,7 +320,7 @@ later is required to fix a server side protocol bug.
312 if opt.local_only: 320 if opt.local_only:
313 manifest_path = superproject.manifest_path 321 manifest_path = superproject.manifest_path
314 if manifest_path: 322 if manifest_path:
315 self._ReloadManifest(manifest_path, load_local_manifests) 323 self._ReloadManifest(manifest_path, manifest, load_local_manifests)
316 return manifest_path 324 return manifest_path
317 325
318 all_projects = self.GetProjects(args, 326 all_projects = self.GetProjects(args,
@@ -323,7 +331,7 @@ later is required to fix a server side protocol bug.
323 manifest_path = update_result.manifest_path 331 manifest_path = update_result.manifest_path
324 superproject_logging_data['updatedrevisionid'] = bool(manifest_path) 332 superproject_logging_data['updatedrevisionid'] = bool(manifest_path)
325 if manifest_path: 333 if manifest_path:
326 self._ReloadManifest(manifest_path, load_local_manifests) 334 self._ReloadManifest(manifest_path, manifest, load_local_manifests)
327 else: 335 else:
328 if print_messages: 336 if print_messages:
329 print('warning: Update of revisionId from superproject has failed, ' 337 print('warning: Update of revisionId from superproject has failed, '
@@ -366,16 +374,16 @@ later is required to fix a server side protocol bug.
366 quiet=opt.quiet, 374 quiet=opt.quiet,
367 verbose=opt.verbose, 375 verbose=opt.verbose,
368 output_redir=buf, 376 output_redir=buf,
369 current_branch_only=self._GetCurrentBranchOnly(opt), 377 current_branch_only=self._GetCurrentBranchOnly(opt, project.manifest),
370 force_sync=opt.force_sync, 378 force_sync=opt.force_sync,
371 clone_bundle=opt.clone_bundle, 379 clone_bundle=opt.clone_bundle,
372 tags=opt.tags, archive=self.manifest.IsArchive, 380 tags=opt.tags, archive=project.manifest.IsArchive,
373 optimized_fetch=opt.optimized_fetch, 381 optimized_fetch=opt.optimized_fetch,
374 retry_fetches=opt.retry_fetches, 382 retry_fetches=opt.retry_fetches,
375 prune=opt.prune, 383 prune=opt.prune,
376 ssh_proxy=self.ssh_proxy, 384 ssh_proxy=self.ssh_proxy,
377 clone_filter=self.manifest.CloneFilter, 385 clone_filter=project.manifest.CloneFilter,
378 partial_clone_exclude=self.manifest.PartialCloneExclude) 386 partial_clone_exclude=project.manifest.PartialCloneExclude)
379 387
380 output = buf.getvalue() 388 output = buf.getvalue()
381 if (opt.verbose or not success) and output: 389 if (opt.verbose or not success) and output:
@@ -472,13 +480,13 @@ later is required to fix a server side protocol bug.
472 pm.end() 480 pm.end()
473 self._fetch_times.Save() 481 self._fetch_times.Save()
474 482
475 if not self.manifest.IsArchive: 483 if not self.outer_client.manifest.IsArchive:
476 self._GCProjects(projects, opt, err_event) 484 self._GCProjects(projects, opt, err_event)
477 485
478 return (ret, fetched) 486 return (ret, fetched)
479 487
480 def _FetchMain(self, opt, args, all_projects, err_event, manifest_name, 488 def _FetchMain(self, opt, args, all_projects, err_event, manifest_name,
481 load_local_manifests, ssh_proxy): 489 load_local_manifests, ssh_proxy, manifest):
482 """The main network fetch loop. 490 """The main network fetch loop.
483 491
484 Args: 492 Args:
@@ -489,11 +497,12 @@ later is required to fix a server side protocol bug.
489 manifest_name: Manifest file to be reloaded. 497 manifest_name: Manifest file to be reloaded.
490 load_local_manifests: Whether to load local manifests. 498 load_local_manifests: Whether to load local manifests.
491 ssh_proxy: SSH manager for clients & masters. 499 ssh_proxy: SSH manager for clients & masters.
500 manifest: The manifest to use.
492 501
493 Returns: 502 Returns:
494 List of all projects that should be checked out. 503 List of all projects that should be checked out.
495 """ 504 """
496 rp = self.manifest.repoProject 505 rp = manifest.repoProject
497 506
498 to_fetch = [] 507 to_fetch = []
499 now = time.time() 508 now = time.time()
@@ -517,7 +526,7 @@ later is required to fix a server side protocol bug.
517 # Iteratively fetch missing and/or nested unregistered submodules 526 # Iteratively fetch missing and/or nested unregistered submodules
518 previously_missing_set = set() 527 previously_missing_set = set()
519 while True: 528 while True:
520 self._ReloadManifest(manifest_name, load_local_manifests) 529 self._ReloadManifest(manifest_name, self.manifest, load_local_manifests)
521 all_projects = self.GetProjects(args, 530 all_projects = self.GetProjects(args,
522 missing_ok=True, 531 missing_ok=True,
523 submodules_ok=opt.fetch_submodules) 532 submodules_ok=opt.fetch_submodules)
@@ -552,7 +561,7 @@ later is required to fix a server side protocol bug.
552 Whether the fetch was successful. 561 Whether the fetch was successful.
553 """ 562 """
554 start = time.time() 563 start = time.time()
555 syncbuf = SyncBuffer(self.manifest.manifestProject.config, 564 syncbuf = SyncBuffer(project.manifest.manifestProject.config,
556 detach_head=detach_head) 565 detach_head=detach_head)
557 success = False 566 success = False
558 try: 567 try:
@@ -689,28 +698,29 @@ later is required to fix a server side protocol bug.
689 t.join() 698 t.join()
690 pm.end() 699 pm.end()
691 700
692 def _ReloadManifest(self, manifest_name=None, load_local_manifests=True): 701 def _ReloadManifest(self, manifest_name, manifest, load_local_manifests=True):
693 """Reload the manfiest from the file specified by the |manifest_name|. 702 """Reload the manfiest from the file specified by the |manifest_name|.
694 703
695 It unloads the manifest if |manifest_name| is None. 704 It unloads the manifest if |manifest_name| is None.
696 705
697 Args: 706 Args:
698 manifest_name: Manifest file to be reloaded. 707 manifest_name: Manifest file to be reloaded.
708 manifest: The manifest to use.
699 load_local_manifests: Whether to load local manifests. 709 load_local_manifests: Whether to load local manifests.
700 """ 710 """
701 if manifest_name: 711 if manifest_name:
702 # Override calls Unload already 712 # Override calls Unload already
703 self.manifest.Override(manifest_name, load_local_manifests=load_local_manifests) 713 manifest.Override(manifest_name, load_local_manifests=load_local_manifests)
704 else: 714 else:
705 self.manifest.Unload() 715 manifest.Unload()
706 716
707 def UpdateProjectList(self, opt): 717 def UpdateProjectList(self, opt, manifest):
708 new_project_paths = [] 718 new_project_paths = []
709 for project in self.GetProjects(None, missing_ok=True): 719 for project in self.GetProjects(None, missing_ok=True):
710 if project.relpath: 720 if project.relpath:
711 new_project_paths.append(project.relpath) 721 new_project_paths.append(project.relpath)
712 file_name = 'project.list' 722 file_name = 'project.list'
713 file_path = os.path.join(self.manifest.subdir, file_name) 723 file_path = os.path.join(manifest.subdir, file_name)
714 old_project_paths = [] 724 old_project_paths = []
715 725
716 if os.path.exists(file_path): 726 if os.path.exists(file_path):
@@ -722,16 +732,16 @@ later is required to fix a server side protocol bug.
722 continue 732 continue
723 if path not in new_project_paths: 733 if path not in new_project_paths:
724 # If the path has already been deleted, we don't need to do it 734 # If the path has already been deleted, we don't need to do it
725 gitdir = os.path.join(self.manifest.topdir, path, '.git') 735 gitdir = os.path.join(manifest.topdir, path, '.git')
726 if os.path.exists(gitdir): 736 if os.path.exists(gitdir):
727 project = Project( 737 project = Project(
728 manifest=self.manifest, 738 manifest=manifest,
729 name=path, 739 name=path,
730 remote=RemoteSpec('origin'), 740 remote=RemoteSpec('origin'),
731 gitdir=gitdir, 741 gitdir=gitdir,
732 objdir=gitdir, 742 objdir=gitdir,
733 use_git_worktrees=os.path.isfile(gitdir), 743 use_git_worktrees=os.path.isfile(gitdir),
734 worktree=os.path.join(self.manifest.topdir, path), 744 worktree=os.path.join(manifest.topdir, path),
735 relpath=path, 745 relpath=path,
736 revisionExpr='HEAD', 746 revisionExpr='HEAD',
737 revisionId=None, 747 revisionId=None,
@@ -747,7 +757,7 @@ later is required to fix a server side protocol bug.
747 fd.write('\n') 757 fd.write('\n')
748 return 0 758 return 0
749 759
750 def UpdateCopyLinkfileList(self): 760 def UpdateCopyLinkfileList(self, manifest):
751 """Save all dests of copyfile and linkfile, and update them if needed. 761 """Save all dests of copyfile and linkfile, and update them if needed.
752 762
753 Returns: 763 Returns:
@@ -766,7 +776,7 @@ later is required to fix a server side protocol bug.
766 } 776 }
767 777
768 copylinkfile_name = 'copy-link-files.json' 778 copylinkfile_name = 'copy-link-files.json'
769 copylinkfile_path = os.path.join(self.manifest.subdir, copylinkfile_name) 779 copylinkfile_path = os.path.join(manifest.subdir, copylinkfile_name)
770 old_copylinkfile_paths = {} 780 old_copylinkfile_paths = {}
771 781
772 if os.path.exists(copylinkfile_path): 782 if os.path.exists(copylinkfile_path):
@@ -797,13 +807,13 @@ later is required to fix a server side protocol bug.
797 json.dump(new_paths, fp) 807 json.dump(new_paths, fp)
798 return True 808 return True
799 809
800 def _SmartSyncSetup(self, opt, smart_sync_manifest_path): 810 def _SmartSyncSetup(self, opt, smart_sync_manifest_path, manifest):
801 if not self.manifest.manifest_server: 811 if not manifest.manifest_server:
802 print('error: cannot smart sync: no manifest server defined in ' 812 print('error: cannot smart sync: no manifest server defined in '
803 'manifest', file=sys.stderr) 813 'manifest', file=sys.stderr)
804 sys.exit(1) 814 sys.exit(1)
805 815
806 manifest_server = self.manifest.manifest_server 816 manifest_server = manifest.manifest_server
807 if not opt.quiet: 817 if not opt.quiet:
808 print('Using manifest server %s' % manifest_server) 818 print('Using manifest server %s' % manifest_server)
809 819
@@ -844,7 +854,7 @@ later is required to fix a server side protocol bug.
844 try: 854 try:
845 server = xmlrpc.client.Server(manifest_server, transport=transport) 855 server = xmlrpc.client.Server(manifest_server, transport=transport)
846 if opt.smart_sync: 856 if opt.smart_sync:
847 branch = self._GetBranch() 857 branch = self._GetBranch(manifest.manifestProject)
848 858
849 if 'SYNC_TARGET' in os.environ: 859 if 'SYNC_TARGET' in os.environ:
850 target = os.environ['SYNC_TARGET'] 860 target = os.environ['SYNC_TARGET']
@@ -870,18 +880,18 @@ later is required to fix a server side protocol bug.
870 % (smart_sync_manifest_path, e), 880 % (smart_sync_manifest_path, e),
871 file=sys.stderr) 881 file=sys.stderr)
872 sys.exit(1) 882 sys.exit(1)
873 self._ReloadManifest(manifest_name) 883 self._ReloadManifest(manifest_name, manifest)
874 else: 884 else:
875 print('error: manifest server RPC call failed: %s' % 885 print('error: manifest server RPC call failed: %s' %
876 manifest_str, file=sys.stderr) 886 manifest_str, file=sys.stderr)
877 sys.exit(1) 887 sys.exit(1)
878 except (socket.error, IOError, xmlrpc.client.Fault) as e: 888 except (socket.error, IOError, xmlrpc.client.Fault) as e:
879 print('error: cannot connect to manifest server %s:\n%s' 889 print('error: cannot connect to manifest server %s:\n%s'
880 % (self.manifest.manifest_server, e), file=sys.stderr) 890 % (manifest.manifest_server, e), file=sys.stderr)
881 sys.exit(1) 891 sys.exit(1)
882 except xmlrpc.client.ProtocolError as e: 892 except xmlrpc.client.ProtocolError as e:
883 print('error: cannot connect to manifest server %s:\n%d %s' 893 print('error: cannot connect to manifest server %s:\n%d %s'
884 % (self.manifest.manifest_server, e.errcode, e.errmsg), 894 % (manifest.manifest_server, e.errcode, e.errmsg),
885 file=sys.stderr) 895 file=sys.stderr)
886 sys.exit(1) 896 sys.exit(1)
887 897
@@ -892,14 +902,14 @@ later is required to fix a server side protocol bug.
892 if not opt.local_only: 902 if not opt.local_only:
893 start = time.time() 903 start = time.time()
894 success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, 904 success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose,
895 current_branch_only=self._GetCurrentBranchOnly(opt), 905 current_branch_only=self._GetCurrentBranchOnly(opt, mp.manifest),
896 force_sync=opt.force_sync, 906 force_sync=opt.force_sync,
897 tags=opt.tags, 907 tags=opt.tags,
898 optimized_fetch=opt.optimized_fetch, 908 optimized_fetch=opt.optimized_fetch,
899 retry_fetches=opt.retry_fetches, 909 retry_fetches=opt.retry_fetches,
900 submodules=self.manifest.HasSubmodules, 910 submodules=mp.manifest.HasSubmodules,
901 clone_filter=self.manifest.CloneFilter, 911 clone_filter=mp.manifest.CloneFilter,
902 partial_clone_exclude=self.manifest.PartialCloneExclude) 912 partial_clone_exclude=mp.manifest.PartialCloneExclude)
903 finish = time.time() 913 finish = time.time()
904 self.event_log.AddSync(mp, event_log.TASK_SYNC_NETWORK, 914 self.event_log.AddSync(mp, event_log.TASK_SYNC_NETWORK,
905 start, finish, success) 915 start, finish, success)
@@ -907,15 +917,15 @@ later is required to fix a server side protocol bug.
907 if mp.HasChanges: 917 if mp.HasChanges:
908 syncbuf = SyncBuffer(mp.config) 918 syncbuf = SyncBuffer(mp.config)
909 start = time.time() 919 start = time.time()
910 mp.Sync_LocalHalf(syncbuf, submodules=self.manifest.HasSubmodules) 920 mp.Sync_LocalHalf(syncbuf, submodules=mp.manifest.HasSubmodules)
911 clean = syncbuf.Finish() 921 clean = syncbuf.Finish()
912 self.event_log.AddSync(mp, event_log.TASK_SYNC_LOCAL, 922 self.event_log.AddSync(mp, event_log.TASK_SYNC_LOCAL,
913 start, time.time(), clean) 923 start, time.time(), clean)
914 if not clean: 924 if not clean:
915 sys.exit(1) 925 sys.exit(1)
916 self._ReloadManifest(manifest_name) 926 self._ReloadManifest(manifest_name, mp.manifest)
917 if opt.jobs is None: 927 if opt.jobs is None:
918 self.jobs = self.manifest.default.sync_j 928 self.jobs = mp.manifest.default.sync_j
919 929
920 def ValidateOptions(self, opt, args): 930 def ValidateOptions(self, opt, args):
921 if opt.force_broken: 931 if opt.force_broken:
@@ -938,7 +948,7 @@ later is required to fix a server side protocol bug.
938 if opt.prune is None: 948 if opt.prune is None:
939 opt.prune = True 949 opt.prune = True
940 950
941 if self.manifest.is_multimanifest and not opt.this_manifest_only and args: 951 if self.outer_client.manifest.is_multimanifest and not opt.this_manifest_only and args:
942 self.OptionParser.error('partial syncs must use --this-manifest-only') 952 self.OptionParser.error('partial syncs must use --this-manifest-only')
943 953
944 def Execute(self, opt, args): 954 def Execute(self, opt, args):
@@ -948,18 +958,22 @@ later is required to fix a server side protocol bug.
948 soft_limit, _ = _rlimit_nofile() 958 soft_limit, _ = _rlimit_nofile()
949 self.jobs = min(self.jobs, (soft_limit - 5) // 3) 959 self.jobs = min(self.jobs, (soft_limit - 5) // 3)
950 960
961 manifest = self.outer_manifest
962 if opt.this_manifest_only or not opt.outer_manifest:
963 manifest = self.manifest
964
951 if opt.manifest_name: 965 if opt.manifest_name:
952 self.manifest.Override(opt.manifest_name) 966 manifest.Override(opt.manifest_name)
953 967
954 manifest_name = opt.manifest_name 968 manifest_name = opt.manifest_name
955 smart_sync_manifest_path = os.path.join( 969 smart_sync_manifest_path = os.path.join(
956 self.manifest.manifestProject.worktree, 'smart_sync_override.xml') 970 manifest.manifestProject.worktree, 'smart_sync_override.xml')
957 971
958 if opt.clone_bundle is None: 972 if opt.clone_bundle is None:
959 opt.clone_bundle = self.manifest.CloneBundle 973 opt.clone_bundle = manifest.CloneBundle
960 974
961 if opt.smart_sync or opt.smart_tag: 975 if opt.smart_sync or opt.smart_tag:
962 manifest_name = self._SmartSyncSetup(opt, smart_sync_manifest_path) 976 manifest_name = self._SmartSyncSetup(opt, smart_sync_manifest_path, manifest)
963 else: 977 else:
964 if os.path.isfile(smart_sync_manifest_path): 978 if os.path.isfile(smart_sync_manifest_path):
965 try: 979 try:
@@ -970,7 +984,7 @@ later is required to fix a server side protocol bug.
970 984
971 err_event = multiprocessing.Event() 985 err_event = multiprocessing.Event()
972 986
973 rp = self.manifest.repoProject 987 rp = manifest.repoProject
974 rp.PreSync() 988 rp.PreSync()
975 cb = rp.CurrentBranch 989 cb = rp.CurrentBranch
976 if cb: 990 if cb:
@@ -980,35 +994,35 @@ later is required to fix a server side protocol bug.
980 'receive updates; run `repo init --repo-rev=stable` to fix.', 994 'receive updates; run `repo init --repo-rev=stable` to fix.',
981 file=sys.stderr) 995 file=sys.stderr)
982 996
983 mp = self.manifest.manifestProject 997 mp = manifest.manifestProject
984 is_standalone_manifest = bool(mp.standalone_manifest_url) 998 is_standalone_manifest = bool(mp.standalone_manifest_url)
985 if not is_standalone_manifest: 999 if not is_standalone_manifest:
986 mp.PreSync() 1000 mp.PreSync()
987 1001
988 if opt.repo_upgraded: 1002 if opt.repo_upgraded:
989 _PostRepoUpgrade(self.manifest, quiet=opt.quiet) 1003 _PostRepoUpgrade(manifest, quiet=opt.quiet)
990 1004
991 if not opt.mp_update: 1005 if not opt.mp_update:
992 print('Skipping update of local manifest project.') 1006 print('Skipping update of local manifest project.')
993 elif not is_standalone_manifest: 1007 elif not is_standalone_manifest:
994 self._UpdateManifestProject(opt, mp, manifest_name) 1008 self._UpdateManifestProject(opt, mp, manifest_name)
995 1009
996 load_local_manifests = not self.manifest.HasLocalManifests 1010 load_local_manifests = not manifest.HasLocalManifests
997 use_superproject = git_superproject.UseSuperproject(opt.use_superproject, 1011 use_superproject = git_superproject.UseSuperproject(opt.use_superproject, manifest)
998 self.manifest) 1012 if use_superproject and (manifest.IsMirror or manifest.IsArchive):
999 if use_superproject and (self.manifest.IsMirror or self.manifest.IsArchive):
1000 # Don't use superproject, because we have no working tree. 1013 # Don't use superproject, because we have no working tree.
1001 use_superproject = False 1014 use_superproject = False
1002 if opt.use_superproject is not None: 1015 if opt.use_superproject is not None:
1003 print('Defaulting to no-use-superproject because there is no working tree.') 1016 print('Defaulting to no-use-superproject because there is no working tree.')
1004 superproject_logging_data = { 1017 superproject_logging_data = {
1005 'superproject': use_superproject, 1018 'superproject': use_superproject,
1006 'haslocalmanifests': bool(self.manifest.HasLocalManifests), 1019 'haslocalmanifests': bool(manifest.HasLocalManifests),
1007 'hassuperprojecttag': bool(self.manifest.superproject), 1020 'hassuperprojecttag': bool(manifest.superproject),
1008 } 1021 }
1009 if use_superproject: 1022 if use_superproject:
1010 manifest_name = self._UpdateProjectsRevisionId( 1023 manifest_name = self._UpdateProjectsRevisionId(
1011 opt, args, load_local_manifests, superproject_logging_data) or opt.manifest_name 1024 opt, args, load_local_manifests, superproject_logging_data,
1025 manifest) or opt.manifest_name
1012 1026
1013 if self.gitc_manifest: 1027 if self.gitc_manifest:
1014 gitc_manifest_projects = self.GetProjects(args, 1028 gitc_manifest_projects = self.GetProjects(args,
@@ -1031,7 +1045,7 @@ later is required to fix a server side protocol bug.
1031 if manifest_name: 1045 if manifest_name:
1032 manifest.Override(manifest_name) 1046 manifest.Override(manifest_name)
1033 else: 1047 else:
1034 manifest.Override(self.manifest.manifestFile) 1048 manifest.Override(manifest.manifestFile)
1035 gitc_utils.generate_gitc_manifest(self.gitc_manifest, 1049 gitc_utils.generate_gitc_manifest(self.gitc_manifest,
1036 manifest, 1050 manifest,
1037 gitc_projects) 1051 gitc_projects)
@@ -1041,7 +1055,7 @@ later is required to fix a server side protocol bug.
1041 # generate a new args list to represent the opened projects. 1055 # generate a new args list to represent the opened projects.
1042 # TODO: make this more reliable -- if there's a project name/path overlap, 1056 # TODO: make this more reliable -- if there's a project name/path overlap,
1043 # this may choose the wrong project. 1057 # this may choose the wrong project.
1044 args = [os.path.relpath(self.manifest.paths[path].worktree, os.getcwd()) 1058 args = [os.path.relpath(manifest.paths[path].worktree, os.getcwd())
1045 for path in opened_projects] 1059 for path in opened_projects]
1046 if not args: 1060 if not args:
1047 return 1061 return
@@ -1052,7 +1066,7 @@ later is required to fix a server side protocol bug.
1052 err_network_sync = False 1066 err_network_sync = False
1053 err_update_projects = False 1067 err_update_projects = False
1054 1068
1055 self._fetch_times = _FetchTimes(self.manifest) 1069 self._fetch_times = _FetchTimes(manifest)
1056 if not opt.local_only: 1070 if not opt.local_only:
1057 with multiprocessing.Manager() as manager: 1071 with multiprocessing.Manager() as manager:
1058 with ssh.ProxyManager(manager) as ssh_proxy: 1072 with ssh.ProxyManager(manager) as ssh_proxy:
@@ -1060,7 +1074,7 @@ later is required to fix a server side protocol bug.
1060 ssh_proxy.sock() 1074 ssh_proxy.sock()
1061 all_projects = self._FetchMain(opt, args, all_projects, err_event, 1075 all_projects = self._FetchMain(opt, args, all_projects, err_event,
1062 manifest_name, load_local_manifests, 1076 manifest_name, load_local_manifests,
1063 ssh_proxy) 1077 ssh_proxy, manifest)
1064 1078
1065 if opt.network_only: 1079 if opt.network_only:
1066 return 1080 return
@@ -1076,18 +1090,18 @@ later is required to fix a server side protocol bug.
1076 file=sys.stderr) 1090 file=sys.stderr)
1077 sys.exit(1) 1091 sys.exit(1)
1078 1092
1079 if self.manifest.IsMirror or self.manifest.IsArchive: 1093 if manifest.IsMirror or manifest.IsArchive:
1080 # bail out now, we have no working tree 1094 # bail out now, we have no working tree
1081 return 1095 return
1082 1096
1083 if self.UpdateProjectList(opt): 1097 if self.UpdateProjectList(opt, manifest):
1084 err_event.set() 1098 err_event.set()
1085 err_update_projects = True 1099 err_update_projects = True
1086 if opt.fail_fast: 1100 if opt.fail_fast:
1087 print('\nerror: Local checkouts *not* updated.', file=sys.stderr) 1101 print('\nerror: Local checkouts *not* updated.', file=sys.stderr)
1088 sys.exit(1) 1102 sys.exit(1)
1089 1103
1090 err_update_linkfiles = not self.UpdateCopyLinkfileList() 1104 err_update_linkfiles = not self.UpdateCopyLinkfileList(manifest)
1091 if err_update_linkfiles: 1105 if err_update_linkfiles:
1092 err_event.set() 1106 err_event.set()
1093 if opt.fail_fast: 1107 if opt.fail_fast:
@@ -1102,8 +1116,8 @@ later is required to fix a server side protocol bug.
1102 1116
1103 # If there's a notice that's supposed to print at the end of the sync, print 1117 # If there's a notice that's supposed to print at the end of the sync, print
1104 # it now... 1118 # it now...
1105 if self.manifest.notice: 1119 if manifest.notice:
1106 print(self.manifest.notice) 1120 print(manifest.notice)
1107 1121
1108 # If we saw an error, exit with code 1 so that other scripts can check. 1122 # If we saw an error, exit with code 1 so that other scripts can check.
1109 if err_event.is_set(): 1123 if err_event.is_set():
diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py
index c1d1758e..aad713f2 100644
--- a/tests/test_subcmds_sync.py
+++ b/tests/test_subcmds_sync.py
@@ -42,4 +42,4 @@ def test_get_current_branch_only(use_superproject, cli_args, result):
42 opts, _ = cmd.OptionParser.parse_args(cli_args) 42 opts, _ = cmd.OptionParser.parse_args(cli_args)
43 43
44 with mock.patch('git_superproject.UseSuperproject', return_value=use_superproject): 44 with mock.patch('git_superproject.UseSuperproject', return_value=use_superproject):
45 assert cmd._GetCurrentBranchOnly(opts) == result 45 assert cmd._GetCurrentBranchOnly(opts, cmd.manifest) == result