Avoid git fork on the common case of repo not changing

Usually repo is upgraded only once a week, if that often.  Most of
the time we invoke HasChanges on the repo project (or even on the
manifest project) the current HEAD will resolve to the same SHA-1
as the remote tracking ref, and there are therefore no changes.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-04-18 10:39:28 -07:00
parent 2810cbc778
commit 336f7bd0ed

View File

@ -1353,7 +1353,25 @@ class MetaProject(Project):
def HasChanges(self): def HasChanges(self):
"""Has the remote received new commits not yet checked out? """Has the remote received new commits not yet checked out?
""" """
if not self.remote or not self.revision:
return False
all = self.bare_ref.all
rev = self.GetRemote(self.remote.name).ToLocal(self.revision) rev = self.GetRemote(self.remote.name).ToLocal(self.revision)
if self._revlist(not_rev(HEAD), rev): if rev in all:
revid = all[rev]
else:
revid = rev
head = self.work_git.GetHead()
if head.startswith(R_HEADS):
try:
head = all[head]
except KeyError:
head = None
if revid == head:
return False
elif self._revlist(not_rev(HEAD), rev):
return True return True
return False return False