Patchwork [1,of,7] push: extract future heads computation into pushop

mail settings
Submitter Pierre-Yves David
Date Aug. 4, 2014, 10:32 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/5249/
State Accepted
Headers show


Pierre-Yves David - Aug. 4, 2014, 10:32 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1404228031 -7200
#      Tue Jul 01 17:20:31 2014 +0200
# Node ID 34bef128e179a7bcc90401f3bd80162f33519d12
# Parent  284a8c9f74f38b1003f8b4ccedf5010ed3da87c3
push: extract future heads computation into pushop

Bundle2 will allow to push all different parts of the push in on single bundle.
This mean that the discovery for each part needs to be done before trying to
push. Currently may have different behaviors for phases and obsolescence markers
when the push of changesets fails. For example, information may still be
exchanged for a part of the history where changesets are common but where
phases mismatch. So the preparation of the push need to determine what
information need to be push in both situations. And it needs a different set of
heads for this. Therefor we are moving heads computation within pushop for easy
access by all parties. We start with the simplest set of heads.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -78,10 +78,15 @@  class pushoperation(object):
         # 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
 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
       - 0 means HTTP error
@@ -308,12 +313,11 @@  def _pushchangeset(pushop):
         pushop.ret = pushop.remote.addchangegroup(cg, 'push', pushop.repo.url())
 def _pushcomputecommonheads(pushop):
     unfi = pushop.repo.unfiltered()
     if pushop.ret:
-        # push succeed, synchronize target of the push
-        cheads = pushop.outgoing.missingheads
+        cheads = pushop.futureheads
     elif pushop.revs is None:
         # All out push fails. synchronize all common
         cheads = pushop.outgoing.commonheads
         # I want cheads = heads(::missingheads and ::commonheads)