summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-03-23 15:12:27 -0700
committerRaman Tenneti <rtenneti@google.com>2021-03-24 15:17:19 +0000
commit2ae44d7029fd435be96ba48eb1e367241c36c940 (patch)
treea2ae9fe91c38dddb61294bd94e0db4bef08b2a0b /subcmds/sync.py
parentd1e4fa7015379cfa3c7ee0fe091bc5910754425f (diff)
downloadgit-repo-2ae44d7029fd435be96ba48eb1e367241c36c940.tar.gz
sync: imply -c if --use-superproject option is used.
Tested the code with the following commands. $ ./run_tests -v Bug: [google internal] b/183232698 Bug: https://crbug.com/gerrit/13707 $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject $ repo_dev sync --use-superproject $ repo_dev sync real 0m8.046s user 0m2.866s sys 0m2.457s Second time repo sync took only 8 seconds and verified by printing that urrent_branch_only is True in project.py's Sync_NetworkHalf function. Change-Id: Ic48efb23ea427dfa36e12a5c49973d6ae776d818 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/301182 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 2953ee3b..b14ad246 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -277,6 +277,16 @@ later is required to fix a server side protocol bug.
277 branch = branch[len(R_HEADS):] 277 branch = branch[len(R_HEADS):]
278 return branch 278 return branch
279 279
280 def _UseSuperproject(self, opt):
281 """Returns True if use-superproject option is enabled"""
282 return (opt.use_superproject or
283 self.manifest.manifestProject.config.GetBoolean(
284 'repo.superproject'))
285
286 def _GetCurrentBranchOnly(self, opt):
287 """Returns True if current-branch or use-superproject options are enabled."""
288 return opt.current_branch_only or self._UseSuperproject(opt)
289
280 def _UpdateProjectsRevisionId(self, opt, args): 290 def _UpdateProjectsRevisionId(self, opt, args):
281 """Update revisionId of every project with the SHA from superproject. 291 """Update revisionId of every project with the SHA from superproject.
282 292
@@ -363,7 +373,7 @@ later is required to fix a server side protocol bug.
363 quiet=opt.quiet, 373 quiet=opt.quiet,
364 verbose=opt.verbose, 374 verbose=opt.verbose,
365 output_redir=buf, 375 output_redir=buf,
366 current_branch_only=opt.current_branch_only, 376 current_branch_only=self._GetCurrentBranchOnly(opt),
367 force_sync=opt.force_sync, 377 force_sync=opt.force_sync,
368 clone_bundle=opt.clone_bundle, 378 clone_bundle=opt.clone_bundle,
369 tags=opt.tags, archive=self.manifest.IsArchive, 379 tags=opt.tags, archive=self.manifest.IsArchive,
@@ -735,7 +745,7 @@ later is required to fix a server side protocol bug.
735 if not opt.local_only: 745 if not opt.local_only:
736 start = time.time() 746 start = time.time()
737 success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, 747 success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose,
738 current_branch_only=opt.current_branch_only, 748 current_branch_only=self._GetCurrentBranchOnly(opt),
739 force_sync=opt.force_sync, 749 force_sync=opt.force_sync,
740 tags=opt.tags, 750 tags=opt.tags,
741 optimized_fetch=opt.optimized_fetch, 751 optimized_fetch=opt.optimized_fetch,
@@ -830,9 +840,7 @@ later is required to fix a server side protocol bug.
830 else: 840 else:
831 self._UpdateManifestProject(opt, mp, manifest_name) 841 self._UpdateManifestProject(opt, mp, manifest_name)
832 842
833 if (opt.use_superproject or 843 if self._UseSuperproject(opt):
834 self.manifest.manifestProject.config.GetBoolean(
835 'repo.superproject')):
836 manifest_name = self._UpdateProjectsRevisionId(opt, args) 844 manifest_name = self._UpdateProjectsRevisionId(opt, args)
837 845
838 if self.gitc_manifest: 846 if self.gitc_manifest: