Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 31281:b3861be6aa6c
mdiff: distinguish diff headers from hunks in unidiff()
Let unidiff return the list of headers it produces (lines '--- <original>' and
'+++ <new>') apart from diff hunks. In patch.diff(), we combine headers
generated there (not specific to unified format) with those from unidiff().
By returning a list of header lines, we do not append new lines in datetag
inner function of unidiff() so that all header lines are '\n'.join-ed in a
similar way.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Fri, 03 Mar 2017 13:51:22 +0100 |
parents | 067f2a95e32c |
children | 92714858dd3e |
comparison
equal
deleted
inserted
replaced
31280:59aec562a50b | 31281:b3861be6aa6c |
---|---|
2547 header.append('index %s..%s %s' % | 2547 header.append('index %s..%s %s' % |
2548 (gitindex(content1)[0:opts.index], | 2548 (gitindex(content1)[0:opts.index], |
2549 gitindex(content2)[0:opts.index], | 2549 gitindex(content2)[0:opts.index], |
2550 gitmode[flag])) | 2550 gitmode[flag])) |
2551 | 2551 |
2552 text = mdiff.unidiff(content1, date1, | 2552 uheaders, text = mdiff.unidiff(content1, date1, |
2553 content2, date2, | 2553 content2, date2, |
2554 path1, path2, opts=opts) | 2554 path1, path2, opts=opts) |
2555 header.extend(uheaders) | |
2555 if header and (text or len(header) > 1): | 2556 if header and (text or len(header) > 1): |
2556 yield '\n'.join(header) + '\n' | 2557 yield '\n'.join(header) + '\n' |
2557 if text: | 2558 if text: |
2558 yield text | 2559 yield text |
2559 | 2560 |