subrepo: speed up git push logic
authorEric Eisner <ede@mit.edu>
Thu, 09 Dec 2010 16:52:14 -0500
changeset 13109 53341289eaf8
parent 13108 dcaad69cfd6a
child 13110 cad35f06c031
subrepo: speed up git push logic In many common cases where the subrepo is up to date with the remote repo, hg push will only need to run one git-branch command to see that nothing needs to be pushed.
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Thu Dec 09 16:52:14 2010 -0500
+++ b/mercurial/subrepo.py	Thu Dec 09 16:52:14 2010 -0500
@@ -813,8 +813,12 @@
     def push(self, force):
         # if a branch in origin contains the revision, nothing to do
         current, branch2rev, rev2branch = self._gitbranchmap()
+        if self._state[1] in rev2branch:
+            for b in rev2branch[self._state[1]]:
+                if b.startswith('remotes/origin/'):
+                    return True
         for b, revision in branch2rev.iteritems():
-            if b.startswith('remotes/origin'):
+            if b.startswith('remotes/origin/'):
                 if self._gitisancestor(self._state[1], revision):
                     return True
         # otherwise, try to push the currently checked out branch