[PATCH 3 of 7] push: move common heads computation in pushop

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Mon Aug 4 17:32:05 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1404228442 -7200
#      Tue Jul 01 17:27:22 2014 +0200
# Node ID 757e2729b231c008ac4657d57f98a0eca6c4617b
# Parent  df19d14fd7bd1562324f50e7f55f0ec7b87aa54d
push: move common heads computation in pushop

Now that both option (push succeed or fall back) lives on 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 on pushop.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -75,12 +75,10 @@ class pushoperation(object):
         self.outgoing = None
         # all remote heads before the push
         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):
         """future remote heads if the changeset push succeed"""
         return self.outgoing.missingheads
@@ -115,10 +113,17 @@ class pushoperation(object):
                          self.outgoing.commonheads,
                          self.outgoing.missing)
         cheads.extend(c.node() for c in revset)
         return cheads
 
+    @property
+    def commonheads(self):
+        """set of all heads common 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
     repository to remote. Return an integer:
       - None means nothing to push
@@ -172,11 +177,10 @@ def push(repo, remote, force=False, revs
             if (pushop.repo.ui.configbool('experimental', 'bundle2-exp',
                                           False)
                 and pushop.remote.capable('bundle2-exp')):
                 _pushbundle2(pushop)
             _pushchangeset(pushop)
-            _pushcomputecommonheads(pushop)
             _pushsyncphase(pushop)
             _pushobsolete(pushop)
         finally:
             if lock is not None:
                 lock.release()
@@ -343,17 +347,10 @@ def _pushchangeset(pushop):
     else:
         # we return an integer indicating remote head count
         # 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()
     cheads = pushop.commonheads
     # even when we don't push, exchanging phase data is useful


More information about the Mercurial-devel mailing list