diff options
author | Raman Tenneti <rtenneti@google.com> | 2021-03-04 10:29:40 -0800 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2021-03-04 20:07:52 +0000 |
commit | ef99ec07b4687cef0129057b81c0c1ebd21bb640 (patch) | |
tree | 86a2e87156f795e631097cc922c9757dbaf1cf7f | |
parent | 934cb0a849d0bf22e2ae64cd6c3e93334d05e3ab (diff) | |
download | git-repo-ef99ec07b4687cef0129057b81c0c1ebd21bb640.tar.gz |
superproject: Display status messages during repo init/sync.v2.13.3
Superproject objects accept the optional argument “quiet”.
The following progress messages are displayed if quiet is false.
Displayed the following message whenever we find we have to make a new
folder (aka new remote), because if you started with repo init android
and later do googleplex-android that is when it will be slow.
"<location>: Performing initial setup for superproject; this might take
several minutes.".
After fetch completion, added the following notification:
"<location>: Initial setup for superproject completed."
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_dev init -u persistent-https://googleplex-android.git.corp.google.com/platform/manifest -b rvc-dev --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject
Bug: [google internal] b/181178282
Bug: https://crbug.com/gerrit/13707
Change-Id: Ia7fb85c6fb934faaa90c48fc0c55e7f41055f48a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299122
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Raman Tenneti <rtenneti@google.com>
-rw-r--r-- | git_superproject.py | 10 | ||||
-rw-r--r-- | subcmds/init.py | 13 | ||||
-rw-r--r-- | subcmds/sync.py | 3 |
3 files changed, 20 insertions, 6 deletions
diff --git a/git_superproject.py b/git_superproject.py index a09edc15..651da48a 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -41,7 +41,8 @@ class Superproject(object): | |||
41 | lookup of commit ids for all projects. It contains _project_commit_ids which | 41 | lookup of commit ids for all projects. It contains _project_commit_ids which |
42 | is a dictionary with project/commit id entries. | 42 | is a dictionary with project/commit id entries. |
43 | """ | 43 | """ |
44 | def __init__(self, manifest, repodir, superproject_dir='exp-superproject'): | 44 | def __init__(self, manifest, repodir, superproject_dir='exp-superproject', |
45 | quiet=False): | ||
45 | """Initializes superproject. | 46 | """Initializes superproject. |
46 | 47 | ||
47 | Args: | 48 | Args: |
@@ -49,9 +50,11 @@ class Superproject(object): | |||
49 | repodir: Path to the .repo/ dir for holding all internal checkout state. | 50 | repodir: Path to the .repo/ dir for holding all internal checkout state. |
50 | It must be in the top directory of the repo client checkout. | 51 | It must be in the top directory of the repo client checkout. |
51 | superproject_dir: Relative path under |repodir| to checkout superproject. | 52 | superproject_dir: Relative path under |repodir| to checkout superproject. |
53 | quiet: If True then only print the progress messages. | ||
52 | """ | 54 | """ |
53 | self._project_commit_ids = None | 55 | self._project_commit_ids = None |
54 | self._manifest = manifest | 56 | self._manifest = manifest |
57 | self._quiet = quiet | ||
55 | self._branch = self._GetBranch() | 58 | self._branch = self._GetBranch() |
56 | self._repodir = os.path.abspath(repodir) | 59 | self._repodir = os.path.abspath(repodir) |
57 | self._superproject_dir = superproject_dir | 60 | self._superproject_dir = superproject_dir |
@@ -89,6 +92,9 @@ class Superproject(object): | |||
89 | """ | 92 | """ |
90 | if not os.path.exists(self._superproject_path): | 93 | if not os.path.exists(self._superproject_path): |
91 | os.mkdir(self._superproject_path) | 94 | os.mkdir(self._superproject_path) |
95 | if not self._quiet and not os.path.exists(self._work_git): | ||
96 | print('%s: Performing initial setup for superproject; this might take ' | ||
97 | 'several minutes.' % self._work_git) | ||
92 | cmd = ['init', '--bare', self._work_git_name] | 98 | cmd = ['init', '--bare', self._work_git_name] |
93 | p = GitCommand(None, | 99 | p = GitCommand(None, |
94 | cmd, | 100 | cmd, |
@@ -183,6 +189,8 @@ class Superproject(object): | |||
183 | return False | 189 | return False |
184 | if not self._Fetch(url): | 190 | if not self._Fetch(url): |
185 | return False | 191 | return False |
192 | if not self._quiet: | ||
193 | print('%s: Initial setup for superproject completed.' % self._work_git) | ||
186 | return True | 194 | return True |
187 | 195 | ||
188 | def _GetAllProjectsCommitIds(self): | 196 | def _GetAllProjectsCommitIds(self): |
diff --git a/subcmds/init.py b/subcmds/init.py index fc446045..c2376b65 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -185,10 +185,15 @@ to update the working directory files. | |||
185 | return {'REPO_MANIFEST_URL': 'manifest_url', | 185 | return {'REPO_MANIFEST_URL': 'manifest_url', |
186 | 'REPO_MIRROR_LOCATION': 'reference'} | 186 | 'REPO_MIRROR_LOCATION': 'reference'} |
187 | 187 | ||
188 | def _CloneSuperproject(self): | 188 | def _CloneSuperproject(self, opt): |
189 | """Clone the superproject based on the superproject's url and branch.""" | 189 | """Clone the superproject based on the superproject's url and branch. |
190 | |||
191 | Args: | ||
192 | opt: Program options returned from optparse. See _Options(). | ||
193 | """ | ||
190 | superproject = git_superproject.Superproject(self.manifest, | 194 | superproject = git_superproject.Superproject(self.manifest, |
191 | self.repodir) | 195 | self.repodir, |
196 | quiet=opt.quiet) | ||
192 | if not superproject.Sync(): | 197 | if not superproject.Sync(): |
193 | print('error: git update of superproject failed', file=sys.stderr) | 198 | print('error: git update of superproject failed', file=sys.stderr) |
194 | sys.exit(1) | 199 | sys.exit(1) |
@@ -553,7 +558,7 @@ to update the working directory files. | |||
553 | self._LinkManifest(opt.manifest_name) | 558 | self._LinkManifest(opt.manifest_name) |
554 | 559 | ||
555 | if self.manifest.manifestProject.config.GetBoolean('repo.superproject'): | 560 | if self.manifest.manifestProject.config.GetBoolean('repo.superproject'): |
556 | self._CloneSuperproject() | 561 | self._CloneSuperproject(opt) |
557 | 562 | ||
558 | if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: | 563 | if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: |
559 | if opt.config_name or self._ShouldConfigureUser(opt): | 564 | if opt.config_name or self._ShouldConfigureUser(opt): |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 0db96b54..3ad0627d 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -292,7 +292,8 @@ later is required to fix a server side protocol bug. | |||
292 | Returns path to the overriding manifest file. | 292 | Returns path to the overriding manifest file. |
293 | """ | 293 | """ |
294 | superproject = git_superproject.Superproject(self.manifest, | 294 | superproject = git_superproject.Superproject(self.manifest, |
295 | self.repodir) | 295 | self.repodir, |
296 | quiet=opt.quiet) | ||
296 | all_projects = self.GetProjects(args, | 297 | all_projects = self.GetProjects(args, |
297 | missing_ok=True, | 298 | missing_ok=True, |
298 | submodules_ok=opt.fetch_submodules) | 299 | submodules_ok=opt.fetch_submodules) |