summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-18 10:39:28 -0700
committerShawn O. Pearce <sop@google.com>2009-04-18 10:39:28 -0700
commit336f7bd0ed70f5ee2595463b6bd8dd277e90c833 (patch)
tree4854b1808bcda18221e097a69c993c4a0cf6137a /project.py
parent2810cbc7784e9a21e7001c31b65af94fd9ba7a5b (diff)
downloadgit-repo-336f7bd0ed70f5ee2595463b6bd8dd277e90c833.tar.gz
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>
Diffstat (limited to 'project.py')
-rw-r--r--project.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/project.py b/project.py
index 09a768fb..9f4512f6 100644
--- a/project.py
+++ b/project.py
@@ -1353,7 +1353,25 @@ class MetaProject(Project):
1353 def HasChanges(self): 1353 def HasChanges(self):
1354 """Has the remote received new commits not yet checked out? 1354 """Has the remote received new commits not yet checked out?
1355 """ 1355 """
1356 if not self.remote or not self.revision:
1357 return False
1358
1359 all = self.bare_ref.all
1356 rev = self.GetRemote(self.remote.name).ToLocal(self.revision) 1360 rev = self.GetRemote(self.remote.name).ToLocal(self.revision)
1357 if self._revlist(not_rev(HEAD), rev): 1361 if rev in all:
1362 revid = all[rev]
1363 else:
1364 revid = rev
1365
1366 head = self.work_git.GetHead()
1367 if head.startswith(R_HEADS):
1368 try:
1369 head = all[head]
1370 except KeyError:
1371 head = None
1372
1373 if revid == head:
1374 return False
1375 elif self._revlist(not_rev(HEAD), rev):
1358 return True 1376 return True
1359 return False 1377 return False