compat: fix compatibility with new duplicatecopies
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 17 Oct 2017 17:35:05 +0200
changeset 3074 8d57acde165d
parent 3073 83627d3a7311
child 3075 8feb2cae7eae
compat: fix compatibility with new duplicatecopies Changeset 754b5117622f updated the signature of 'copies.duplicatecopies'. We can now handle the multiple version of that code for compatiblity.
hgext3rd/evolve/__init__.py
hgext3rd/evolve/compat.py
--- a/hgext3rd/evolve/__init__.py	Sat Oct 14 19:14:27 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Tue Oct 17 17:35:05 2017 +0200
@@ -924,7 +924,7 @@
             repo.setparents(repo['.'].node(), nullid)
             repo.dirstate.write(tr)
             # fix up dirstate for copies and renames
-            copies.duplicatecopies(repo, dest.rev(), orig.p1().rev())
+            compat.duplicatecopies(repo, repo[None], dest.rev(), orig.p1().rev())
 
         class LocalMergeFailure(MergeFailure, exc.__class__):
             pass
--- a/hgext3rd/evolve/compat.py	Sat Oct 14 19:14:27 2017 +0200
+++ b/hgext3rd/evolve/compat.py	Tue Oct 17 17:35:05 2017 +0200
@@ -7,6 +7,7 @@
 """
 
 from mercurial import (
+    copies,
     context,
     hg,
     obsolete,
@@ -177,3 +178,12 @@
     """function to start a pager in case ui.pager() exists"""
     if util.safehasattr(ui, 'pager'):
         ui.pager(cmd)
+
+def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None):
+    # cannot use anything else until 4.3 support is dropped.
+    assert wctx.rev() is None
+    if copies.duplicatecopies.__code__.co_argcount < 5:
+        # pre 4.4 duplicatecopies compat
+        copies.duplicatecopies(repo, rev, fromrev, skiprev=skiprev)
+    else:
+        copies.duplicatecopies(repo, wctx, rev, fromrev, skiprev=skiprev)