Mercurial > hg-stable
diff mercurial/mdiff.py @ 35990:8b6dd3922f70
patch: unify check_binary and binary flags
Follows up 079b27b5a869. If opts.text=True, check_binary is ignored, so we
can just pass the binary flag to unidiff().
perfunidiff now takes any inputs as text files, which I think is a desired
behavior.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 04 Feb 2018 10:28:03 +0900 |
parents | bdb6ec909878 |
children | 9e641c4525a2 |
line wrap: on
line diff
--- a/mercurial/mdiff.py Wed Feb 07 13:49:02 2018 +0530 +++ b/mercurial/mdiff.py Sun Feb 04 10:28:03 2018 +0900 @@ -236,7 +236,7 @@ yield s, type yield s1, '=' -def unidiff(a, ad, b, bd, fn1, fn2, opts=defaultopts, check_binary=True): +def unidiff(a, ad, b, bd, fn1, fn2, binary, opts=defaultopts): """Return a unified diff as a (headers, hunks) tuple. If the diff is not null, `headers` is a list with unified diff header @@ -244,8 +244,7 @@ (hunkrange, hunklines) coming from _unidiff(). Otherwise, `headers` and `hunks` are empty. - Setting `check_binary` to false will skip the binary check, i.e. when - it has been done in advance. Files are expected to be text in this case. + Set binary=True if either a or b should be taken as a binary file. """ def datetag(date, fn=None): if not opts.git and not opts.nodates: @@ -269,7 +268,7 @@ fn1 = util.pconvert(fn1) fn2 = util.pconvert(fn2) - if not opts.text and check_binary and (util.binary(a) or util.binary(b)): + if binary: if a and b and len(a) == len(b) and a == b: return sentinel headerlines = []