Mercurial > hg
comparison tests/test-grep.t @ 11902:3c9a5ed9b1e2
tests: unify test-grep
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Mon, 16 Aug 2010 02:03:29 +0900 |
parents | tests/test-grep@df5d1d571d27 |
children | 4134686b83e1 |
comparison
equal
deleted
inserted
replaced
11901:a80577bfea29 | 11902:3c9a5ed9b1e2 |
---|---|
1 $ mkdir t | |
2 $ cd t | |
3 $ hg init | |
4 $ echo import > port | |
5 $ hg add port | |
6 $ hg commit -m 0 -u spam -d '0 0' | |
7 $ echo export >> port | |
8 $ hg commit -m 1 -u eggs -d '1 0' | |
9 $ echo export > port | |
10 $ echo vaportight >> port | |
11 $ echo 'import/export' >> port | |
12 $ hg commit -m 2 -u spam -d '2 0' | |
13 $ echo 'import/export' >> port | |
14 $ hg commit -m 3 -u eggs -d '3 0' | |
15 $ head -n 3 port > port1 | |
16 $ mv port1 port | |
17 $ hg commit -m 4 -u spam -d '4 0' | |
18 | |
19 pattern error | |
20 | |
21 $ hg grep '**test**' | |
22 grep: invalid match pattern: nothing to repeat | |
23 | |
24 simple | |
25 | |
26 $ hg grep port port | |
27 port:4:export | |
28 port:4:vaportight | |
29 port:4:import/export | |
30 | |
31 simple with color | |
32 | |
33 $ hg --config extensions.color= grep --config color.mode=ansi \ | |
34 > --color=always port port | |
35 port:4:ex[0;31;1mport[0m | |
36 port:4:va[0;31;1mport[0might | |
37 port:4:im[0;31;1mport[0m/export | |
38 | |
39 all | |
40 | |
41 $ hg grep --traceback --all -nu port port | |
42 port:4:4:-:spam:import/export | |
43 port:3:4:+:eggs:import/export | |
44 port:2:1:-:spam:import | |
45 port:2:2:-:spam:export | |
46 port:2:1:+:spam:export | |
47 port:2:2:+:spam:vaportight | |
48 port:2:3:+:spam:import/export | |
49 port:1:2:+:eggs:export | |
50 port:0:1:+:spam:import | |
51 | |
52 other | |
53 | |
54 $ hg grep import port | |
55 port:4:import/export | |
56 | |
57 $ hg cp port port2 | |
58 $ hg commit -m 4 -u spam -d '5 0' | |
59 | |
60 follow | |
61 | |
62 $ hg grep --traceback -f 'import$' port2 | |
63 port:0:import | |
64 $ echo deport >> port2 | |
65 $ hg commit -m 5 -u eggs -d '6 0' | |
66 $ hg grep -f --all -nu port port2 | |
67 port2:6:4:+:eggs:deport | |
68 port:4:4:-:spam:import/export | |
69 port:3:4:+:eggs:import/export | |
70 port:2:1:-:spam:import | |
71 port:2:2:-:spam:export | |
72 port:2:1:+:spam:export | |
73 port:2:2:+:spam:vaportight | |
74 port:2:3:+:spam:import/export | |
75 port:1:2:+:eggs:export | |
76 port:0:1:+:spam:import | |
77 | |
78 $ cd .. | |
79 $ hg init t2 | |
80 $ cd t2 | |
81 $ hg grep foobar foo | |
82 $ hg grep foobar | |
83 $ echo blue >> color | |
84 $ echo black >> color | |
85 $ hg add color | |
86 $ hg ci -m 0 | |
87 $ echo orange >> color | |
88 $ hg ci -m 1 | |
89 $ echo black > color | |
90 $ hg ci -m 2 | |
91 $ echo orange >> color | |
92 $ echo blue >> color | |
93 $ hg ci -m 3 | |
94 $ hg grep orange | |
95 color:3:orange | |
96 $ hg grep --all orange | |
97 color:3:+:orange | |
98 color:2:-:orange | |
99 color:1:+:orange | |
100 | |
101 | |
102 match in last "line" without newline | |
103 | |
104 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();' | |
105 $ hg ci -Amnoeol | |
106 adding noeol | |
107 | |
108 last character omitted in output to avoid infinite loop | |
109 | |
110 $ hg grep loop | |
111 noeol:4:no infinite loo | |
112 | |
113 | |
114 $ cd .. | |
115 | |
116 Got a traceback when using grep on a single | |
117 revision with renamed files. | |
118 issue 685 | |
119 | |
120 $ hg init issue685 | |
121 $ cd issue685 | |
122 $ echo octarine > color | |
123 $ hg ci -Amcolor | |
124 adding color | |
125 $ hg rename color colour | |
126 $ hg ci -Am rename | |
127 $ hg grep octarine | |
128 colour:1:octarine | |
129 color:0:octarine | |
130 | |
131 Used to crash here | |
132 | |
133 $ hg grep -r 1 octarine | |
134 colour:1:octarine | |
135 $ cd .. | |
136 | |
137 | |
138 Issue337: test that grep follows parent-child relationships instead | |
139 of just using revision numbers. | |
140 | |
141 $ hg init issue337 | |
142 $ cd issue337 | |
143 | |
144 $ echo white > color | |
145 $ hg commit -A -m "0 white" | |
146 adding color | |
147 | |
148 $ echo red > color | |
149 $ hg commit -A -m "1 red" | |
150 | |
151 $ hg update 0 | |
152 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
153 $ echo black > color | |
154 $ hg commit -A -m "2 black" | |
155 created new head | |
156 | |
157 $ hg update --clean 1 | |
158 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
159 $ echo blue > color | |
160 $ hg commit -A -m "3 blue" | |
161 | |
162 $ hg grep --all red | |
163 color:3:-:red | |
164 color:1:+:red |