Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/patch.py Fri Mar 03 16:17:17 2017 +0100 +++ b/mercurial/patch.py Fri Mar 03 13:51:22 2017 +0100 @@ -2549,9 +2549,10 @@ gitindex(content2)[0:opts.index], gitmode[flag])) - text = mdiff.unidiff(content1, date1, - content2, date2, - path1, path2, opts=opts) + uheaders, text = mdiff.unidiff(content1, date1, + content2, date2, + path1, path2, opts=opts) + header.extend(uheaders) if header and (text or len(header) > 1): yield '\n'.join(header) + '\n' if text: