From patchwork Mon Aug 4 22:32:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,7] push: extract future heads computation into pushop From: Pierre-Yves David X-Patchwork-Id: 5249 Message-Id: <34bef128e179a7bcc904.1407191523@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Mon, 04 Aug 2014 15:32:03 -0700 # 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/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -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 else: # I want cheads = heads(::missingheads and ::commonheads)