From 4cdfdb77343b2d4664c0a13c9e485a02988e578f Mon Sep 17 00:00:00 2001 From: Erik Elmeke Date: Fri, 9 Sep 2022 17:13:17 +0200 Subject: [PATCH] manifest: allow extend-project to override dest-branch and upstream Bug: https://crbug.com/gerrit/16238 Change-Id: Id6eff34791525b3df690e160c911c0286331984b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/345144 Tested-by: Erik Elmeke Reviewed-by: Mike Frysinger --- docs/manifest-format.md | 8 ++++++++ manifest_xml.py | 6 ++++++ tests/test_manifest_xml.py | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/docs/manifest-format.md b/docs/manifest-format.md index 0d26296d..bcdf5a8e 100644 --- a/docs/manifest-format.md +++ b/docs/manifest-format.md @@ -105,6 +105,8 @@ following DTD: + + @@ -423,6 +425,12 @@ project. Same syntax as the corresponding element of `project`. Attribute `remote`: If specified, overrides the remote of the original project. Same syntax as the corresponding element of `project`. +Attribute `dest-branch`: If specified, overrides the dest-branch of the original +project. Same syntax as the corresponding element of `project`. + +Attribute `upstream`: If specified, overrides the upstream of the original +project. Same syntax as the corresponding element of `project`. + ### Element annotation Zero or more annotation elements may be specified as children of a diff --git a/manifest_xml.py b/manifest_xml.py index b7579d5d..129eb3f7 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -1289,6 +1289,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md remote = self._default.remote else: remote = self._get_remote(node) + dest_branch = node.getAttribute('dest-branch') + upstream = node.getAttribute('upstream') named_projects = self._projects[name] if dest_path and not path and len(named_projects) > 1: @@ -1304,6 +1306,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md if remote_name: p.remote = remote.ToRemoteSpec(name) + if dest_branch: + p.dest_branch = dest_branch + if upstream: + p.upstream = upstream if dest_path: del self._paths[p.relpath] diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 48403c0d..e181b642 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -874,3 +874,27 @@ class ExtendProjectElementTests(ManifestParseTestCase): else: self.assertEqual(manifest.projects[0].relpath, 'bar') self.assertEqual(manifest.projects[1].relpath, 'y') + + def test_extend_project_dest_branch(self): + manifest = self.getXmlManifest(""" + + + + + + +""") + self.assertEqual(len(manifest.projects), 1) + self.assertEqual(manifest.projects[0].dest_branch, 'bar') + + def test_extend_project_upstream(self): + manifest = self.getXmlManifest(""" + + + + + + +""") + self.assertEqual(len(manifest.projects), 1) + self.assertEqual(manifest.projects[0].upstream, 'bar')