compat: add an abstraction for 'scmutil.cleanupnodes'
The usage of the function was added in 103244e34a9c but is not compatible with
Mercurial <= 4.2.
--- a/hgext3rd/topic/__init__.py Fri Oct 20 18:56:15 2017 +0200
+++ b/hgext3rd/topic/__init__.py Fri Oct 20 19:29:56 2017 +0200
@@ -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 Fri Oct 20 18:56:15 2017 +0200
+++ b/hgext3rd/topic/compat.py Fri Oct 20 19:29:56 2017 +0200
@@ -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)