changeset 3199:e11e018e8338 stable

compat: add an abstraction for 'scmutil.cleanupnodes' The usage of the function was added in 103244e34a9c but is not compatible with Mercurial <= 4.2.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 20 Oct 2017 19:29:56 +0200
parents 9c04bd928056
children 7a5941d91fc0
files hgext3rd/topic/__init__.py hgext3rd/topic/compat.py
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -778,7 +778,9 @@
         rewrote += 1
 
     # create obsmarkers and move bookmarks
-    scmutil.cleanupnodes(repo, successors, 'changetopics')
+    # XXX we should be creating marker as we go instead of only at the end,
+    # this makes the operations more modulars
+    compat.cleanupnodes(repo, successors, 'changetopics')
 
     # move the working copy too
     wctx = repo[None]
--- a/hgext3rd/topic/compat.py
+++ b/hgext3rd/topic/compat.py
@@ -7,7 +7,11 @@
 """
 from __future__ import absolute_import
 
-from mercurial import obsolete
+from mercurial import (
+    obsolete,
+    scmutil,
+    util,
+)
 
 getmarkers = None
 successorssets = None
@@ -29,3 +33,15 @@
         ui.pager(cmd)
     except AttributeError:
         pass
+
+def cleanupnodes(repo, replacements, operation, moves=None):
+    # create obsmarkers and move bookmarks
+    # XXX we should be creating marker as we go instead of only at the end,
+    # this makes the operations more modulars
+    if util.safehasattr(scmutil, 'cleanupnodes'):
+        scmutil.cleanupnodes(repo, replacements, 'changetopics',
+                             moves=moves)
+    else:
+        relations = [(repo[o], tuple(repo[n] for n in new))
+                     for (o, new) in replacements.iteritems()]
+        obsolete.createmarkers(repo, relations)