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
This commit is contained in:
Brian Harring
2012-09-28 20:21:57 -07:00
parent 34acdd2534
commit 14a6674e32
3 changed files with 55 additions and 17 deletions

View File

@@ -123,7 +123,7 @@ class XmlManifest(object):
if r.reviewUrl is not None:
e.setAttribute('review', r.reviewUrl)
def Save(self, fd, peg_rev=False):
def Save(self, fd, peg_rev=False, peg_rev_upstream=True):
"""Write the current manifest out to the given file descriptor.
"""
mp = self.manifestProject
@@ -197,11 +197,15 @@ class XmlManifest(object):
e.setAttribute('remote', p.remote.name)
if peg_rev:
if self.IsMirror:
e.setAttribute('revision',
p.bare_git.rev_parse(p.revisionExpr + '^0'))
value = p.bare_git.rev_parse(p.revisionExpr + '^0')
else:
e.setAttribute('revision',
p.work_git.rev_parse(HEAD + '^0'))
value = p.work_git.rev_parse(HEAD + '^0')
e.setAttribute('revision', value)
if peg_rev_upstream and value != p.revisionExpr:
# Only save the origin if the origin is not a sha1, and the default
# isn't our value, and the if the default doesn't already have that
# covered.
e.setAttribute('upstream', p.revisionExpr)
elif not d.revisionExpr or p.revisionExpr != d.revisionExpr:
e.setAttribute('revision', p.revisionExpr)
@@ -573,6 +577,8 @@ class XmlManifest(object):
else:
sync_c = sync_c.lower() in ("yes", "true", "1")
upstream = node.getAttribute('upstream')
groups = ''
if node.hasAttribute('groups'):
groups = node.getAttribute('groups')
@@ -599,7 +605,8 @@ class XmlManifest(object):
revisionId = None,
rebase = rebase,
groups = groups,
sync_c = sync_c)
sync_c = sync_c,
upstream = upstream)
for n in node.childNodes:
if n.nodeName == 'copyfile':