summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Harring <brian.harring@intel.com>2011-04-28 05:04:41 -0700
committerShawn O. Pearce <sop@google.com>2012-05-24 09:07:24 -0700
commit2644874d9d3e6c16299a01acddf66cd99fd43414 (patch)
treebd2e86186a48a22286c6e919758d7edf366bda9a
parent3d125940f6223efe62e35b795f57e7e717b4528e (diff)
downloadgit-repo-2644874d9d3e6c16299a01acddf66cd99fd43414.tar.gz
ManifestXml: add include support
Having the ability to include other manifests is a very practical feature to ease the managment of manifest. It allows to divide a manifest into separate files, and create different environment depending on what we want to release You can have unlimited recursion of include, the manifest configs will simply be concatenated as if it was in a single file. command "repo manifest" will create a single manifest, and not recreate the manifest hierarchy for example: Our developement manifest will look like: <?xml version='1.0' encoding='UTF-8'?> <manifest> <default revision="platform/android/main" remote="intel"/> <include name="server.xml"/> <!-- The Server configuration --> <include name="aosp.xml" /> <!-- All the AOSP projects --> <include name="bsp.xml" /> <!-- The BSP projects that we release in source form --> <include name="bsp-priv.xml" /> <!-- The source of the BSP projects we release in binary form --> </manifest> Our release manifest will look like: <?xml version='1.0' encoding='UTF-8'?> <manifest> <default revision="platform/android/release-ext" remote="intel"/> <include name="server.xml"/> <!-- The Server configuration --> <include name="aosp.xml" /> <!-- All the AOSP projects --> <include name="bsp.xml" /> <!-- The BSP projects that we release in source form --> <include name="bsp-ext.xml" /> <!-- The PREBUILT version of the BSP projects we release in binary form --> </manifest> And it is also easy to create and maintain feature branch with a manifest that looks like: <?xml version='1.0' encoding='UTF-8'?> <manifest> <default revision="feature_branch_foobar" remote="intel"/> <include name="server.xml"/> <!-- The Server configuration --> <include name="aosp.xml" /> <!-- All the AOSP projects --> <include name="bsp.xml" /> <!-- The BSP projects that we release in source form --> <include name="bsp-priv.xml" /> <!-- The source of the BSP projects we release in binary form --> </manifest> Signed-off-by: Brian Harring <brian.harring@intel.com> Signed-off-by: Pierre Tardy <pierre.tardy@intel.com> Change-Id: I833a30d303039e485888768e6b81561b7665e89d
-rw-r--r--docs/manifest-format.txt13
-rw-r--r--manifest_xml.py39
2 files changed, 44 insertions, 8 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt
index 53789651..9f4585b8 100644
--- a/docs/manifest-format.txt
+++ b/docs/manifest-format.txt
@@ -63,6 +63,9 @@ following DTD:
63 <!ELEMENT repo-hooks (EMPTY)> 63 <!ELEMENT repo-hooks (EMPTY)>
64 <!ATTLIST repo-hooks in-project CDATA #REQUIRED> 64 <!ATTLIST repo-hooks in-project CDATA #REQUIRED>
65 <!ATTLIST repo-hooks enabled-list CDATA #REQUIRED> 65 <!ATTLIST repo-hooks enabled-list CDATA #REQUIRED>
66
67 <!ELEMENT include (EMPTY)>
68 <!ATTLIST include name CDATA #REQUIRED>
66 ]> 69 ]>
67 70
68A description of the elements and their attributes follows. 71A description of the elements and their attributes follows.
@@ -192,6 +195,16 @@ This element is mostly useful in the local_manifest.xml, where
192the user can remove a project, and possibly replace it with their 195the user can remove a project, and possibly replace it with their
193own definition. 196own definition.
194 197
198Element include
199---------------
200
201This element provides the capability of including another manifest
202file into the originating manifest. Normal rules apply for the
203target manifest to include- it must be a usable manifest on it's own.
204
205Attribute `name`; the manifest to include, specified relative to
206the manifest repositories root.
207
195 208
196Local Manifest 209Local Manifest
197============== 210==============
diff --git a/manifest_xml.py b/manifest_xml.py
index ca65e33f..2927fd1c 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -298,18 +298,41 @@ class XmlManifest(object):
298 298
299 self._loaded = True 299 self._loaded = True
300 300
301 def _ParseManifest(self, is_root_file): 301 def _ParseManifestObject(self, path):
302 root = xml.dom.minidom.parse(self.manifestFile) 302 root = xml.dom.minidom.parse(path)
303 if not root or not root.childNodes: 303 if not root or not root.childNodes:
304 raise ManifestParseError( 304 raise ManifestParseError("no root node in %s" % (path,))
305 "no root node in %s" %
306 self.manifestFile)
307 305
308 config = root.childNodes[0] 306 config = root.childNodes[0]
309 if config.nodeName != 'manifest': 307 if config.nodeName != 'manifest':
310 raise ManifestParseError( 308 raise ManifestParseError("no <manifest> in %s" % (path,))
311 "no <manifest> in %s" % 309
312 self.manifestFile) 310 return config
311
312 def _ParseManifest(self, is_root_file):
313 config = self._ParseManifestObject(self.manifestFile)
314
315 for node in config.childNodes:
316 if node.nodeName == 'include':
317 name = self._reqatt(node, 'name')
318 fp = os.path.join(self.manifestProject.worktree, name)
319 if not os.path.isfile(fp):
320 raise ManifestParseError, \
321 "include %s doesn't exist or isn't a file" % \
322 (name,)
323 try:
324 subconfig = self._ParseManifestObject(fp)
325 # should isolate this to the exact exception, but that's
326 # tricky. actual parsing implementation may vary.
327 except (KeyboardInterrupt, RuntimeError, SystemExit):
328 raise
329 except Exception, e:
330 raise ManifestParseError(
331 "failed parsing included manifest %s: %s", (name, e))
332
333 for sub_node in subconfig.childNodes:
334 config.appendChild(sub_node.cloneNode(True))
335
313 336
314 for node in config.childNodes: 337 for node in config.childNodes:
315 if node.nodeName == 'remove-project': 338 if node.nodeName == 'remove-project':