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
This commit is contained in:
Brian Harring 2012-06-07 20:05:35 -07:00
parent 62d0b10a7b
commit 475a47d531

View File

@ -283,11 +283,12 @@ class XmlManifest(object):
self.branch = b self.branch = b
nodes = [] nodes = []
nodes.append(self._ParseManifestXml(self.manifestFile)) nodes.append(self._ParseManifestXml(self.manifestFile,
self.manifestProject.worktree))
local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME)
if os.path.exists(local): if os.path.exists(local):
nodes.append(self._ParseManifestXml(local)) nodes.append(self._ParseManifestXml(local, self.repodir))
self._ParseManifest(nodes) self._ParseManifest(nodes)
@ -297,7 +298,7 @@ class XmlManifest(object):
self._loaded = True self._loaded = True
def _ParseManifestXml(self, path): def _ParseManifestXml(self, path, include_root):
root = xml.dom.minidom.parse(path) root = xml.dom.minidom.parse(path)
if not root or not root.childNodes: if not root or not root.childNodes:
raise ManifestParseError("no root node in %s" % (path,)) raise ManifestParseError("no root node in %s" % (path,))
@ -310,13 +311,13 @@ class XmlManifest(object):
for node in config.childNodes: for node in config.childNodes:
if node.nodeName == 'include': if node.nodeName == 'include':
name = self._reqatt(node, 'name') name = self._reqatt(node, 'name')
fp = os.path.join(os.path.dirname(path), name) fp = os.path.join(include_root, name)
if not os.path.isfile(fp): if not os.path.isfile(fp):
raise ManifestParseError, \ raise ManifestParseError, \
"include %s doesn't exist or isn't a file" % \ "include %s doesn't exist or isn't a file" % \
(name,) (name,)
try: try:
nodes.extend(self._ParseManifestXml(fp)) nodes.extend(self._ParseManifestXml(fp, include_root))
# should isolate this to the exact exception, but that's # should isolate this to the exact exception, but that's
# tricky. actual parsing implementation may vary. # tricky. actual parsing implementation may vary.
except (KeyboardInterrupt, RuntimeError, SystemExit): except (KeyboardInterrupt, RuntimeError, SystemExit):