[PATCH 2 of 7] push: extract fallback heads computation into pushop
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Mon Aug 4 17:32:04 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1404228047 -7200
# Tue Jul 01 17:20:47 2014 +0200
# Node ID df19d14fd7bd1562324f50e7f55f0ec7b87aa54d
# Parent 34bef128e179a7bcc90401f3bd80162f33519d12
push: extract fallback heads computation into pushop
Similar motivation than for `futureheads` we extract the computation into pushop
to make it available early to all possibles interested parties.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -83,10 +83,43 @@ class pushoperation(object):
@util.propertycache
def futureheads(self):
"""future remote heads if the changeset push succeed"""
return self.outgoing.missingheads
+ @util.propertycache
+ def fallbackheads(self):
+ """future remote heads if the changeset push fails"""
+ if self.revs is None:
+ # not target to push, all common are relevant
+ return self.outgoing.commonheads
+ unfi = self.repo.unfiltered()
+ # I want cheads = heads(::missingheads and ::commonheads)
+ # (missingheads is revs with secret changeset filtered out)
+ #
+ # This can be expressed as:
+ # cheads = ( (missingheads and ::commonheads)
+ # + (commonheads and ::missingheads))"
+ # )
+ #
+ # while trying to push we already computed the following:
+ # common = (::commonheads)
+ # missing = ((commonheads::missingheads) - commonheads)
+ #
+ # We can pick:
+ # * missingheads part of common (::commonheads)
+ common = set(self.outgoing.common)
+ nm = self.repo.changelog.nodemap
+ cheads = [node for node in self.revs if nm[node] in common]
+ # and
+ # * commonheads parents on missing
+ revset = unfi.set('%ln and parents(roots(%ln))',
+ self.outgoing.commonheads,
+ self.outgoing.missing)
+ cheads.extend(c.node() for c in revset)
+ return cheads
+
+
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
@@ -311,40 +344,14 @@ def _pushchangeset(pushop):
# we return an integer indicating remote head count
# change
pushop.ret = pushop.remote.addchangegroup(cg, 'push', pushop.repo.url())
def _pushcomputecommonheads(pushop):
- unfi = pushop.repo.unfiltered()
if pushop.ret:
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)
- # (missingheads is revs with secret changeset filtered out)
- #
- # This can be expressed as:
- # cheads = ( (missingheads and ::commonheads)
- # + (commonheads and ::missingheads))"
- # )
- #
- # while trying to push we already computed the following:
- # common = (::commonheads)
- # missing = ((commonheads::missingheads) - commonheads)
- #
- # We can pick:
- # * missingheads part of common (::commonheads)
- common = set(pushop.outgoing.common)
- nm = pushop.repo.changelog.nodemap
- cheads = [node for node in pushop.revs if nm[node] in common]
- # and
- # * commonheads parents on missing
- revset = unfi.set('%ln and parents(roots(%ln))',
- pushop.outgoing.commonheads,
- pushop.outgoing.missing)
- cheads.extend(c.node() for c in revset)
+ cheads = pushop.fallbackheads
pushop.commonheads = cheads
def _pushsyncphase(pushop):
"""synchronise phase information locally and remotely"""
unfi = pushop.repo.unfiltered()
More information about the Mercurial-devel
mailing list