changeset 2697:189fd9d6a405

obslog: handle patch generation for mercurial 4.1- The unidiff API changed, we detect and work around that.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 02 Jul 2017 17:13:35 +0200
parents a32afe67e8a6
children 6d48ad81e7b5 5d54de9cf50f
files hgext3rd/evolve/obshistory.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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):