summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Harring <ferringb@google.com>2012-06-07 20:05:35 -0700
committerBrian Harring <ferringb@google.com>2012-06-07 20:19:04 -0700
commit475a47d531bfe5ad82ec104189075df72a3143b7 (patch)
treedb44a1646f6f02c2105bf7946359076cf1d0a864
parent62d0b10a7bea2aa5cb7593ff12d14c482a1a663c (diff)
downloadgit-repo-475a47d531bfe5ad82ec104189075df72a3143b7.tar.gz
Restore include support.
Calculation of where the include file lives was broken by 23acdd3f14 since it resulted in looking for the first include in .repo, rather than .repo/manifests. While people can work around it via setting their includes to manifests/<include-target>, that breaks down since each layer of includes would then have to be relative. As such, restore the behaviour back to 2644874d; manifests includes are calculated relative to the manifest root (ie, .repo/manifests); local manifests includes are calculated relative to .repo/ . Change-Id: I74c19ba614c41d2f08cd3e9fd094f3c510e3bfd1
-rw-r--r--manifest_xml.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index daf5740b..a46cf24e 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -283,11 +283,12 @@ class XmlManifest(object):
283 self.branch = b 283 self.branch = b
284 284
285 nodes = [] 285 nodes = []
286 nodes.append(self._ParseManifestXml(self.manifestFile)) 286 nodes.append(self._ParseManifestXml(self.manifestFile,
287 self.manifestProject.worktree))
287 288
288 local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) 289 local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME)
289 if os.path.exists(local): 290 if os.path.exists(local):
290 nodes.append(self._ParseManifestXml(local)) 291 nodes.append(self._ParseManifestXml(local, self.repodir))
291 292
292 self._ParseManifest(nodes) 293 self._ParseManifest(nodes)
293 294
@@ -297,7 +298,7 @@ class XmlManifest(object):
297 298
298 self._loaded = True 299 self._loaded = True
299 300
300 def _ParseManifestXml(self, path): 301 def _ParseManifestXml(self, path, include_root):
301 root = xml.dom.minidom.parse(path) 302 root = xml.dom.minidom.parse(path)
302 if not root or not root.childNodes: 303 if not root or not root.childNodes:
303 raise ManifestParseError("no root node in %s" % (path,)) 304 raise ManifestParseError("no root node in %s" % (path,))
@@ -310,13 +311,13 @@ class XmlManifest(object):
310 for node in config.childNodes: 311 for node in config.childNodes:
311 if node.nodeName == 'include': 312 if node.nodeName == 'include':
312 name = self._reqatt(node, 'name') 313 name = self._reqatt(node, 'name')
313 fp = os.path.join(os.path.dirname(path), name) 314 fp = os.path.join(include_root, name)
314 if not os.path.isfile(fp): 315 if not os.path.isfile(fp):
315 raise ManifestParseError, \ 316 raise ManifestParseError, \
316 "include %s doesn't exist or isn't a file" % \ 317 "include %s doesn't exist or isn't a file" % \
317 (name,) 318 (name,)
318 try: 319 try:
319 nodes.extend(self._ParseManifestXml(fp)) 320 nodes.extend(self._ParseManifestXml(fp, include_root))
320 # should isolate this to the exact exception, but that's 321 # should isolate this to the exact exception, but that's
321 # tricky. actual parsing implementation may vary. 322 # tricky. actual parsing implementation may vary.
322 except (KeyboardInterrupt, RuntimeError, SystemExit): 323 except (KeyboardInterrupt, RuntimeError, SystemExit):