Patchwork [7,of,7,(push,is,done;,12,more,to,go,for,pull)] push: extract new common set computation from phase synchronisation

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 11, 2014, 9:32 p.m.
Message ID <b637cca233eaa73dc55c.1392154377@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3588/
State Accepted
Commit 7d0bbb6dd73006d423c061fc4147e16135189e97
Headers show

Comments

Pierre-Yves David - Feb. 11, 2014, 9:32 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391152323 28800
#      Thu Jan 30 23:12:03 2014 -0800
# Node ID b637cca233eaa73dc55c4f0bb6bc18c6b275a774
# Parent  1f749657b1e39fdb9b3c5a6fa91ce80eccbb1e11
push: extract new common set computation from phase synchronisation

Now that every necessary information is held in the `pushoperation` object, we
can extract the new common set computation to it's own function.

This changeset is pure code movement only.
Matt Mackall - Feb. 11, 2014, 11:02 p.m.
On Tue, 2014-02-11 at 13:32 -0800, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1391152323 28800
> #      Thu Jan 30 23:12:03 2014 -0800
> # Node ID b637cca233eaa73dc55c4f0bb6bc18c6b275a774
> # Parent  1f749657b1e39fdb9b3c5a6fa91ce80eccbb1e11
> push: extract new common set computation from phase synchronisation

These are queued for default, thanks.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -102,10 +102,11 @@  def push(repo, remote, force=False, revs
             lock = pushop.remote.lock()
         try:
             _pushdiscovery(pushop)
             if _pushcheckoutgoing(pushop):
                 _pushchangeset(pushop)
+            _pushcomputecommonheads(pushop)
             _pushsyncphase(pushop)
             _pushobsolete(pushop)
         finally:
             if lock is not None:
                 lock.release()
@@ -205,13 +206,48 @@  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:
+        # push succeed, synchronize target of the push
+        cheads = pushop.outgoing.missingheads
+    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)
+    pushop.commonheads = cheads
+
 def _pushsyncphase(pushop):
     """synchronise phase information locally and remotly"""
     unfi = pushop.repo.unfiltered()
+    cheads = pushop.commonheads
     if pushop.ret:
         # push succeed, synchronize target of the push
         cheads = pushop.outgoing.missingheads
     elif pushop.revs is None:
         # All out push fails. synchronize all common