push: move common heads computation into pushop
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 01 Jul 2014 17:27:22 +0200
changeset 22016 7d976d71684c
parent 22015 c478031deba2
child 22017 7986e99bb69a
push: move common heads computation into pushop Now that both options (push succeed or fall back) live in pushop, we can move the common heads computation there too. It is a very commonly accessed attribute so it makes a lot of sense to have it in pushop.
mercurial/exchange.py
--- a/mercurial/exchange.py	Tue Jul 01 17:20:47 2014 +0200
+++ b/mercurial/exchange.py	Tue Jul 01 17:27:22 2014 +0200
@@ -77,8 +77,6 @@
         self.remoteheads = None
         # testable as a boolean indicating if any nodes are missing locally.
         self.incoming = None
-        # set of all heads common after changeset bundle push
-        self.commonheads = None
 
     @util.propertycache
     def futureheads(self):
@@ -117,6 +115,13 @@
         cheads.extend(c.node() for c in revset)
         return cheads
 
+    @property
+    def commonheads(self):
+        """set of all common heads after changeset bundle push"""
+        if self.ret:
+            return self.futureheads
+        else:
+            return self.fallbackheads
 
 def push(repo, remote, force=False, revs=None, newbranch=False):
     '''Push outgoing changesets (limited by revs) from a local
@@ -174,7 +179,6 @@
                 and pushop.remote.capable('bundle2-exp')):
                 _pushbundle2(pushop)
             _pushchangeset(pushop)
-            _pushcomputecommonheads(pushop)
             _pushsyncphase(pushop)
             _pushobsolete(pushop)
         finally:
@@ -345,13 +349,6 @@
         # change
         pushop.ret = pushop.remote.addchangegroup(cg, 'push', pushop.repo.url())
 
-def _pushcomputecommonheads(pushop):
-    if pushop.ret:
-        cheads = pushop.futureheads
-    else:
-        cheads = pushop.fallbackheads
-    pushop.commonheads = cheads
-
 def _pushsyncphase(pushop):
     """synchronise phase information locally and remotely"""
     unfi = pushop.repo.unfiltered()