tests/test-grep
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 17 Aug 2007 20:18:05 -0300
changeset 5195 33015dac5df5
parent 5107 0edea751bbb2
child 7240 dac14cc9711e
permissions -rwxr-xr-x
convert: fix mercurial_sink.putcommit Changeset 4ebc8693ce72 added some code to putcommit to avoid creating a revision that touches no files, but this can break regular conversions from some repositories: - conceptually, since we're converting a repo, we should try to make the new hg repo as similar as possible to the original repo - we should create a new changeset, even if the original revision didn't touch any files (maybe the commit message had some important bit); - even if a "regular" revision that doesn't touch any file may seem weird (and maybe even broken), it's completely legitimate for a merge revision to not touch any file, and, if we just skip it, the converted repo will end up with wrong history and possibly an extra head. As an example, say the crew and main hg repos are sync'ed. Somebody sends an important patch to the mailing list. Matt quickly applies and pushes it. But at the same time somebody also applies it to crew and pushes it. Suppose the commit message ended up being a bit different (say, there was a typo and somebody didn't fix it) or that the date ended up being different (because of different patch-applying scripts): the changeset hashes will be different, but the manifests will be the same. Since both changesets were pushed to public repos, it's hard to recall them. If both are merged, the manifest from the resulting merge revision will have the exact same contents as its parents - i.e. the merge revision really doesn't touch any file at all. To keep the file filtering stuff "working", the generic code was changed to skip empty revisions if we're filtering the repo, fixing a bug in the process (we want parents[0] instead of tip).
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
1212
ccb6201e3f28 Change grep -e to grep --all
mpm@selenic.com
parents: 1167
diff changeset
    25
hg grep --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'
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    31
echo '% follow'
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2869
diff changeset
    32
hg grep -f 'import$' port2
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
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    45
hg ci -m 0 -d '0 0'
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    46
echo orange >> color
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    47
hg ci -m 1 -d '0 0'
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    48
echo black > color
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    49
hg ci -m 2 -d '0 0'
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
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
    52
hg ci -m 3 -d '0 0'
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
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    56
# Got a traceback when using grep on a single
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    57
# revision with renamed files.
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    58
cd ..
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    59
echo % issue 685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    60
hg init issue685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    61
cd issue685
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    62
echo octarine > color
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    63
hg ci -Amcolor
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    64
hg rename color colour
5107
0edea751bbb2 test-grep: use lowercase hg command
Matt Mackall <mpm@selenic.com>
parents: 5106
diff changeset
    65
hg ci -Am rename
5106
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    66
hg grep octarine
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    67
# Used to crash here
ee702e7f181f test-grep: test issue 685
Patrick Mezard <pmezard@gmail.com>
parents: 4877
diff changeset
    68
hg grep -r 1 octarine