changeset 2693:f4b0351fa813

evolve: adapt to function migrate to obsutil Mercurial 4.3 has a new module "obsutil" and multiple functions moved there. We handle the move for the one we care about.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 02 Jul 2017 15:02:11 +0200
parents 96843c68acc8
children 8a222745a71c
files hgext3rd/evolve/__init__.py hgext3rd/evolve/compat.py hgext3rd/evolve/obshistory.py
diffstat 3 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Sun Jul 02 14:10:44 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Sun Jul 02 15:02:11 2017 +0200
@@ -928,7 +928,7 @@
         if not ctx.obsolete():
             continue
 
-        successors = obsolete.successorssets(repo, ctx.node(), cache)
+        successors = compat.successorssets(repo, ctx.node(), cache)
 
         # We can't make any assumptions about how to update the hash if the
         # cset in question was split or diverged.
@@ -1201,14 +1201,14 @@
         return p.rev()
     obs = repo[p]
     ui = repo.ui
-    newer = obsolete.successorssets(repo, obs.node())
+    newer = compat.successorssets(repo, obs.node())
     # search of a parent which is not killed
     while not newer:
         ui.debug("stabilize target %s is plain dead,"
                  " trying to stabilize on its parent\n" %
                  obs)
         obs = obs.parents()[0]
-        newer = obsolete.successorssets(repo, obs.node())
+        newer = compat.successorssets(repo, obs.node())
     if len(newer) > 1 or len(newer[0]) > 1:
         raise MultipleSuccessorsError(newer)
 
@@ -1328,11 +1328,11 @@
     """Compute sets of commits divergent with a given one"""
     cache = {}
     base = {}
-    for n in obsolete.allprecursors(repo.obsstore, [ctx.node()]):
+    for n in compat.allprecursors(repo.obsstore, [ctx.node()]):
         if n == ctx.node():
             # a node can't be a base for divergence with itself
             continue
-        nsuccsets = obsolete.successorssets(repo, n, cache)
+        nsuccsets = compat.successorssets(repo, n, cache)
         for nsuccset in nsuccsets:
             if ctx.node() in nsuccset:
                 # we are only interested in *other* successor sets
@@ -1636,7 +1636,7 @@
     tovisit = list(parents(rev))
     while tovisit:
         r = tovisit.pop()
-        succsets = obsolete.successorssets(repo, tonode(r))
+        succsets = compat.successorssets(repo, tonode(r))
         if not succsets:
             tovisit.extend(parents(r))
         else:
@@ -1699,14 +1699,14 @@
         ui.warn(_("cannot solve instability of %s, skipping\n") % orig)
         return False
     obs = pctx
-    newer = obsolete.successorssets(repo, obs.node())
+    newer = compat.successorssets(repo, obs.node())
     # search of a parent which is not killed
     while not newer or newer == [()]:
         ui.debug("stabilize target %s is plain dead,"
                  " trying to stabilize on its parent\n" %
                  obs)
         obs = obs.parents()[0]
-        newer = obsolete.successorssets(repo, obs.node())
+        newer = compat.successorssets(repo, obs.node())
     if len(newer) > 1:
         msg = _("skipping %s: divergent rewriting. can't choose "
                 "destination\n") % obs
@@ -1985,7 +1985,7 @@
     """
     repo = ctx._repo.unfiltered()
     for base in repo.set('reverse(allprecursors(%d))', ctx):
-        newer = obsolete.successorssets(ctx._repo, base.node())
+        newer = compat.successorssets(ctx._repo, base.node())
         # drop filter and solution including the original ctx
         newer = [n for n in newer if n and ctx.node() not in n]
         if newer:
@@ -2827,7 +2827,7 @@
             if not (duplicate or allowdivergence):
                 # The user hasn't yet decided what to do with the revived
                 # cset, let's ask
-                sset = obsolete.successorssets(repo, ctx.node())
+                sset = compat.successorssets(repo, ctx.node())
                 nodivergencerisk = (len(sset) == 0 or
                                     (len(sset) == 1 and
                                      len(sset[0]) == 1 and
--- a/hgext3rd/evolve/compat.py	Sun Jul 02 14:10:44 2017 +0200
+++ b/hgext3rd/evolve/compat.py	Sun Jul 02 15:02:11 2017 +0200
@@ -11,6 +11,12 @@
     obsolete
 )
 
+try:
+    from mercurial import obsutil
+    obsutil.closestpredecessors
+except ImportError:
+    obsutil = None
+
 from . import (
     exthelper,
 )
@@ -55,3 +61,17 @@
             pendingnodes -= seennodes
             seennodes |= pendingnodes
         return seenmarkers
+
+# successors set move from mercurial.obsolete to mercurial.obsutil in 4.3
+def successorssets(*args, **kwargs):
+    func = getattr(obsutil, 'successorssets', None)
+    if func is None:
+        func = obsolete.successorssets
+    return func(*args, **kwargs)
+
+# allprecursors set move from mercurial.obsolete to mercurial.obsutil in 4.3
+def allprecursors(*args, **kwargs):
+    func = getattr(obsutil, 'allprecursors', None)
+    if func is None:
+        func = obsolete.allprecursors
+    return func(*args, **kwargs)
--- a/hgext3rd/evolve/obshistory.py	Sun Jul 02 14:10:44 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py	Sun Jul 02 15:02:11 2017 +0200
@@ -24,6 +24,7 @@
 from mercurial.i18n import _
 
 from . import (
+    compat,
     exthelper,
 )
 
@@ -681,7 +682,7 @@
     or has diverged
     """
     if successorssets is None:
-        successorssets = obsolete.successorssets(repo, revnode)
+        successorssets = compat.successorssets(repo, revnode)
 
     fate = _getobsfate(successorssets)