obslog: handle patch generation for mercurial 4.1-
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 02 Jul 2017 17:13:35 +0200
changeset 2697 189fd9d6a405
parent 2696 a32afe67e8a6
child 2698 6d48ad81e7b5
child 2709 5d54de9cf50f
obslog: handle patch generation for mercurial 4.1- The unidiff API changed, we detect and work around that.
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Sun Jul 02 16:39:48 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py	Sun Jul 02 17:13:35 2017 +0200
@@ -172,11 +172,15 @@
     succname = "%s-changeset-description" % succctx
 
     d = mdiff.unidiff(basedesc, '', succdesc, '', basename, succname)
-    uheaders, hunks = d
+    # mercurial 4.1 and before return the patch directly
+    if not isinstance(d, tuple):
+        patch = d
+    else:
+        uheaders, hunks = d
 
-    # Copied from patch.diff
-    text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
-    patch = "\n".join(uheaders + [text])
+        # Copied from patch.diff
+        text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
+        patch = "\n".join(uheaders + [text])
     return _indent(patch)
 
 class missingchangectx(object):