summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
authorBrian Harring <ferringb@google.com>2012-09-28 20:21:57 -0700
committerBrian Harring <ferringb@google.com>2012-09-28 22:31:27 -0700
commit14a6674e32b3000dbe8b7c96b0d1bb4fb0021720 (patch)
tree024482226fefd4c188f20f56047325b69d388a9f /manifest_xml.py
parent34acdd253439448b6c08c3abfc5e7b8bd03f383f (diff)
downloadgit-repo-14a6674e32b3000dbe8b7c96b0d1bb4fb0021720.tar.gz
manifest: record the original revision when in -r mode.
Currently when doing a sync against a revision locked manifest, sync has no option but to fall back to sync'ing the entire refs space; it doesn't know which ref to ask for that contains the sha1 it wants. This sucks if we're in -c mode; thus when we generate a revision locked manifest, record the originating branch- and try syncing that branch first. If the sha1 is found within that branch, this saves us having to pull down the rest of the repo- a potentially heavy saving. If that branch doesn't have the desired sha1, we fallback to sync'ing everything. Change-Id: I99a5e44fa1d792dfcada76956a2363187df94cf1
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 8e9efd13..be185477 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -123,7 +123,7 @@ class XmlManifest(object):
123 if r.reviewUrl is not None: 123 if r.reviewUrl is not None:
124 e.setAttribute('review', r.reviewUrl) 124 e.setAttribute('review', r.reviewUrl)
125 125
126 def Save(self, fd, peg_rev=False): 126 def Save(self, fd, peg_rev=False, peg_rev_upstream=True):
127 """Write the current manifest out to the given file descriptor. 127 """Write the current manifest out to the given file descriptor.
128 """ 128 """
129 mp = self.manifestProject 129 mp = self.manifestProject
@@ -197,11 +197,15 @@ class XmlManifest(object):
197 e.setAttribute('remote', p.remote.name) 197 e.setAttribute('remote', p.remote.name)
198 if peg_rev: 198 if peg_rev:
199 if self.IsMirror: 199 if self.IsMirror:
200 e.setAttribute('revision', 200 value = p.bare_git.rev_parse(p.revisionExpr + '^0')
201 p.bare_git.rev_parse(p.revisionExpr + '^0'))
202 else: 201 else:
203 e.setAttribute('revision', 202 value = p.work_git.rev_parse(HEAD + '^0')
204 p.work_git.rev_parse(HEAD + '^0')) 203 e.setAttribute('revision', value)
204 if peg_rev_upstream and value != p.revisionExpr:
205 # Only save the origin if the origin is not a sha1, and the default
206 # isn't our value, and the if the default doesn't already have that
207 # covered.
208 e.setAttribute('upstream', p.revisionExpr)
205 elif not d.revisionExpr or p.revisionExpr != d.revisionExpr: 209 elif not d.revisionExpr or p.revisionExpr != d.revisionExpr:
206 e.setAttribute('revision', p.revisionExpr) 210 e.setAttribute('revision', p.revisionExpr)
207 211
@@ -573,6 +577,8 @@ class XmlManifest(object):
573 else: 577 else:
574 sync_c = sync_c.lower() in ("yes", "true", "1") 578 sync_c = sync_c.lower() in ("yes", "true", "1")
575 579
580 upstream = node.getAttribute('upstream')
581
576 groups = '' 582 groups = ''
577 if node.hasAttribute('groups'): 583 if node.hasAttribute('groups'):
578 groups = node.getAttribute('groups') 584 groups = node.getAttribute('groups')
@@ -599,7 +605,8 @@ class XmlManifest(object):
599 revisionId = None, 605 revisionId = None,
600 rebase = rebase, 606 rebase = rebase,
601 groups = groups, 607 groups = groups,
602 sync_c = sync_c) 608 sync_c = sync_c,
609 upstream = upstream)
603 610
604 for n in node.childNodes: 611 for n in node.childNodes:
605 if n.nodeName == 'copyfile': 612 if n.nodeName == 'copyfile':