annotate tests/test-diff-binary-file @ 4135:6cb6cfe43c5d

Avoid some false positives for addremove -s The original code uses the similary score 1 - len(diff(after, before)) / len(after) The diff can at most be the size of the 'before' file, so any small 'before' file would be considered very similar. Removing an empty file would cause all files added in the same revision to be considered copies of the removed file. This changes the metric to bytes_overlap(before, after) / len(before + after) i.e. the actual percentage of bytes shared between the two files.
author Erling Ellingsen <erlingalf@gmail.com>
date Sun, 18 Feb 2007 20:39:25 +0100
parents 0934fef871f3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4103
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
1 #!/bin/sh
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
2
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
3 hg init a
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
4 cd a
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
5 cp $TESTDIR/binfile.bin .
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
6 hg add binfile.bin
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
7 hg ci -m 'add binfile.bin' -d '0 0'
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
8
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
9 echo >> binfile.bin
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
10 hg ci -m 'change binfile.bin' -d '0 0'
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
11
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
12 hg revert -r 0 binfile.bin
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
13 hg ci -m 'revert binfile.bin' -d '0 0'
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
14
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
15 echo % diff -r 0 -r 1
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
16 hg diff --nodates -r 0 -r 1
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
17
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
18 echo % diff -r 0 -r 2
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
19 hg diff --nodates -r 0 -r 2
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
20
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
21 echo % diff --git -r 0 -r 1
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
22 hg diff --git -r 0 -r 1
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
23
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
24 echo % diff --git -r 0 -r 2
0934fef871f3 add test for diffing identical binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
25 hg diff --git -r 0 -r 2