Avoid unnecessary git symbolic-ref calls during repo sync

If the m/BRANCH ref is already pointing at the value set in the
manifest there is no reason to set it again.  Leave it alone,
thus saving a full fork+exec call.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-04-17 20:32:44 -07:00
parent c12c360f89
commit 0f3dd233ec
2 changed files with 18 additions and 5 deletions

View File

@ -31,8 +31,7 @@ class GitRefs(object):
@property
def all(self):
if self._phyref is None or self._NeedUpdate():
self._LoadAll()
self._EnsureLoaded()
return self._phyref
def get(self, name):
@ -52,6 +51,17 @@ class GitRefs(object):
if name in self._mtime:
del self._mtime[name]
def symref(self, name):
try:
self._EnsureLoaded()
return self._symref[name]
except KeyError:
return ''
def _EnsureLoaded(self):
if self._phyref is None or self._NeedUpdate():
self._LoadAll()
def _NeedUpdate(self):
for name, mtime in self._mtime.iteritems():
try: