Patchwork [1,of,6] checkheads: gather the postprocessing with other obsolescence specific code

login
register
mail settings
Submitter Pierre-Yves David
Date June 4, 2017, 2:49 p.m.
Message ID <df3d013cc55eeeab9296.1496587769@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21169/
State Accepted
Headers show

Comments

Pierre-Yves David - June 4, 2017, 2:49 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1496029559 -7200
#      Mon May 29 05:45:59 2017 +0200
# Node ID df3d013cc55eeeab9296daf313d73bcafae4883c
# Parent  fc9296c15112af247e4985cdc45fbbf7d8eed175
# EXP-Topic pushrace
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r df3d013cc55e
checkheads: gather the postprocessing with other obsolescence specific code

We extract this function from the loop and gather it with the rest of the
obsolescence specific code. That will help to clarify the move of the whole logic
inside the "heads summary" computation.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -331,13 +331,17 @@  def checkheads(pushop):
     # If there are more heads after the push than before, a suitable
     # error message, depending on unsynced status, is displayed.
     errormsg = None
-    # If there is no obsstore, allfuturecommon won't be used, so no
-    # need to compute it.
+    # If there are no obsstore, no post-processing are needed.
     if repo.obsstore:
         allmissing = set(outgoing.missing)
         cctx = repo.set('%ld', outgoing.common)
         allfuturecommon = set(c.node() for c in cctx)
         allfuturecommon.update(allmissing)
+        for branch, heads in sorted(headssum.iteritems()):
+            remoteheads, newheads, unsyncedheads = heads
+            result = _postprocessobsolete(pushop, allfuturecommon, newheads)
+            newheads = sorted(result[0])
+            headssum[branch] = (remoteheads, newheads, unsyncedheads)
     for branch, heads in sorted(headssum.iteritems()):
         remoteheads, newheads, unsyncedheads = heads
         # add unsynced data
@@ -347,9 +351,6 @@  def checkheads(pushop):
             oldhs = set(remoteheads)
         oldhs.update(unsyncedheads)
         dhs = None # delta heads, the new heads on branch
-        if repo.obsstore:
-            result = _postprocessobsolete(pushop, allfuturecommon, newheads)
-            newheads = sorted(result[0])
         newhs = set(newheads)
         newhs.update(unsyncedheads)
         if unsyncedheads: