From 14a6674e32b3000dbe8b7c96b0d1bb4fb0021720 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Fri, 28 Sep 2012 20:21:57 -0700 Subject: 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 --- manifest_xml.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'manifest_xml.py') 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): 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': -- cgit v1.2.3-54-g00ecf