Patchwork [3,of,4] checkheads: use "revnum" in the "allfuturecommon" set

mail settings
Submitter Pierre-Yves David
Date June 10, 2017, 1:32 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/21310/
State Accepted
Headers show


Pierre-Yves David - June 10, 2017, 1:32 a.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1496666224 -3600
#      Mon Jun 05 13:37:04 2017 +0100
# Node ID 4f1a47b8fdacbb3f757ac7f92d783770dcf8215d
# Parent  a0df0fa8e5b7bccd329d3546e54ba488ca89e035
# EXP-Topic skipctx
# Available At
#              hg pull -r 4f1a47b8fdac
checkheads: use "revnum" in the "allfuturecommon" set

The obsolete post-processing needs to know the extend of the pushed set. The
way it is implemented is... suboptimal. It build a full set of all nodes in the
pushset and it does so using changectx. We have much better API for this now.
The simplest is to use the existing lazy ancestors computation. That logic uses
revnum and not node (for good reason) so we start with updating the
post-processing code to handle a "allfuturecommon" set containing revision


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -250,8 +250,9 @@  def _headssummary(pushop):
     if repo.obsstore:
         allmissing = set(outgoing.missing)
         cctx = repo.set('%ld', outgoing.common)
-        allfuturecommon = set(c.node() for c in cctx)
-        allfuturecommon.update(allmissing)
+        allfuturecommon = set(c.rev() for c in cctx)
+        torev = repo.changelog.rev
+        allfuturecommon.update(torev(m) for m in allmissing)
         for branch, heads in sorted(headssum.iteritems()):
             remoteheads, newheads, unsyncedheads, placeholder = heads
             result = _postprocessobsolete(pushop, allfuturecommon, newheads)
@@ -443,7 +444,7 @@  def _postprocessobsolete(pushop, futurec
     public = phases.public
     getphase = unfi._phasecache.phase
     ispublic = (lambda r: getphase(unfi, r) == public)
-    ispushed = (lambda n: n in futurecommon)
+    ispushed = (lambda n: torev(n) in futurecommon)
     hasoutmarker = functools.partial(pushingmarkerfor, unfi.obsstore, ispushed)
     successorsmarkers = unfi.obsstore.successors
     newhs = set() # final set of new heads
@@ -469,7 +470,7 @@  def _postprocessobsolete(pushop, futurec
     while localcandidate:
         nh = localcandidate.pop()
         # run this check early to skip the evaluation of the whole branch
-        if (nh in futurecommon or ispublic(torev(nh))):
+        if (torev(nh) in futurecommon or ispublic(torev(nh))):
@@ -484,7 +485,7 @@  def _postprocessobsolete(pushop, futurec
         # * any part of it is considered part of the result by previous logic,
         # * if we have no markers to push to obsolete it.
         if (any(ispublic(r) for r in branchrevs)
-                or any(n in futurecommon for n in branchnodes)
+                or any(torev(n) in futurecommon for n in branchnodes)
                 or any(not hasoutmarker(n) for n in branchnodes)):