Mercurial > hg
changeset 30789:b8ad243f5ded
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.
author | Sean Farley <sean@farley.io> |
---|---|
date | Sat, 31 Dec 2016 15:41:57 -0600 |
parents | d1901c4c8ec0 |
children | dbcc10cf7f8d |
files | mercurial/patch.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Mon Jan 09 11:13:47 2017 -0800 +++ b/mercurial/patch.py Sat Dec 31 15:41:57 2016 -0600 @@ -2526,6 +2526,15 @@ 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)