tests/test-grep
author Dirkjan Ochtman <dirkjan@ochtman.nl>
Fri, 06 Nov 2009 22:46:46 +0100
changeset 9731 0e080d519d1b
parent 9367 1ef630452e0b
child 10826 717c35d55fb3
permissions -rwxr-xr-x
hgweb: treat rev as raw-rev if user agent is hg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     1
#!/bin/sh
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     2
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     3
mkdir t
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     4
cd t
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     5
hg init
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     6
echo import > port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     7
hg add port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     8
hg commit -m 0 -u spam -d '0 0'
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
     9
echo export >> port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    10
hg commit -m 1 -u eggs -d '1 0'
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    11
echo export > port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    12
echo vaportight >> port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    13
echo 'import/export' >> port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    14
hg commit -m 2 -u spam -d '2 0'
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    15
echo 'import/export' >> port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    16
hg commit -m 3 -u eggs -d '3 0'
1539
5e47e42b14ba use posix compliant option for head
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1212
diff changeset
    17
head -n 3 port > port1
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    18
mv port1 port
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    19
hg commit -m 4 -u spam -d '4 0'
4877
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 3951
diff changeset
    20
echo % pattern error
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 3951
diff changeset
    21
hg grep '**test**'
3950
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2870
diff changeset
    22
echo % simple
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    23
hg grep port port
3950
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2870
diff changeset
    24
echo % all
9367
1ef630452e0b cmdutil: use context objects for walkchangerevs()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8897
diff changeset
    25
hg grep --traceback --all -nu port port
3950
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2870
diff changeset
    26
echo % other
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
diff changeset
    27
hg grep import port
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    28
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    29
hg cp port port2
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    30
hg commit -m 4 -u spam -d '5 0'
9367
1ef630452e0b cmdutil: use context objects for walkchangerevs()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8897
diff changeset
    31
echo % follow
1ef630452e0b cmdutil: use context objects for walkchangerevs()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8897
diff changeset
    32
hg grep --traceback -f 'import$' port2
2870
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    33
echo deport >> port2
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    34
hg commit -m 5 -u eggs -d '6 0'
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    35
hg grep -f --all -nu port port2
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    36
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    37
cd ..
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    38
hg init t2
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    39
cd t2
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    40
hg grep foobar foo
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    41
hg grep foobar
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    42
echo blue >> color
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    43
echo black >> color
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    44
hg add color
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7240
diff changeset
    45
hg ci -m 0
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    46
echo orange >> color
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7240
diff changeset
    47
hg ci -m 1
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    48
echo black > color
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7240
diff changeset
    49
hg ci -m 2
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    50
echo orange >> color
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    51
echo blue >> color
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7240
diff changeset
    52
hg ci -m 3
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    53
hg grep orange
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    54
hg grep --all orange
5106
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    55
7240
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    56
echo % match in last "line" without newline
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    57
python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    58
hg ci -Amnoeol
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    59
echo % last character omitted in output to avoid infinite loop
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    60
hg grep loop
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    61
5106
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    62
# Got a traceback when using grep on a single
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    63
# revision with renamed files.
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    64
cd ..
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    65
echo % issue 685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    66
hg init issue685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    67
cd issue685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    68
echo octarine > color
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    69
hg ci -Amcolor
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    70
hg rename color colour
5107
0edea751bbb2 test-grep: use lowercase hg command
Matt Mackall <mpm@selenic.com>
parents: 5106
diff changeset
    71
hg ci -Am rename
5106
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    72
hg grep octarine
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    73
# Used to crash here
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    74
hg grep -r 1 octarine
7240
dac14cc9711e test 261a9f47b44b: grep w/ match in last line w/o newline
Christian Ebert <blacktrash@gmx.net>
parents: 5107
diff changeset
    75
8897
aa78a0583731 test-grep: fixed comment
Martin Geisler <mg@lazybytes.net>
parents: 8849
diff changeset
    76
# Issue337: test that grep follows parent-child relationships instead
aa78a0583731 test-grep: fixed comment
Martin Geisler <mg@lazybytes.net>
parents: 8849
diff changeset
    77
# of just using revision numbers.
8849
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    78
cd ..
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    79
echo % issue 337
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    80
hg init issue337
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    81
cd issue337
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    82
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    83
echo white > color
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    84
hg commit -A -m "0 white"
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    85
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    86
echo red > color
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    87
hg commit -A -m "1 red"
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    88
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    89
hg update 0
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    90
echo black > color
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    91
hg commit -A -m "2 black"
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    92
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    93
hg update --clean 1
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    94
echo blue > color
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    95
hg commit -A -m "3 blue"
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    96
80cc4b1a62d0 compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 8167
diff changeset
    97
hg grep --all red