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>
This commit is contained in:
Raman Tenneti 2021-03-23 15:12:27 -07:00
parent d1e4fa7015
commit 2ae44d7029

View File

@ -277,6 +277,16 @@ later is required to fix a server side protocol bug.
branch = branch[len(R_HEADS):] branch = branch[len(R_HEADS):]
return branch return branch
def _UseSuperproject(self, opt):
"""Returns True if use-superproject option is enabled"""
return (opt.use_superproject or
self.manifest.manifestProject.config.GetBoolean(
'repo.superproject'))
def _GetCurrentBranchOnly(self, opt):
"""Returns True if current-branch or use-superproject options are enabled."""
return opt.current_branch_only or self._UseSuperproject(opt)
def _UpdateProjectsRevisionId(self, opt, args): def _UpdateProjectsRevisionId(self, opt, args):
"""Update revisionId of every project with the SHA from superproject. """Update revisionId of every project with the SHA from superproject.
@ -363,7 +373,7 @@ later is required to fix a server side protocol bug.
quiet=opt.quiet, quiet=opt.quiet,
verbose=opt.verbose, verbose=opt.verbose,
output_redir=buf, output_redir=buf,
current_branch_only=opt.current_branch_only, current_branch_only=self._GetCurrentBranchOnly(opt),
force_sync=opt.force_sync, force_sync=opt.force_sync,
clone_bundle=opt.clone_bundle, clone_bundle=opt.clone_bundle,
tags=opt.tags, archive=self.manifest.IsArchive, tags=opt.tags, archive=self.manifest.IsArchive,
@ -735,7 +745,7 @@ later is required to fix a server side protocol bug.
if not opt.local_only: if not opt.local_only:
start = time.time() start = time.time()
success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose,
current_branch_only=opt.current_branch_only, current_branch_only=self._GetCurrentBranchOnly(opt),
force_sync=opt.force_sync, force_sync=opt.force_sync,
tags=opt.tags, tags=opt.tags,
optimized_fetch=opt.optimized_fetch, optimized_fetch=opt.optimized_fetch,
@ -830,9 +840,7 @@ later is required to fix a server side protocol bug.
else: else:
self._UpdateManifestProject(opt, mp, manifest_name) self._UpdateManifestProject(opt, mp, manifest_name)
if (opt.use_superproject or if self._UseSuperproject(opt):
self.manifest.manifestProject.config.GetBoolean(
'repo.superproject')):
manifest_name = self._UpdateProjectsRevisionId(opt, args) manifest_name = self._UpdateProjectsRevisionId(opt, args)
if self.gitc_manifest: if self.gitc_manifest: