compat: handle different `ui.edit` signature with Mercurial 4.3 stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 24 Apr 2018 15:23:15 +0100
branchstable
changeset 3709 aaa6adbbb47a
parent 3708 d7a89d5b3684
child 3710 f84cbb816d64
child 3717 220e0811b39d
compat: handle different `ui.edit` signature with Mercurial 4.3
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/obsexchange.py
--- 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'