tests/test-annotate
author David Greenaway <hg-dev@davidgreenaway.com>
Sat, 03 Apr 2010 11:58:16 +1100
changeset 11060 e6df01776e08
parent 10369 98a0421b9e52
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:
2923
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     1
#!/bin/sh
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     2
4365
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3405
diff changeset
     3
HGMERGE=true; export HGMERGE
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3405
diff changeset
     4
2923
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     5
echo % init
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     6
hg init
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     7
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     8
echo % commit
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
     9
echo 'a' > a
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    10
hg ci -A -m test -u nobody -d '1 0'
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    11
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    12
echo % annotate -c
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    13
hg annotate -c a
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    14
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    15
echo % annotate -cl
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    16
hg annotate -cl a
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    17
2923
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    18
echo % annotate -d
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    19
hg annotate -d a
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    20
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    21
echo % annotate -n
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    22
hg annotate -n a
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    23
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    24
echo % annotate -nl
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    25
hg annotate -nl a
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    26
2923
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    27
echo % annotate -u
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    28
hg annotate -u a
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    29
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    30
echo % annotate -cdnu
cd47230a4eb9 tests: new test for "hg annotate"
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
diff changeset
    31
hg annotate -cdnu a
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    32
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    33
echo % annotate -cdnul
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    34
hg annotate -cdnul a
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    35
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    36
cat <<EOF >>a
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    37
a
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    38
a
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    39
EOF
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    40
hg ci -ma1 -d '1 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    41
hg cp a b
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    42
hg ci -mb -d '1 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    43
cat <<EOF >> b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    44
b4
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    45
b5
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    46
b6
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    47
EOF
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    48
hg ci -mb2 -d '2 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    49
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    50
echo % annotate -n b
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    51
hg annotate -n b
10369
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 4857
diff changeset
    52
echo % annotate --no-follow b
98a0421b9e52 commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 4857
diff changeset
    53
hg annotate --no-follow b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    54
echo % annotate -nl b
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    55
hg annotate -nl b
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    56
echo % annotate -nf b
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    57
hg annotate -nf b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    58
echo % annotate -nlf b
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    59
hg annotate -nlf b
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    60
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    61
hg up -C 2
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    62
cat <<EOF >> b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    63
b4
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    64
c
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    65
b5
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    66
EOF
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    67
hg ci -mb2.1 -d '2 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    68
hg merge
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    69
hg ci -mmergeb -d '3 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    70
echo % annotate after merge
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    71
hg annotate -nf b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    72
echo % annotate after merge with -l
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    73
hg annotate -nlf b
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    74
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    75
hg up -C 1
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    76
hg cp a b
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    77
cat <<EOF > b
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    78
a
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    79
z
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    80
a
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    81
EOF
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    82
hg ci -mc -d '3 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    83
hg merge
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    84
cat <<EOF >> b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    85
b4
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    86
c
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    87
b5
3172
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    88
EOF
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    89
echo d >> b
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    90
hg ci -mmerge2 -d '4 0'
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    91
echo % annotate after rename merge
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 2925
diff changeset
    92
hg annotate -nf b
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    93
echo % annotate after rename merge with -l
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    94
hg annotate -nlf b
3405
2e1d8b238b6c Test annotate using named rev instead of linkrev
Brendan Cully <brendan@kublai.com>
parents: 3202
diff changeset
    95
2e1d8b238b6c Test annotate using named rev instead of linkrev
Brendan Cully <brendan@kublai.com>
parents: 3202
diff changeset
    96
echo % linkrev vs rev
4857
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    97
hg annotate -r tip -n a
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    98
echo % linkrev vs rev with -l
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4659
diff changeset
    99
hg annotate -r tip -nl a
4639
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   100
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   101
# test issue 589
4659
7a7d4937272b Kill trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4640
diff changeset
   102
# annotate was crashing when trying to --follow something
4639
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   103
# like A -> B -> A
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   104
echo % generate ABA rename configuration
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   105
echo foo > foo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   106
hg add foo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   107
hg ci -m addfoo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   108
hg rename foo bar
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   109
hg ci -m renamefoo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   110
hg rename bar foo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   111
hg ci -m renamebar
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   112
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   113
echo % annotate after ABA with follow
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   114
hg annotate --follow foo
c7371aa0c153 test-annotate: add a test for issue 589.
Patrick Mezard <pmezard@gmail.com>
parents: 3405
diff changeset
   115