# HG changeset patch # User Pierre-Yves David # Date 1508520596 -7200 # Node ID e11e018e83387ede464a9ce0724bbe5ad09affdd # Parent 9c04bd9280560ac06e43b4033dc849e6fdae9ad4 compat: add an abstraction for 'scmutil.cleanupnodes' The usage of the function was added in 103244e34a9c but is not compatible with Mercurial <= 4.2. diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- 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] diff --git a/hgext3rd/topic/compat.py b/hgext3rd/topic/compat.py --- 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)