summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/manifest-format.txt8
-rw-r--r--manifest_xml.py22
-rw-r--r--project.py7
3 files changed, 28 insertions, 9 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt
index e48b75fe..f187bfaf 100644
--- a/docs/manifest-format.txt
+++ b/docs/manifest-format.txt
@@ -35,6 +35,7 @@ following DTD:
35 <!ATTLIST remote alias CDATA #IMPLIED> 35 <!ATTLIST remote alias CDATA #IMPLIED>
36 <!ATTLIST remote fetch CDATA #REQUIRED> 36 <!ATTLIST remote fetch CDATA #REQUIRED>
37 <!ATTLIST remote review CDATA #IMPLIED> 37 <!ATTLIST remote review CDATA #IMPLIED>
38 <!ATTLIST remote revision CDATA #IMPLIED>
38 39
39 <!ELEMENT default (EMPTY)> 40 <!ELEMENT default (EMPTY)>
40 <!ATTLIST default remote IDREF #IMPLIED> 41 <!ATTLIST default remote IDREF #IMPLIED>
@@ -112,6 +113,10 @@ Attribute `review`: Hostname of the Gerrit server where reviews
112are uploaded to by `repo upload`. This attribute is optional; 113are uploaded to by `repo upload`. This attribute is optional;
113if not specified then `repo upload` will not function. 114if not specified then `repo upload` will not function.
114 115
116Attribute `revision`: Name of a Git branch (e.g. `master` or
117`refs/heads/master`). Remotes with their own revision will override
118the default revision.
119
115Element default 120Element default
116--------------- 121---------------
117 122
@@ -208,7 +213,8 @@ to track for this project. Names can be relative to refs/heads
208(e.g. just "master") or absolute (e.g. "refs/heads/master"). 213(e.g. just "master") or absolute (e.g. "refs/heads/master").
209Tags and/or explicit SHA-1s should work in theory, but have not 214Tags and/or explicit SHA-1s should work in theory, but have not
210been extensively tested. If not supplied the revision given by 215been extensively tested. If not supplied the revision given by
211the default element is used. 216the remote element is used if applicable, else the default
217element is used.
212 218
213Attribute `dest-branch`: Name of a Git branch (e.g. `master`). 219Attribute `dest-branch`: Name of a Git branch (e.g. `master`).
214When using `repo upload`, changes will be submitted for code 220When using `repo upload`, changes will be submitted for code
diff --git a/manifest_xml.py b/manifest_xml.py
index e2f58e62..a32c693f 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -63,12 +63,14 @@ class _XmlRemote(object):
63 alias=None, 63 alias=None,
64 fetch=None, 64 fetch=None,
65 manifestUrl=None, 65 manifestUrl=None,
66 review=None): 66 review=None,
67 revision=None):
67 self.name = name 68 self.name = name
68 self.fetchUrl = fetch 69 self.fetchUrl = fetch
69 self.manifestUrl = manifestUrl 70 self.manifestUrl = manifestUrl
70 self.remoteAlias = alias 71 self.remoteAlias = alias
71 self.reviewUrl = review 72 self.reviewUrl = review
73 self.revision = revision
72 self.resolvedFetchUrl = self._resolveFetchUrl() 74 self.resolvedFetchUrl = self._resolveFetchUrl()
73 75
74 def __eq__(self, other): 76 def __eq__(self, other):
@@ -159,6 +161,8 @@ class XmlManifest(object):
159 e.setAttribute('alias', r.remoteAlias) 161 e.setAttribute('alias', r.remoteAlias)
160 if r.reviewUrl is not None: 162 if r.reviewUrl is not None:
161 e.setAttribute('review', r.reviewUrl) 163 e.setAttribute('review', r.reviewUrl)
164 if r.revision is not None:
165 e.setAttribute('revision', r.revision)
162 166
163 def Save(self, fd, peg_rev=False, peg_rev_upstream=True): 167 def Save(self, fd, peg_rev=False, peg_rev_upstream=True):
164 """Write the current manifest out to the given file descriptor. 168 """Write the current manifest out to the given file descriptor.
@@ -240,7 +244,8 @@ class XmlManifest(object):
240 if d.remote: 244 if d.remote:
241 remoteName = d.remote.remoteAlias or d.remote.name 245 remoteName = d.remote.remoteAlias or d.remote.name
242 if not d.remote or p.remote.name != remoteName: 246 if not d.remote or p.remote.name != remoteName:
243 e.setAttribute('remote', p.remote.name) 247 remoteName = p.remote.name
248 e.setAttribute('remote', remoteName)
244 if peg_rev: 249 if peg_rev:
245 if self.IsMirror: 250 if self.IsMirror:
246 value = p.bare_git.rev_parse(p.revisionExpr + '^0') 251 value = p.bare_git.rev_parse(p.revisionExpr + '^0')
@@ -252,8 +257,10 @@ class XmlManifest(object):
252 # isn't our value, and the if the default doesn't already have that 257 # isn't our value, and the if the default doesn't already have that
253 # covered. 258 # covered.
254 e.setAttribute('upstream', p.revisionExpr) 259 e.setAttribute('upstream', p.revisionExpr)
255 elif not d.revisionExpr or p.revisionExpr != d.revisionExpr: 260 else:
256 e.setAttribute('revision', p.revisionExpr) 261 revision = self.remotes[remoteName].revision or d.revisionExpr
262 if not revision or revision != p.revisionExpr:
263 e.setAttribute('revision', p.revisionExpr)
257 264
258 for c in p.copyfiles: 265 for c in p.copyfiles:
259 ce = doc.createElement('copyfile') 266 ce = doc.createElement('copyfile')
@@ -592,8 +599,11 @@ class XmlManifest(object):
592 review = node.getAttribute('review') 599 review = node.getAttribute('review')
593 if review == '': 600 if review == '':
594 review = None 601 review = None
602 revision = node.getAttribute('revision')
603 if revision == '':
604 revision = None
595 manifestUrl = self.manifestProject.config.GetString('remote.origin.url') 605 manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
596 return _XmlRemote(name, alias, fetch, manifestUrl, review) 606 return _XmlRemote(name, alias, fetch, manifestUrl, review, revision)
597 607
598 def _ParseDefault(self, node): 608 def _ParseDefault(self, node):
599 """ 609 """
@@ -686,7 +696,7 @@ class XmlManifest(object):
686 raise ManifestParseError("no remote for project %s within %s" % 696 raise ManifestParseError("no remote for project %s within %s" %
687 (name, self.manifestFile)) 697 (name, self.manifestFile))
688 698
689 revisionExpr = node.getAttribute('revision') 699 revisionExpr = node.getAttribute('revision') or remote.revision
690 if not revisionExpr: 700 if not revisionExpr:
691 revisionExpr = self._default.revisionExpr 701 revisionExpr = self._default.revisionExpr
692 if not revisionExpr: 702 if not revisionExpr:
diff --git a/project.py b/project.py
index 127176e5..db380a09 100644
--- a/project.py
+++ b/project.py
@@ -259,10 +259,12 @@ class RemoteSpec(object):
259 def __init__(self, 259 def __init__(self,
260 name, 260 name,
261 url = None, 261 url = None,
262 review = None): 262 review = None,
263 revision = None):
263 self.name = name 264 self.name = name
264 self.url = url 265 self.url = url
265 self.review = review 266 self.review = review
267 self.revision = revision
266 268
267class RepoHook(object): 269class RepoHook(object):
268 """A RepoHook contains information about a script to run as a hook. 270 """A RepoHook contains information about a script to run as a hook.
@@ -1657,7 +1659,8 @@ class Project(object):
1657 1659
1658 remote = RemoteSpec(self.remote.name, 1660 remote = RemoteSpec(self.remote.name,
1659 url = url, 1661 url = url,
1660 review = self.remote.review) 1662 review = self.remote.review,
1663 revision = self.remote.revision)
1661 subproject = Project(manifest = self.manifest, 1664 subproject = Project(manifest = self.manifest,
1662 name = name, 1665 name = name,
1663 remote = remote, 1666 remote = remote,