Mercurial > hg > mercurial-crew-with-dirclash
annotate tests/test-transplant @ 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 | 75313c36aa04 |
children | e3a0c092b4e2 |
rev | line source |
---|---|
3714 | 1 #!/bin/sh |
2 | |
3 cat <<EOF >> $HGRCPATH | |
4 [extensions] | |
5 transplant= | |
6 EOF | |
7 | |
8 hg init t | |
9 cd t | |
10 echo r1 > r1 | |
11 hg ci -Amr1 -d'0 0' | |
12 echo r2 > r2 | |
13 hg ci -Amr2 -d'1 0' | |
14 hg up 0 | |
15 | |
16 echo b1 > b1 | |
17 hg ci -Amb1 -d '0 0' | |
18 echo b2 > b2 | |
19 hg ci -Amb2 -d '1 0' | |
20 echo b3 > b3 | |
21 hg ci -Amb3 -d '2 0' | |
22 | |
23 hg log --template '{rev} {parents} {desc}\n' | |
24 | |
4034
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
25 hg clone . ../rebase |
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
26 cd ../rebase |
3714 | 27 |
28 hg up -C 1 | |
29 echo '% rebase b onto r1' | |
30 hg transplant -a -b tip | |
31 hg log --template '{rev} {parents} {desc}\n' | |
32 | |
4034
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
33 hg clone ../t ../prune |
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
34 cd ../prune |
3714 | 35 |
36 hg up -C 1 | |
37 echo '% rebase b onto r1, skipping b2' | |
38 hg transplant -a -b tip -p 3 | |
39 hg log --template '{rev} {parents} {desc}\n' | |
40 | |
41 echo '% remote transplant' | |
4034
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
42 hg clone -r 1 ../t ../remote |
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
43 cd ../remote |
3714 | 44 hg transplant --log -s ../t 2 4 |
45 hg log --template '{rev} {parents} {desc}\n' | |
46 | |
47 echo '% skip previous transplants' | |
48 hg transplant -s ../t -a -b 4 | |
49 hg log --template '{rev} {parents} {desc}\n' | |
50 | |
51 echo '% skip local changes transplanted to the source' | |
52 echo b4 > b4 | |
53 hg ci -Amb4 -d '3 0' | |
4034
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
54 hg clone ../t ../pullback |
9bd078ce8de9
Minor test-transplant cleanup
Brendan Cully <brendan@kublai.com>
parents:
3758
diff
changeset
|
55 cd ../pullback |
3714 | 56 hg transplant -s ../remote -a -b tip |
3724
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
57 |
4036
ebf1a05f6479
Make test-transplant test pull case
Brendan Cully <brendan@kublai.com>
parents:
4034
diff
changeset
|
58 echo '% remote transplant with pull' |
4050
75313c36aa04
transplant: test non-local source
Brendan Cully <brendan@kublai.com>
parents:
4036
diff
changeset
|
59 hg -R ../t serve -p 20062 -d --pid-file=../t.pid |
75313c36aa04
transplant: test non-local source
Brendan Cully <brendan@kublai.com>
parents:
4036
diff
changeset
|
60 cat ../t.pid >> $DAEMON_PIDS |
75313c36aa04
transplant: test non-local source
Brendan Cully <brendan@kublai.com>
parents:
4036
diff
changeset
|
61 |
4036
ebf1a05f6479
Make test-transplant test pull case
Brendan Cully <brendan@kublai.com>
parents:
4034
diff
changeset
|
62 hg clone -r 0 ../t ../rp |
ebf1a05f6479
Make test-transplant test pull case
Brendan Cully <brendan@kublai.com>
parents:
4034
diff
changeset
|
63 cd ../rp |
4050
75313c36aa04
transplant: test non-local source
Brendan Cully <brendan@kublai.com>
parents:
4036
diff
changeset
|
64 hg transplant -s http://localhost:20062/ 2 4 |
4036
ebf1a05f6479
Make test-transplant test pull case
Brendan Cully <brendan@kublai.com>
parents:
4034
diff
changeset
|
65 hg log --template '{rev} {parents} {desc}\n' |
ebf1a05f6479
Make test-transplant test pull case
Brendan Cully <brendan@kublai.com>
parents:
4034
diff
changeset
|
66 |
3724
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
67 echo '% transplant --continue' |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
68 hg init ../tc |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
69 cd ../tc |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
70 cat <<EOF > foo |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
71 foo |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
72 bar |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
73 baz |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
74 EOF |
3726
752884db5037
transplant: recover added/removed files after failed application
Brendan Cully <brendan@kublai.com>
parents:
3724
diff
changeset
|
75 echo toremove > toremove |
3724
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
76 hg ci -Amfoo -d '0 0' |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
77 cat <<EOF > foo |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
78 foo2 |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
79 bar2 |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
80 baz2 |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
81 EOF |
3726
752884db5037
transplant: recover added/removed files after failed application
Brendan Cully <brendan@kublai.com>
parents:
3724
diff
changeset
|
82 rm toremove |
752884db5037
transplant: recover added/removed files after failed application
Brendan Cully <brendan@kublai.com>
parents:
3724
diff
changeset
|
83 echo added > added |
752884db5037
transplant: recover added/removed files after failed application
Brendan Cully <brendan@kublai.com>
parents:
3724
diff
changeset
|
84 hg ci -Amfoo2 -d '0 0' |
3724
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
85 echo bar > bar |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
86 hg ci -Ambar -d '0 0' |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
87 echo bar2 >> bar |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
88 hg ci -mbar2 -d '0 0' |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
89 hg up 0 |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
90 echo foobar > foo |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
91 hg ci -mfoobar -d '0 0' |
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
92 hg transplant 1:3 |
3758
889f7e74a0d9
transplant: log source node when recovering too.
Brendan Cully <brendan@kublai.com>
parents:
3726
diff
changeset
|
93 # transplant -c shouldn't use an old changeset |
889f7e74a0d9
transplant: log source node when recovering too.
Brendan Cully <brendan@kublai.com>
parents:
3726
diff
changeset
|
94 hg up -C |
889f7e74a0d9
transplant: log source node when recovering too.
Brendan Cully <brendan@kublai.com>
parents:
3726
diff
changeset
|
95 hg transplant 1 |
3724
ea523d6f5f1a
transplant: fix --continue; add --continue test
Brendan Cully <brendan@kublai.com>
parents:
3714
diff
changeset
|
96 hg transplant --continue |
3758
889f7e74a0d9
transplant: log source node when recovering too.
Brendan Cully <brendan@kublai.com>
parents:
3726
diff
changeset
|
97 hg transplant 1:3 |
3726
752884db5037
transplant: recover added/removed files after failed application
Brendan Cully <brendan@kublai.com>
parents:
3724
diff
changeset
|
98 hg locate |