Procházet zdrojové kódy

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
Brian Harring před 13 roky
rodič
revize
475a47d531
1 změnil soubory, kde provedl 6 přidání a 5 odebrání
  1. 6 5
      manifest_xml.py

+ 6 - 5
manifest_xml.py

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