Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 35890:079b27b5a869
patch: avoid repeated binary checks if all files in a patch are text
Differential Revision: https://phab.mercurial-scm.org/D1940
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 25 Jan 2018 22:40:19 +0100 |
parents | a981ab2a1b4c |
children | c8e2d6ed1f9e |
comparison
equal
deleted
inserted
replaced
35889:5cfdf6137af8 | 35890:079b27b5a869 |
---|---|
2696 if f2: | 2696 if f2: |
2697 fctx2 = getfilectx(f2, ctx2) | 2697 fctx2 = getfilectx(f2, ctx2) |
2698 if opts.git or losedatafn: | 2698 if opts.git or losedatafn: |
2699 flag2 = ctx2.flags(f2) | 2699 flag2 = ctx2.flags(f2) |
2700 # if binary is True, output "summary" or "base85", but not "text diff" | 2700 # if binary is True, output "summary" or "base85", but not "text diff" |
2701 binary = not opts.text and any(f.isbinary() | 2701 if opts.text: |
2702 for f in [fctx1, fctx2] if f is not None) | 2702 check_binary = True |
2703 binary = False | |
2704 else: | |
2705 check_binary = any(f.isbinary() | |
2706 for f in [fctx1, fctx2] if f is not None) | |
2707 binary = check_binary | |
2703 | 2708 |
2704 if losedatafn and not opts.git: | 2709 if losedatafn and not opts.git: |
2705 if (binary or | 2710 if (binary or |
2706 # copy/rename | 2711 # copy/rename |
2707 f2 in copy or | 2712 f2 in copy or |
2787 gitindex(content2)[0:opts.index], | 2792 gitindex(content2)[0:opts.index], |
2788 gitmode[flag])) | 2793 gitmode[flag])) |
2789 | 2794 |
2790 uheaders, hunks = mdiff.unidiff(content1, date1, | 2795 uheaders, hunks = mdiff.unidiff(content1, date1, |
2791 content2, date2, | 2796 content2, date2, |
2792 path1, path2, opts=opts) | 2797 path1, path2, opts=opts, |
2798 check_binary=check_binary) | |
2793 header.extend(uheaders) | 2799 header.extend(uheaders) |
2794 yield fctx1, fctx2, header, hunks | 2800 yield fctx1, fctx2, header, hunks |
2795 | 2801 |
2796 def diffstatsum(stats): | 2802 def diffstatsum(stats): |
2797 maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False | 2803 maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False |