hgext3rd/topic/compat.py
branchstable
changeset 3094 e11e018e8338
parent 3064 7a1a4d1f0958
child 3560 f61a23a84dac
--- 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)