Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 23924:0db6810e84e8 stable
diff: use binary diff when copy source is binary
When a binary source has been copied or renamed into a non-binary
file, we don't check whether the copy source was binary. There is a
code comment explaining that a git mode will be forced anyway in order
to capture the copy record (i.e. losedatafn() will be called). This is
true, but forcing git mode is not the only effect binary files have:
when git mode was already requested, we use the binary-ness to tell us
whether to use a regular unified diff or a git binary diff. The user
sees this as a "Binary file $file has changed" instead of the binary
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 17 Jan 2015 15:03:41 -0800 |
parents | ed645dc672e5 |
children | d8330fb8c44d |
comparison
equal
deleted
inserted
replaced
23923:ab6fd3205dad | 23924:0db6810e84e8 |
---|---|
1829 else: | 1829 else: |
1830 if opts.git: | 1830 if opts.git: |
1831 header.append('new file mode %s\n' % mode) | 1831 header.append('new file mode %s\n' % mode) |
1832 elif ctx2.flags(f): | 1832 elif ctx2.flags(f): |
1833 losedatafn(f) | 1833 losedatafn(f) |
1834 # In theory, if tn was copied or renamed we should check | 1834 if util.binary(to) or util.binary(tn): |
1835 # if the source is binary too but the copy record already | |
1836 # forces git mode. | |
1837 if util.binary(tn): | |
1838 if opts.git: | 1835 if opts.git: |
1839 binarydiff = True | 1836 binarydiff = True |
1840 else: | 1837 else: |
1841 losedatafn(f) | 1838 losedatafn(f) |
1842 if not opts.git and not tn: | 1839 if not opts.git and not tn: |