mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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:
parent
2810cbc778
commit
336f7bd0ed
20
project.py
20
project.py
@ -1353,7 +1353,25 @@ class MetaProject(Project):
|
||||
def HasChanges(self):
|
||||
"""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)
|
||||
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 False
|
||||
|
Loading…
Reference in New Issue
Block a user