From b5c5a5e0688743b21c032287ae2b4357ec66f11d Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Sat, 6 Feb 2021 09:44:15 -0800 Subject: [PATCH] manifest: set revisionId as revision attribute it it is not being set in ToXml. As we were testing superproject setting revisionId attribute to SHA and reloading the manifest, we found out revisionId attribute is not being saved. Made the change to save the revisionId if it is not being saved. Tested the code with the following commands. $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti Change-Id: I95fdf655b19648ad3e9aba10b9bed8bb9439deb6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296182 Reviewed-by: Ian Kasprzak --- manifest_xml.py | 2 ++ tests/test_manifest_xml.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/manifest_xml.py b/manifest_xml.py index eb8a98cc..e32551c8 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -403,6 +403,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr if not revision or revision != p.revisionExpr: e.setAttribute('revision', p.revisionExpr) + elif p.revisionId: + e.setAttribute('revision', p.revisionId) if (p.upstream and (p.upstream != p.revisionExpr or p.upstream != d.upstreamExpr)): e.setAttribute('upstream', p.upstream) diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 370eb4f5..5fd242fc 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -327,6 +327,26 @@ class XmlManifestTests(unittest.TestCase): result['extras'], ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) + def test_project_set_revision_id(self): + """Check setting of project's revisionId.""" + manifest = self.getXmlManifest(""" + + + + + +""") + self.assertEqual(len(manifest.projects), 1) + project = manifest.projects[0] + project.SetRevisionId('ABCDEF') + self.assertEqual( + manifest.ToXml().toxml(), + '' + + '' + + '' + + '' + + '') + def test_include_levels(self): root_m = os.path.join(self.manifest_dir, 'root.xml') with open(root_m, 'w') as fp: