manifest_xml: - Added doc and testing of unknown tags/elements.
Added this test to verify that older versions of repo can handle
"<superproject" element. Tested by adding "<iankaz" unknown element.
Tested the code with the following commands.
$ ./run_tests tests/test_manifest_xml.py
$ ./run_tests -v
Bug: https://crbug.com/gerrit/13709
Tested-by: Raman Tenneti <rtenneti@google.com>
Change-Id: I858d56f38cefcfcd14474efdd631a5a940c3ce47
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293482
Reviewed-by: Mike Frysinger <vapier@google.com>
diff --git a/docs/manifest-format.md b/docs/manifest-format.md
index 8e5e287..6156333 100644
--- a/docs/manifest-format.md
+++ b/docs/manifest-format.md
@@ -109,6 +109,12 @@
]>
```
+For compatibility purposes across repo releases, all unknown elements are
+silently ignored. However, repo reserves all possible names for itself for
+future use. If you want to use custom elements, the `x-*` namespace is
+reserved for that purpose, and repo guarantees to never allocate any
+corresponding names.
+
A description of the elements and their attributes follows.
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index e4adf3c..e2c83af 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -280,6 +280,27 @@
'<superproject name="superproject"/>' +
'</manifest>')
+ def test_unknown_tags(self):
+ """Check superproject settings."""
+ manifest = self.getXmlManifest("""
+<manifest>
+ <remote name="test-remote" fetch="http://localhost" />
+ <default remote="test-remote" revision="refs/heads/main" />
+ <superproject name="superproject"/>
+ <iankaz value="unknown (possible) future tags are ignored"/>
+ <x-custom-tag>X tags are always ignored</x-custom-tag>
+</manifest>
+""")
+ self.assertEqual(manifest.superproject['name'], 'superproject')
+ self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
+ self.assertEqual(
+ manifest.ToXml().toxml(),
+ '<?xml version="1.0" ?><manifest>' +
+ '<remote name="test-remote" fetch="http://localhost"/>' +
+ '<default remote="test-remote" revision="refs/heads/main"/>' +
+ '<superproject name="superproject"/>' +
+ '</manifest>')
+
def test_project_group(self):
"""Check project group settings."""
manifest = self.getXmlManifest("""