summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2021-11-18 22:40:18 +0000
committerLaMont Jones <lamontjones@google.com>2022-02-17 21:57:55 +0000
commitcc879a97c3e2614d19b15b4661c3cab4d33139c9 (patch)
tree69d225e9f0e9d79fec8f423d9c40c275f0bf3b8c /main.py
parent87cce68b28c34fa86895baa8d7f48307382e6c75 (diff)
downloadgit-repo-cc879a97c3e2614d19b15b4661c3cab4d33139c9.tar.gz
Add multi-manifest support with <submanifest> elementv2.22
To be addressed in another change: - a partial `repo sync` (with a list of projects/paths to sync) requires `--this-tree-only`. Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/main.py b/main.py
index 2050cabb..6fb688c2 100755
--- a/main.py
+++ b/main.py
@@ -127,6 +127,8 @@ global_options.add_option('--event-log',
127 help='filename of event log to append timeline to') 127 help='filename of event log to append timeline to')
128global_options.add_option('--git-trace2-event-log', action='store', 128global_options.add_option('--git-trace2-event-log', action='store',
129 help='directory to write git trace2 event log to') 129 help='directory to write git trace2 event log to')
130global_options.add_option('--submanifest-path', action='store',
131 metavar='REL_PATH', help='submanifest path')
130 132
131 133
132class _Repo(object): 134class _Repo(object):
@@ -217,7 +219,12 @@ class _Repo(object):
217 SetDefaultColoring(gopts.color) 219 SetDefaultColoring(gopts.color)
218 220
219 git_trace2_event_log = EventLog() 221 git_trace2_event_log = EventLog()
220 repo_client = RepoClient(self.repodir) 222 outer_client = RepoClient(self.repodir)
223 repo_client = outer_client
224 if gopts.submanifest_path:
225 repo_client = RepoClient(self.repodir,
226 submanifest_path=gopts.submanifest_path,
227 outer_client=outer_client)
221 gitc_manifest = None 228 gitc_manifest = None
222 gitc_client_name = gitc_utils.parse_clientdir(os.getcwd()) 229 gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
223 if gitc_client_name: 230 if gitc_client_name:
@@ -229,6 +236,8 @@ class _Repo(object):
229 repodir=self.repodir, 236 repodir=self.repodir,
230 client=repo_client, 237 client=repo_client,
231 manifest=repo_client.manifest, 238 manifest=repo_client.manifest,
239 outer_client=outer_client,
240 outer_manifest=outer_client.manifest,
232 gitc_manifest=gitc_manifest, 241 gitc_manifest=gitc_manifest,
233 git_event_log=git_trace2_event_log) 242 git_event_log=git_trace2_event_log)
234 except KeyError: 243 except KeyError:
@@ -283,7 +292,37 @@ class _Repo(object):
283 try: 292 try:
284 cmd.CommonValidateOptions(copts, cargs) 293 cmd.CommonValidateOptions(copts, cargs)
285 cmd.ValidateOptions(copts, cargs) 294 cmd.ValidateOptions(copts, cargs)
286 result = cmd.Execute(copts, cargs) 295
296 this_manifest_only = copts.this_manifest_only
297 # If not specified, default to using the outer manifest.
298 outer_manifest = copts.outer_manifest is not False
299 if cmd.MULTI_MANIFEST_SUPPORT or this_manifest_only:
300 result = cmd.Execute(copts, cargs)
301 elif outer_manifest and repo_client.manifest.is_submanifest:
302 # The command does not support multi-manifest, we are using a
303 # submanifest, and the command line is for the outermost manifest.
304 # Re-run using the outermost manifest, which will recurse through the
305 # submanifests.
306 gopts.submanifest_path = ''
307 result = self._Run(name, gopts, argv)
308 else:
309 # No multi-manifest support. Run the command in the current
310 # (sub)manifest, and then any child submanifests.
311 result = cmd.Execute(copts, cargs)
312 for submanifest in repo_client.manifest.submanifests.values():
313 spec = submanifest.ToSubmanifestSpec(root=repo_client.outer_client)
314 gopts.submanifest_path = submanifest.repo_client.path_prefix
315 child_argv = argv[:]
316 child_argv.append('--no-outer-manifest')
317 # Not all subcommands support the 3 manifest options, so only add them
318 # if the original command includes them.
319 if hasattr(copts, 'manifest_url'):
320 child_argv.extend(['--manifest-url', spec.manifestUrl])
321 if hasattr(copts, 'manifest_name'):
322 child_argv.extend(['--manifest-name', spec.manifestName])
323 if hasattr(copts, 'manifest_branch'):
324 child_argv.extend(['--manifest-branch', spec.revision])
325 result = self._Run(name, gopts, child_argv) or result
287 except (DownloadError, ManifestInvalidRevisionError, 326 except (DownloadError, ManifestInvalidRevisionError,
288 NoManifestException) as e: 327 NoManifestException) as e:
289 print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)), 328 print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),