# HG changeset patch # User Sean Farley # Date 2016-12-31 21:41:57 # Node ID b8ad243f5ded9ba56d3f1a64d4d1008dbdb6701a # Parent d1901c4c8ec016110ba09d1b9ce409973758caf7 patch: add index line for diff output This helps highlighting in third-party diff coloring (which assumes git output) and maintains pedantic correctness with diff --git. Tests will be added at the end of the series. diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2526,6 +2526,15 @@ def trydiff(repo, revs, ctx1, ctx2, modi header.append('index %s..%s' % (gitindex(content1), gitindex(content2))) else: + if opts.git and opts.index > 0: + flag = flag1 + if flag is None: + flag = flag2 + header.append('index %s..%s %s' % + (gitindex(content1)[0:opts.index], + gitindex(content2)[0:opts.index], + gitmode[flag])) + text = mdiff.unidiff(content1, date1, content2, date2, path1, path2, opts=opts)