Просмотр исходного кода

Add <add-remote to-project="..."> to inject additional remotes

This way users can add forks they know about to an existing project
that was already declared in the primary manifest.  This is mostly
useful with the Linux kernel project, where multiple forks is quite
common for the main upstream tree (e.g. Linus' tree), a platform
architecture tree (e.g. ARM) and a device specific tree (e.g. the
msm7k tree used by Android).

Signed-off-by: Shawn O. Pearce <sop@google.com>
Shawn O. Pearce 17 лет назад
Родитель
Сommit
70939e2f73
2 измененных файлов с 43 добавлено и 8 удалено
  1. 23 1
      docs/manifest-format.txt
  2. 20 7
      manifest.py

+ 23 - 1
docs/manifest-format.txt

@@ -20,7 +20,10 @@ A manifest XML file (e.g. 'default.xml') roughly conforms to the
 following DTD:
 following DTD:
 
 
 <!DOCTYPE manifest [
 <!DOCTYPE manifest [
-  <!ELEMENT manifest (remote*, default?, project*)>
+  <!ELEMENT manifest (remote*,
+                      default?,
+                      project*,
+                      add-remote*)>
 
 
   <!ELEMENT remote (EMPTY)>
   <!ELEMENT remote (EMPTY)>
   <!ATTLIST remote name         ID    #REQUIRED>
   <!ATTLIST remote name         ID    #REQUIRED>
@@ -37,6 +40,13 @@ following DTD:
   <!ATTLIST project path     CDATA #IMPLIED>
   <!ATTLIST project path     CDATA #IMPLIED>
   <!ATTLIST project remote   IDREF #IMPLIED>
   <!ATTLIST project remote   IDREF #IMPLIED>
   <!ATTLIST project revision CDATA #IMPLIED>
   <!ATTLIST project revision CDATA #IMPLIED>
+
+  <!ELEMENT add-remote (EMPTY)>
+  <!ATTLIST add-remote to-project   ID    #REQUIRED>
+  <!ATTLIST add-remote name         ID    #REQUIRED>
+  <!ATTLIST add-remote fetch        CDATA #REQUIRED>
+  <!ATTLIST add-remote review       CDATA #IMPLIED>
+  <!ATTLIST add-remote project-name CDATA #IMPLIED>
 ]>
 ]>
 
 
 A description of the elements and their attributes follows.
 A description of the elements and their attributes follows.
@@ -74,6 +84,18 @@ Only permitted when the remote element is nested inside of a project
 element (see below).  If not given, defaults to the name supplied
 element (see below).  If not given, defaults to the name supplied
 in the project's name attribute.
 in the project's name attribute.
 
 
+Element add-remote
+------------------
+
+Adds a remote to an existing project, whose name is given by the
+to-project attribute.  This is functionally equivalent to nesting
+a remote element under the project, but has the advantage that it
+can be specified in the uesr's `local_manifest.xml` to add a remote
+to a project declared by the normal manifest.
+
+The element can be used to add a fork of an existing project that
+the user needs to work with.
+
 
 
 Element default
 Element default
 ---------------
 ---------------

+ 20 - 7
manifest.py

@@ -165,6 +165,16 @@ class Manifest(object):
                 (project.name, self.manifestFile)
                 (project.name, self.manifestFile)
         self._projects[project.name] = project
         self._projects[project.name] = project
 
 
+    for node in config.childNodes:
+      if node.nodeName == 'add-remote':
+        pn = self._reqatt(node, 'to-project')
+        project = self._projects.get(pn)
+        if not project:
+          raise ManifestParseError, \
+                'project %s not defined in %s' % \
+                (pn, self.manifestFile)
+        self._ParseProjectExtraRemote(project, node)
+
   def _AddMetaProjectMirror(self, m):
   def _AddMetaProjectMirror(self, m):
     name = None
     name = None
     m_url = m.GetRemote(m.remote.name).url
     m_url = m.GetRemote(m.remote.name).url
@@ -281,18 +291,21 @@ class Manifest(object):
 
 
     for n in node.childNodes:
     for n in node.childNodes:
       if n.nodeName == 'remote':
       if n.nodeName == 'remote':
-        r = self._ParseRemote(n)
-        if project.extraRemotes.get(r.name) \
-           or project.remote.name == r.name:
-          raise ManifestParseError, \
-                'duplicate remote %s in project %s in %s' % \
-                (r.name, project.name, self.manifestFile)
-        project.extraRemotes[r.name] = r
+        self._ParseProjectExtraRemote(project, n)
       elif n.nodeName == 'copyfile':
       elif n.nodeName == 'copyfile':
         self._ParseCopyFile(project, n)
         self._ParseCopyFile(project, n)
 
 
     return project
     return project
 
 
+  def _ParseProjectExtraRemote(self, project, n):
+    r = self._ParseRemote(n)
+    if project.extraRemotes.get(r.name) \
+       or project.remote.name == r.name:
+      raise ManifestParseError, \
+            'duplicate remote %s in project %s in %s' % \
+            (r.name, project.name, self.manifestFile)
+    project.extraRemotes[r.name] = r
+
   def _ParseCopyFile(self, project, node):
   def _ParseCopyFile(self, project, node):
     src = self._reqatt(node, 'src')
     src = self._reqatt(node, 'src')
     dest = self._reqatt(node, 'dest')
     dest = self._reqatt(node, 'dest')