diff options
| -rw-r--r-- | docs/manifest-format.txt | 7 | ||||
| -rw-r--r-- | manifest_xml.py | 12 |
2 files changed, 17 insertions, 2 deletions
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: | |||
| 32 | 32 | ||
| 33 | <!ELEMENT remote (EMPTY)> | 33 | <!ELEMENT remote (EMPTY)> |
| 34 | <!ATTLIST remote name ID #REQUIRED> | 34 | <!ATTLIST remote name ID #REQUIRED> |
| 35 | <!ATTLIST remote alias CDATA #IMPLIED> | ||
| 35 | <!ATTLIST remote fetch CDATA #REQUIRED> | 36 | <!ATTLIST remote fetch CDATA #REQUIRED> |
| 36 | <!ATTLIST remote review CDATA #IMPLIED> | 37 | <!ATTLIST remote review CDATA #IMPLIED> |
| 37 | 38 | ||
| @@ -89,6 +90,12 @@ name specified here is used as the remote name in each project's | |||
| 89 | .git/config, and is therefore automatically available to commands | 90 | .git/config, and is therefore automatically available to commands |
| 90 | like `git fetch`, `git remote`, `git pull` and `git push`. | 91 | like `git fetch`, `git remote`, `git pull` and `git push`. |
| 91 | 92 | ||
| 93 | Attribute `alias`: The alias, if specified, is used to override | ||
| 94 | `name` to be set as the remote name in each project's .git/config. | ||
| 95 | Its value can be duplicated while attribute `name` has to be unique | ||
| 96 | in the manifest file. This helps each project to be able to have | ||
| 97 | same remote name which actually points to different remote url. | ||
| 98 | |||
| 92 | Attribute `fetch`: The Git URL prefix for all projects which use | 99 | Attribute `fetch`: The Git URL prefix for all projects which use |
| 93 | this remote. Each project's name is appended to this prefix to | 100 | this remote. Each project's name is appended to this prefix to |
| 94 | form the actual URL used to clone the project. | 101 | 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): | |||
| 41 | class _XmlRemote(object): | 41 | class _XmlRemote(object): |
| 42 | def __init__(self, | 42 | def __init__(self, |
| 43 | name, | 43 | name, |
| 44 | alias=None, | ||
| 44 | fetch=None, | 45 | fetch=None, |
| 45 | manifestUrl=None, | 46 | manifestUrl=None, |
| 46 | review=None): | 47 | review=None): |
| 47 | self.name = name | 48 | self.name = name |
| 48 | self.fetchUrl = fetch | 49 | self.fetchUrl = fetch |
| 49 | self.manifestUrl = manifestUrl | 50 | self.manifestUrl = manifestUrl |
| 51 | self.remoteAlias = alias | ||
| 50 | self.reviewUrl = review | 52 | self.reviewUrl = review |
| 51 | self.resolvedFetchUrl = self._resolveFetchUrl() | 53 | self.resolvedFetchUrl = self._resolveFetchUrl() |
| 52 | 54 | ||
| @@ -62,7 +64,10 @@ class _XmlRemote(object): | |||
| 62 | 64 | ||
| 63 | def ToRemoteSpec(self, projectName): | 65 | def ToRemoteSpec(self, projectName): |
| 64 | url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName | 66 | url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName |
| 65 | return RemoteSpec(self.name, url, self.reviewUrl) | 67 | remoteName = self.name |
| 68 | if self.remoteAlias: | ||
| 69 | remoteName = self.remoteAlias | ||
| 70 | return RemoteSpec(remoteName, url, self.reviewUrl) | ||
| 66 | 71 | ||
| 67 | class XmlManifest(object): | 72 | class XmlManifest(object): |
| 68 | """manages the repo configuration file""" | 73 | """manages the repo configuration file""" |
| @@ -451,12 +456,15 @@ class XmlManifest(object): | |||
| 451 | reads a <remote> element from the manifest file | 456 | reads a <remote> element from the manifest file |
| 452 | """ | 457 | """ |
| 453 | name = self._reqatt(node, 'name') | 458 | name = self._reqatt(node, 'name') |
| 459 | alias = node.getAttribute('alias') | ||
| 460 | if alias == '': | ||
| 461 | alias = None | ||
| 454 | fetch = self._reqatt(node, 'fetch') | 462 | fetch = self._reqatt(node, 'fetch') |
| 455 | review = node.getAttribute('review') | 463 | review = node.getAttribute('review') |
| 456 | if review == '': | 464 | if review == '': |
| 457 | review = None | 465 | review = None |
| 458 | manifestUrl = self.manifestProject.config.GetString('remote.origin.url') | 466 | manifestUrl = self.manifestProject.config.GetString('remote.origin.url') |
| 459 | return _XmlRemote(name, fetch, manifestUrl, review) | 467 | return _XmlRemote(name, alias, fetch, manifestUrl, review) |
| 460 | 468 | ||
| 461 | def _ParseDefault(self, node): | 469 | def _ParseDefault(self, node): |
| 462 | """ | 470 | """ |
