obsfate: fix changeset description diff computing
authorBoris Feld <boris.feld@octobus.net>
Wed, 14 Feb 2018 09:46:56 +0100
changeset 3499 512706514555
parent 3498 152daa6967af
child 3500 a43fdbd6f7eb
obsfate: fix changeset description diff computing Mercurial core 8b6dd3922f70 changed the mdiff.unidiff API. Add a new compat method for all supported Mercurial versions.
hgext3rd/evolve/compat.py
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/compat.py	Tue Jan 30 15:11:35 2018 +0530
+++ b/hgext3rd/evolve/compat.py	Wed Feb 14 09:46:56 2018 +0100
@@ -6,10 +6,13 @@
 Compatibility module
 """
 
+import inspect
+
 from mercurial import (
     copies,
     context,
     hg,
+    mdiff,
     obsolete,
     revset,
     util,
@@ -238,3 +241,16 @@
         cachevfs = vfsmod.vfs(repo.vfs.join('cache'))
         cachevfs.createmode = repo.store.createmode
     return cachevfs
+
+def strdiff(a, b, fn1, fn2):
+    """ A version of mdiff.unidiff for comparing two strings
+    """
+    args = [a, '', b, '', fn1, fn2]
+
+    # hg < 4.6 compat 8b6dd3922f70
+    argspec = inspect.getargspec(mdiff.unidiff)
+
+    if 'binary' in argspec.args:
+        args.append(False)
+
+    return mdiff.unidiff(*args)
--- a/hgext3rd/evolve/obshistory.py	Tue Jan 30 15:11:35 2018 +0530
+++ b/hgext3rd/evolve/obshistory.py	Wed Feb 14 09:46:56 2018 +0100
@@ -13,7 +13,6 @@
     commands,
     error,
     graphmod,
-    mdiff,
     patch,
     obsolete,
     node as nodemod,
@@ -172,7 +171,7 @@
     basename = "changeset-description"
     succname = "changeset-description"
 
-    d = mdiff.unidiff(basedesc, '', succdesc, '', basename, succname)
+    d = compat.strdiff(basedesc, succdesc, basename, succname)
     # mercurial 4.1 and before return the patch directly
     if not isinstance(d, tuple):
         patch = d