summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-02-09 00:26:31 -0800
committerRaman Tenneti <rtenneti@google.com>2021-02-11 18:59:29 +0000
commit21dce3d8b351538d0fe8c05e6106c8b281580dda (patch)
tree771c7d005adc27acfbfdd7e6e85339766efdb810 /subcmds/init.py
parente3315bb49a782bcf62ba9df4fc1c2690b046763f (diff)
downloadgit-repo-21dce3d8b351538d0fe8c05e6106c8b281580dda.tar.gz
init: added --use-superproject option to clone superproject.v2.12.2
Added --no-use-superproject to repo and init.py to disable use of manifest superprojects. Replaced the term "sha" with "commit id". Added _GetBranch method to Superproject object. Moved shared code between init and sync into SyncSuperproject function. This function either does git clone or git fetch. If git fetch fails it does git clone. Changed Superproject constructor to accept manifest, repodir and branch to avoid passing them to multiple functions as argument. Changed functions that were raising exceptions to return either True or False. Saved the --use-superproject option in config as repo.superproject. Updated internal-fs-layout.md document. Updated the tests to work with the new API changes in Superproject. Performance for the first time sync has improved from 20 minutes to around 15 minutes. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ repo init took around 20 seconds longer because of cloning of superproject. $ time 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 ... real 0m35.919s user 0m21.947s sys 0m8.977s First run $ time repo sync --use-superproject ... real 16m41.982s user 100m6.916s sys 19m18.753s No difference in repo sync time after the first run. Bug: [google internal] b/179090734 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Change-Id: I12df92112f46e001dfbc6f12cd633c3a15cf924b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296382 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index fe3ebd2c..1d16c856 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -25,6 +25,7 @@ from error import ManifestParseError
25from project import SyncBuffer 25from project import SyncBuffer
26from git_config import GitConfig 26from git_config import GitConfig
27from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD 27from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD
28import git_superproject
28import platform_utils 29import platform_utils
29from wrapper import Wrapper 30from wrapper import Wrapper
30 31
@@ -134,6 +135,11 @@ to update the working directory files.
134 g.add_option('--submodules', 135 g.add_option('--submodules',
135 dest='submodules', action='store_true', 136 dest='submodules', action='store_true',
136 help='sync any submodules associated with the manifest repo') 137 help='sync any submodules associated with the manifest repo')
138 g.add_option('--use-superproject', action='store_true',
139 help='use the manifest superproject to sync projects')
140 g.add_option('--no-use-superproject', action='store_false',
141 dest='use_superproject',
142 help='disable use of manifest superprojects')
137 g.add_option('-g', '--groups', 143 g.add_option('-g', '--groups',
138 dest='groups', default='default', 144 dest='groups', default='default',
139 help='restrict manifest projects to ones with specified ' 145 help='restrict manifest projects to ones with specified '
@@ -176,6 +182,14 @@ to update the working directory files.
176 return {'REPO_MANIFEST_URL': 'manifest_url', 182 return {'REPO_MANIFEST_URL': 'manifest_url',
177 'REPO_MIRROR_LOCATION': 'reference'} 183 'REPO_MIRROR_LOCATION': 'reference'}
178 184
185 def _CloneSuperproject(self):
186 """Clone the superproject based on the superproject's url and branch."""
187 superproject = git_superproject.Superproject(self.manifest,
188 self.repodir)
189 if not superproject.Sync():
190 print('error: git update of superproject failed', file=sys.stderr)
191 sys.exit(1)
192
179 def _SyncManifest(self, opt): 193 def _SyncManifest(self, opt):
180 m = self.manifest.manifestProject 194 m = self.manifest.manifestProject
181 is_new = not m.Exists 195 is_new = not m.Exists
@@ -305,6 +319,9 @@ to update the working directory files.
305 if opt.submodules: 319 if opt.submodules:
306 m.config.SetBoolean('repo.submodules', opt.submodules) 320 m.config.SetBoolean('repo.submodules', opt.submodules)
307 321
322 if opt.use_superproject is not None:
323 m.config.SetBoolean('repo.superproject', opt.use_superproject)
324
308 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, verbose=opt.verbose, 325 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, verbose=opt.verbose,
309 clone_bundle=opt.clone_bundle, 326 clone_bundle=opt.clone_bundle,
310 current_branch_only=opt.current_branch_only, 327 current_branch_only=opt.current_branch_only,
@@ -519,6 +536,9 @@ to update the working directory files.
519 self._SyncManifest(opt) 536 self._SyncManifest(opt)
520 self._LinkManifest(opt.manifest_name) 537 self._LinkManifest(opt.manifest_name)
521 538
539 if self.manifest.manifestProject.config.GetBoolean('repo.superproject'):
540 self._CloneSuperproject()
541
522 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: 542 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
523 if opt.config_name or self._ShouldConfigureUser(opt): 543 if opt.config_name or self._ShouldConfigureUser(opt):
524 self._ConfigureUser(opt) 544 self._ConfigureUser(opt)