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>
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt
index 2b49d46..5c014d6 100644
--- a/docs/manifest-format.txt
+++ b/docs/manifest-format.txt
@@ -20,7 +20,10 @@
following DTD:
<!DOCTYPE manifest [
- <!ELEMENT manifest (remote*, default?, project*)>
+ <!ELEMENT manifest (remote*,
+ default?,
+ project*,
+ add-remote*)>
<!ELEMENT remote (EMPTY)>
<!ATTLIST remote name ID #REQUIRED>
@@ -37,6 +40,13 @@
<!ATTLIST project path CDATA #IMPLIED>
<!ATTLIST project remote IDREF #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.
@@ -74,6 +84,18 @@
element (see below). If not given, defaults to the name supplied
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
---------------
diff --git a/manifest.py b/manifest.py
index 6545568..2ac1453 100644
--- a/manifest.py
+++ b/manifest.py
@@ -165,6 +165,16 @@
(project.name, self.manifestFile)
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):
name = None
m_url = m.GetRemote(m.remote.name).url
@@ -281,18 +291,21 @@
for n in node.childNodes:
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':
self._ParseCopyFile(project, n)
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):
src = self._reqatt(node, 'src')
dest = self._reqatt(node, 'dest')