tests/test-clone-r
author David Greenaway <hg-dev@davidgreenaway.com>
Sat, 03 Apr 2010 11:58:16 +1100
changeset 11060 e6df01776e08
parent 3853 c0b449154a90
permissions -rwxr-xr-x
findrenames: Optimise "addremove -s100" by matching files by their SHA1 hashes. We speed up 'findrenames' for the usecase when a user specifies they want a similarity of 100% by matching files by their exact SHA1 hash value. This reduces the number of comparisons required to find exact matches from O(n^2) to O(n). While it would be nice if we could just use mercurial's pre-calculated SHA1 hash for existing files, this hash includes the file's ancestor information making it unsuitable for our purposes. Instead, we calculate the hash of old content from scratch. The following benchmarks were taken on the current head of crew: addremove 100% similarity: rm -rf *; hg up -C; mv tests tests.new hg --time addremove -s100 --dry-run before: real 176.350 secs (user 128.890+0.000 sys 47.430+0.000) after: real 2.130 secs (user 1.890+0.000 sys 0.240+0.000) addremove 75% similarity: rm -rf *; hg up -C; mv tests tests.new; \ for i in tests.new/*; do echo x >> $i; done hg --time addremove -s75 --dry-run before: real 264.560 secs (user 215.130+0.000 sys 49.410+0.000) after: real 218.710 secs (user 172.790+0.000 sys 45.870+0.000)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1886
d4a3a8a332ab remove bashisms from tests
TK Soh <teekaysoh@yahoo.com>
parents: 1468
diff changeset
     1
#!/bin/sh
1468
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     2
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     3
hg init test
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     4
cd test
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     5
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     6
0
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     7
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     8
hg add afile
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
     9
hg commit -m "0.0"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    10
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    11
1
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    12
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    13
hg commit -m "0.1"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    14
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    15
2
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    16
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    17
hg commit -m "0.2"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    18
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    19
3
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    20
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    21
hg commit -m "0.3"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    22
hg update -C 0
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    23
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    24
1
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    25
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    26
hg commit -m "1.1"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    27
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    28
2
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    29
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    30
hg commit -m "1.2"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    31
cat >fred <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    32
a line
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    33
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    34
cat >>afile <<EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    35
3
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    36
EOF
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    37
hg add fred
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    38
hg commit -m "1.3"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    39
hg mv afile adifferentfile
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    40
hg commit -m "1.3m"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    41
hg update -C 3
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    42
hg mv afile anotherfile
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    43
hg commit -m "0.3m"
3853
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1886
diff changeset
    44
hg debugindex .hg/store/data/afile.i
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1886
diff changeset
    45
hg debugindex .hg/store/data/adifferentfile.i
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1886
diff changeset
    46
hg debugindex .hg/store/data/anotherfile.i
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1886
diff changeset
    47
hg debugindex .hg/store/data/fred.i
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1886
diff changeset
    48
hg debugindex .hg/store/00manifest.i
1468
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    49
hg verify
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    50
cd ..
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    51
for i in 0 1 2 3 4 5 6 7 8; do
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    52
   hg clone -r "$i" test test-"$i"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    53
   cd test-"$i"
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    54
   hg verify
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    55
   cd ..
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    56
done
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    57
cd test-8
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    58
hg pull ../test-7
dc1bbc456b96 Added a test for clone -r.
Eric Hopper <hopper@omnifarious.org>
parents:
diff changeset
    59
hg verify