changeset 3709:aaa6adbbb47a stable

compat: handle different `ui.edit` signature with Mercurial 4.3
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 24 Apr 2018 15:23:15 +0100
parents d7a89d5b3684
children f84cbb816d64 220e0811b39d
files hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/obsexchange.py
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Apr 24 16:13:42 2018 +0100
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Apr 24 15:23:15 2018 +0100
@@ -195,7 +195,10 @@
     while newnode is None:
         fp.seek(0)
         previous_patch = fp.getvalue()
-        newpatch = ui.edit(fp.getvalue(), old.user(), action="diff")
+        if 5 <= len(ui.edit.im_func.func_defaults):
+            newpatch = ui.edit(fp.getvalue(), old.user(), action="diff")
+        else:
+            newpatch = ui.edit(fp.getvalue(), old.user())
 
         afp = stringio()
         afp.write(newpatch)
--- a/hgext3rd/evolve/obsexchange.py	Tue Apr 24 16:13:42 2018 +0100
+++ b/hgext3rd/evolve/obsexchange.py	Tue Apr 24 15:23:15 2018 +0100
@@ -54,12 +54,12 @@
 @eh.uisetup
 def addgetbundleargs(self):
     try:
+        from mercurial import wireprototypes
+        gboptsmap = wireprototypes.GETBUNDLE_ARGUMENTS
+    except (ImportError, AttributeError):
         # <= hg 4.5
         from mercurial import wireproto
         gboptsmap = wireproto.gboptsmap
-    except (ImportError, AttributeError):
-        from mercurial import wireprototypes
-        gboptsmap = wireprototypes.GETBUNDLE_ARGUMENTS
     gboptsmap['evo_obscommon'] = 'nodes'
     gboptsmap['evo_missing_nodes'] = 'nodes'