From 303bd963d57936873f62c7b61a885911afc46788 Mon Sep 17 00:00:00 2001 From: Fredrik de Groot Date: Mon, 9 Sep 2024 15:54:57 +0200 Subject: manifest: add optional base check on remove and extend This adds an optional, built-in checker for guarding against patches hanging on wrong base revisions, which is useful if a lower layer of the manifest changes after a patch was done. When adding a patch with a new revision using extend-project or remove-project/project: C---D---E patches in project bla / A---B project bla in manifest state 1 If project bla gets updated, in a new snap ID or by a supplier or similar, to a new state: C---D---E patches in project bla / A---B---F---G project bla in manifest state 2 Parsing will fail because revision of bla is now G, giving the choice to create a new patch branch from G and updating base-rev, or keeping previous branch for some reason and only updating base-rev. Intended for use in a layered manifest with hashed revisions. Named refs like branches and tags also work fine when comparing, but will be misleading if a branch is used as base-rev. Change-Id: Ic6211550a7d3cc9656057f6a2087c505b40cad2b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/436777 Reviewed-by: Josip Sokcevic Tested-by: Fredrik de Groot Commit-Queue: Josip Sokcevic --- tests/test_manifest_xml.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 3f03272a..3d1fde96 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -1049,6 +1049,91 @@ class RemoveProjectElementTests(ManifestParseTestCase): self.assertTrue(found_proj1_path1) self.assertTrue(found_proj2) + def test_base_revision_checks_on_patching(self): + manifest_fail_wrong_tag = self.getXmlManifest( + """ + + + + + + +""" + ) + with self.assertRaises(error.ManifestParseError): + manifest_fail_wrong_tag.ToXml() + + manifest_fail_remove = self.getXmlManifest( + """ + + + + + + +""" + ) + with self.assertRaises(error.ManifestParseError): + manifest_fail_remove.ToXml() + + manifest_fail_extend = self.getXmlManifest( + """ + + + + + + +""" + ) + with self.assertRaises(error.ManifestParseError): + manifest_fail_extend.ToXml() + + manifest_fail_unknown = self.getXmlManifest( + """ + + + + + + +""" + ) + with self.assertRaises(error.ManifestParseError): + manifest_fail_unknown.ToXml() + + manifest_ok = self.getXmlManifest( + """ + + + + + + + + + + + + + + + +""" + ) + found_proj2 = False + found_proj3 = False + for proj in manifest_ok.projects: + if proj.name == "project2": + found_proj2 = True + if proj.name == "project3": + found_proj3 = True + self.assertNotEqual(proj.name, "project1") + self.assertNotEqual(proj.name, "project4") + self.assertTrue(found_proj2) + self.assertTrue(found_proj3) + self.assertTrue(len(manifest_ok.projects) == 2) + class ExtendProjectElementTests(ManifestParseTestCase): """Tests for .""" -- cgit v1.2.3-54-g00ecf