diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index a827f556..38868f10 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt @@ -32,6 +32,7 @@ following DTD: + @@ -89,6 +90,12 @@ name specified here is used as the remote name in each project's .git/config, and is therefore automatically available to commands like `git fetch`, `git remote`, `git pull` and `git push`. +Attribute `alias`: The alias, if specified, is used to override +`name` to be set as the remote name in each project's .git/config. +Its value can be duplicated while attribute `name` has to be unique +in the manifest file. This helps each project to be able to have +same remote name which actually points to different remote url. + Attribute `fetch`: The Git URL prefix for all projects which use this remote. Each project's name is appended to this prefix to form the actual URL used to clone the project. diff --git a/manifest_xml.py b/manifest_xml.py index 86899f63..d3156e5c 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -41,12 +41,14 @@ class _Default(object): class _XmlRemote(object): def __init__(self, name, + alias=None, fetch=None, manifestUrl=None, review=None): self.name = name self.fetchUrl = fetch self.manifestUrl = manifestUrl + self.remoteAlias = alias self.reviewUrl = review self.resolvedFetchUrl = self._resolveFetchUrl() @@ -62,7 +64,10 @@ class _XmlRemote(object): def ToRemoteSpec(self, projectName): url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName - return RemoteSpec(self.name, url, self.reviewUrl) + remoteName = self.name + if self.remoteAlias: + remoteName = self.remoteAlias + return RemoteSpec(remoteName, url, self.reviewUrl) class XmlManifest(object): """manages the repo configuration file""" @@ -451,12 +456,15 @@ class XmlManifest(object): reads a element from the manifest file """ name = self._reqatt(node, 'name') + alias = node.getAttribute('alias') + if alias == '': + alias = None fetch = self._reqatt(node, 'fetch') review = node.getAttribute('review') if review == '': review = None manifestUrl = self.manifestProject.config.GetString('remote.origin.url') - return _XmlRemote(name, fetch, manifestUrl, review) + return _XmlRemote(name, alias, fetch, manifestUrl, review) def _ParseDefault(self, node): """