Mercurial > public > mercurial-scm > hg
comparison mercurial/patch.py @ 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 |
comparison
equal
deleted
inserted
replaced
30788:d1901c4c8ec0 | 30789:b8ad243f5ded |
---|---|
2524 text = mdiff.b85diff(content1, content2) | 2524 text = mdiff.b85diff(content1, content2) |
2525 if text: | 2525 if text: |
2526 header.append('index %s..%s' % | 2526 header.append('index %s..%s' % |
2527 (gitindex(content1), gitindex(content2))) | 2527 (gitindex(content1), gitindex(content2))) |
2528 else: | 2528 else: |
2529 if opts.git and opts.index > 0: | |
2530 flag = flag1 | |
2531 if flag is None: | |
2532 flag = flag2 | |
2533 header.append('index %s..%s %s' % | |
2534 (gitindex(content1)[0:opts.index], | |
2535 gitindex(content2)[0:opts.index], | |
2536 gitmode[flag])) | |
2537 | |
2529 text = mdiff.unidiff(content1, date1, | 2538 text = mdiff.unidiff(content1, date1, |
2530 content2, date2, | 2539 content2, date2, |
2531 path1, path2, opts=opts) | 2540 path1, path2, opts=opts) |
2532 if header and (text or len(header) > 1): | 2541 if header and (text or len(header) > 1): |
2533 yield '\n'.join(header) + '\n' | 2542 yield '\n'.join(header) + '\n' |