comparison tests/test-diff-binary-file.t @ 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 3fbef7ac26f0
children 186f2afe9919
comparison
equal deleted inserted replaced
23923:ab6fd3205dad 23924:0db6810e84e8
7 $ echo >> binfile.bin 7 $ echo >> binfile.bin
8 $ hg ci -m 'change binfile.bin' 8 $ hg ci -m 'change binfile.bin'
9 9
10 $ hg revert -r 0 binfile.bin 10 $ hg revert -r 0 binfile.bin
11 $ hg ci -m 'revert binfile.bin' 11 $ hg ci -m 'revert binfile.bin'
12 $ hg cp binfile.bin nonbinfile
13 $ echo text > nonbinfile
14 $ hg ci -m 'make non-binary copy of binary file'
12 15
13 $ hg diff --nodates -r 0 -r 1 16 $ hg diff --nodates -r 0 -r 1
14 diff -r 48b371597640 -r acea2ab458c8 binfile.bin 17 diff -r 48b371597640 -r acea2ab458c8 binfile.bin
15 Binary file binfile.bin has changed 18 Binary file binfile.bin has changed
16 19
39 42
40 $ hg diff --config diff.nobinary=True --git -r 0 -r 1 43 $ hg diff --config diff.nobinary=True --git -r 0 -r 1
41 diff --git a/binfile.bin b/binfile.bin 44 diff --git a/binfile.bin b/binfile.bin
42 Binary file binfile.bin has changed 45 Binary file binfile.bin has changed
43 46
47 $ hg diff --git -r 2 -r 3
48 diff --git a/binfile.bin b/nonbinfile
49 copy from binfile.bin
50 copy to nonbinfile
51 index 37ba3d1c6f17137d9c5f5776fa040caf5fe73ff9..8e27be7d6154a1f68ea9160ef0e18691d20560dc
52 GIT binary patch
53 literal 5
54 Mc$_OqttjCF00uV!&;S4c
55
56
44 $ cd .. 57 $ cd ..