comparison mercurial/patch.py @ 31273:92714858dd3e

mdiff: let unidiff return (diffheader, hunks) This will be used to make it possible to filter diff hunks based on this range information. Now unidiff returns a 'hunks' generator that yield tuple (hunkrange, hunklines) coming from _unidiff() with 'newline at end of file' processing.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 03 Mar 2017 17:46:40 +0100
parents b3861be6aa6c
children a8023a64c40d
comparison
equal deleted inserted replaced
31272:e41946f39724 31273:92714858dd3e
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 uheaders, text = mdiff.unidiff(content1, date1, 2552 uheaders, hunks = 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 header.extend(uheaders)
2556 text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
2556 if header and (text or len(header) > 1): 2557 if header and (text or len(header) > 1):
2557 yield '\n'.join(header) + '\n' 2558 yield '\n'.join(header) + '\n'
2558 if text: 2559 if text:
2559 yield text 2560 yield text
2560 2561