##// END OF EJS Templates
patch: unify check_binary and binary flags...
Yuya Nishihara -
r35969:8b6dd392 default
parent child Browse files
Show More
@@ -1088,7 +1088,7 b' def perfunidiff(ui, repo, file_, rev=Non'
1088 1088 for left, right in textpairs:
1089 1089 # The date strings don't matter, so we pass empty strings.
1090 1090 headerlines, hunks = mdiff.unidiff(
1091 left, '', right, '', 'left', 'right')
1091 left, '', right, '', 'left', 'right', binary=False)
1092 1092 # consume iterators in roughly the way patch.py does
1093 1093 b'\n'.join(headerlines)
1094 1094 b''.join(sum((list(hlines) for hrange, hlines in hunks), []))
@@ -236,7 +236,7 b' def allblocks(text1, text2, opts=None, l'
236 236 yield s, type
237 237 yield s1, '='
238 238
239 def unidiff(a, ad, b, bd, fn1, fn2, opts=defaultopts, check_binary=True):
239 def unidiff(a, ad, b, bd, fn1, fn2, binary, opts=defaultopts):
240 240 """Return a unified diff as a (headers, hunks) tuple.
241 241
242 242 If the diff is not null, `headers` is a list with unified diff header
@@ -244,8 +244,7 b' def unidiff(a, ad, b, bd, fn1, fn2, opts'
244 244 (hunkrange, hunklines) coming from _unidiff().
245 245 Otherwise, `headers` and `hunks` are empty.
246 246
247 Setting `check_binary` to false will skip the binary check, i.e. when
248 it has been done in advance. Files are expected to be text in this case.
247 Set binary=True if either a or b should be taken as a binary file.
249 248 """
250 249 def datetag(date, fn=None):
251 250 if not opts.git and not opts.nodates:
@@ -269,7 +268,7 b' def unidiff(a, ad, b, bd, fn1, fn2, opts'
269 268 fn1 = util.pconvert(fn1)
270 269 fn2 = util.pconvert(fn2)
271 270
272 if not opts.text and check_binary and (util.binary(a) or util.binary(b)):
271 if binary:
273 272 if a and b and len(a) == len(b) and a == b:
274 273 return sentinel
275 274 headerlines = []
@@ -2699,12 +2699,9 b' def trydiff(repo, revs, ctx1, ctx2, modi'
2699 2699 flag2 = ctx2.flags(f2)
2700 2700 # if binary is True, output "summary" or "base85", but not "text diff"
2701 2701 if opts.text:
2702 check_binary = True
2703 2702 binary = False
2704 2703 else:
2705 check_binary = any(f.isbinary()
2706 for f in [fctx1, fctx2] if f is not None)
2707 binary = check_binary
2704 binary = any(f.isbinary() for f in [fctx1, fctx2] if f is not None)
2708 2705
2709 2706 if losedatafn and not opts.git:
2710 2707 if (binary or
@@ -2794,8 +2791,8 b' def trydiff(repo, revs, ctx1, ctx2, modi'
2794 2791
2795 2792 uheaders, hunks = mdiff.unidiff(content1, date1,
2796 2793 content2, date2,
2797 path1, path2, opts=opts,
2798 check_binary=check_binary)
2794 path1, path2,
2795 binary=binary, opts=opts)
2799 2796 header.extend(uheaders)
2800 2797 yield fctx1, fctx2, header, hunks
2801 2798
General Comments 0
You need to be logged in to leave comments. Login now