# HG changeset patch # User Jun Wu # Date 1494030032 25200 # Node ID 0c67ab3d77d5beac4ec61fb5fd92933bcc23b7e2 # Parent 15f10ee778f83a0c1e546ef7c16f01e008e0a719 diff: correct binary testing logic This seems to be more correct given the table drawn in the previous patch. Namely, "losedatafn" and "opts.git" are removed, "not opts.text" is added. - losedatafn: diff output (binary) should not be affected by "losedatafn" - opts.git: binary testing is helpful for detecting a fast path in the next path. the fast path can also be used if opts.git is False - opts.text: if it's set, we should treat the content as non-binary diff -r 15f10ee778f8 -r 0c67ab3d77d5 mercurial/patch.py --- a/mercurial/patch.py Fri May 05 16:48:58 2017 -0700 +++ b/mercurial/patch.py Fri May 05 17:20:32 2017 -0700 @@ -2540,9 +2540,9 @@ content2 = fctx2.data() if opts.git or losedatafn: flag2 = ctx2.flags(f2) - binary = False - if opts.git or losedatafn: - binary = any(f.isbinary() for f in [fctx1, fctx2] if f is not None) + # if binary is True, output "summary" or "base85", but not "text diff" + binary = not opts.text and any(f.isbinary() + for f in [fctx1, fctx2] if f is not None) if losedatafn and not opts.git: if (binary or @@ -2595,7 +2595,7 @@ # yes | yes * * * | text diff | yes # no | * * * * | text diff | yes # [1]: hash(fctx.data()) is outputted. so fctx.data() cannot be faked - if binary and opts.git and not opts.nobinary and not opts.text: + if binary and opts.git and not opts.nobinary: text = mdiff.b85diff(content1, content2) if text: header.append('index %s..%s' %