obslog: handle patch generation for mercurial 4.1-
The unidiff API changed, we detect and work around that.
--- 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):