Show More
@@ -1,735 +1,730 b'' | |||
|
1 | 1 | $ hg init t |
|
2 | 2 | $ cd t |
|
3 | 3 | $ echo import > port |
|
4 | 4 | $ hg add port |
|
5 | 5 | $ hg commit -m 0 -u spam -d '0 0' |
|
6 | 6 | $ echo export >> port |
|
7 | 7 | $ hg commit -m 1 -u eggs -d '1 0' |
|
8 | 8 | $ echo export > port |
|
9 | 9 | $ echo vaportight >> port |
|
10 | 10 | $ echo 'import/export' >> port |
|
11 | 11 | $ hg commit -m 2 -u spam -d '2 0' |
|
12 | 12 | $ echo 'import/export' >> port |
|
13 | 13 | $ hg commit -m 3 -u eggs -d '3 0' |
|
14 | 14 | $ head -n 3 port > port1 |
|
15 | 15 | $ mv port1 port |
|
16 | 16 | $ hg commit -m 4 -u spam -d '4 0' |
|
17 | 17 | |
|
18 | 18 | pattern error |
|
19 | 19 | |
|
20 | 20 | $ hg grep '**test**' |
|
21 | 21 | grep: invalid match pattern: nothing to repeat* (glob) |
|
22 | 22 | [1] |
|
23 | 23 | |
|
24 | 24 | simple |
|
25 | 25 | |
|
26 | 26 | $ hg grep -r tip:0 '.*' |
|
27 | 27 | port:4:export |
|
28 | 28 | port:4:vaportight |
|
29 | 29 | port:4:import/export |
|
30 | 30 | port:3:export |
|
31 | 31 | port:3:vaportight |
|
32 | 32 | port:3:import/export |
|
33 | 33 | port:3:import/export |
|
34 | 34 | port:2:export |
|
35 | 35 | port:2:vaportight |
|
36 | 36 | port:2:import/export |
|
37 | 37 | port:1:import |
|
38 | 38 | port:1:export |
|
39 | 39 | port:0:import |
|
40 | 40 | $ hg grep -r tip:0 port port |
|
41 | 41 | port:4:export |
|
42 | 42 | port:4:vaportight |
|
43 | 43 | port:4:import/export |
|
44 | 44 | port:3:export |
|
45 | 45 | port:3:vaportight |
|
46 | 46 | port:3:import/export |
|
47 | 47 | port:3:import/export |
|
48 | 48 | port:2:export |
|
49 | 49 | port:2:vaportight |
|
50 | 50 | port:2:import/export |
|
51 | 51 | port:1:import |
|
52 | 52 | port:1:export |
|
53 | 53 | port:0:import |
|
54 | 54 | |
|
55 | 55 | simple from subdirectory |
|
56 | 56 | |
|
57 | 57 | $ mkdir dir |
|
58 | 58 | $ cd dir |
|
59 | 59 | $ hg grep -r tip:0 port |
|
60 | 60 | port:4:export |
|
61 | 61 | port:4:vaportight |
|
62 | 62 | port:4:import/export |
|
63 | 63 | port:3:export |
|
64 | 64 | port:3:vaportight |
|
65 | 65 | port:3:import/export |
|
66 | 66 | port:3:import/export |
|
67 | 67 | port:2:export |
|
68 | 68 | port:2:vaportight |
|
69 | 69 | port:2:import/export |
|
70 | 70 | port:1:import |
|
71 | 71 | port:1:export |
|
72 | 72 | port:0:import |
|
73 | 73 | $ hg grep -r tip:0 port --config ui.relative-paths=yes |
|
74 | 74 | ../port:4:export |
|
75 | 75 | ../port:4:vaportight |
|
76 | 76 | ../port:4:import/export |
|
77 | 77 | ../port:3:export |
|
78 | 78 | ../port:3:vaportight |
|
79 | 79 | ../port:3:import/export |
|
80 | 80 | ../port:3:import/export |
|
81 | 81 | ../port:2:export |
|
82 | 82 | ../port:2:vaportight |
|
83 | 83 | ../port:2:import/export |
|
84 | 84 | ../port:1:import |
|
85 | 85 | ../port:1:export |
|
86 | 86 | ../port:0:import |
|
87 | 87 | $ cd .. |
|
88 | 88 | |
|
89 | 89 | simple with color |
|
90 | 90 | |
|
91 | 91 | $ hg --config extensions.color= grep --config color.mode=ansi \ |
|
92 | 92 | > --color=always port port -r tip:0 |
|
93 | 93 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc) |
|
94 | 94 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc) |
|
95 | 95 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc) |
|
96 | 96 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc) |
|
97 | 97 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc) |
|
98 | 98 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc) |
|
99 | 99 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc) |
|
100 | 100 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc) |
|
101 | 101 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc) |
|
102 | 102 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/ex\x1b[0;31;1mport\x1b[0m (esc) |
|
103 | 103 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc) |
|
104 | 104 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc) |
|
105 | 105 | \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m0\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m (esc) |
|
106 | 106 | |
|
107 | 107 | simple templated |
|
108 | 108 | |
|
109 | 109 | $ hg grep port -r tip:0 \ |
|
110 | 110 | > -T '{path}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n' |
|
111 | 111 | port:4:914fa752cdea:exPORT |
|
112 | 112 | port:4:914fa752cdea:vaPORTight |
|
113 | 113 | port:4:914fa752cdea:imPORT/exPORT |
|
114 | 114 | port:3:95040cfd017d:exPORT |
|
115 | 115 | port:3:95040cfd017d:vaPORTight |
|
116 | 116 | port:3:95040cfd017d:imPORT/exPORT |
|
117 | 117 | port:3:95040cfd017d:imPORT/exPORT |
|
118 | 118 | port:2:3b325e3481a1:exPORT |
|
119 | 119 | port:2:3b325e3481a1:vaPORTight |
|
120 | 120 | port:2:3b325e3481a1:imPORT/exPORT |
|
121 | 121 | port:1:8b20f75c1585:imPORT |
|
122 | 122 | port:1:8b20f75c1585:exPORT |
|
123 | 123 | port:0:f31323c92170:imPORT |
|
124 | 124 | |
|
125 | 125 | $ hg grep port -r tip:0 -T '{path}:{rev}:{texts}\n' |
|
126 | 126 | port:4:export |
|
127 | 127 | port:4:vaportight |
|
128 | 128 | port:4:import/export |
|
129 | 129 | port:3:export |
|
130 | 130 | port:3:vaportight |
|
131 | 131 | port:3:import/export |
|
132 | 132 | port:3:import/export |
|
133 | 133 | port:2:export |
|
134 | 134 | port:2:vaportight |
|
135 | 135 | port:2:import/export |
|
136 | 136 | port:1:import |
|
137 | 137 | port:1:export |
|
138 | 138 | port:0:import |
|
139 | 139 | |
|
140 | 140 | $ hg grep port -r tip:0 -T '{path}:{tags}:{texts}\n' |
|
141 | 141 | port:tip:export |
|
142 | 142 | port:tip:vaportight |
|
143 | 143 | port:tip:import/export |
|
144 | 144 | port::export |
|
145 | 145 | port::vaportight |
|
146 | 146 | port::import/export |
|
147 | 147 | port::import/export |
|
148 | 148 | port::export |
|
149 | 149 | port::vaportight |
|
150 | 150 | port::import/export |
|
151 | 151 | port::import |
|
152 | 152 | port::export |
|
153 | 153 | port::import |
|
154 | 154 | |
|
155 | 155 | simple JSON (no "change" field) |
|
156 | 156 | |
|
157 | 157 | $ hg grep -r tip:0 -Tjson port |
|
158 | 158 | [ |
|
159 | 159 | { |
|
160 | 160 | "date": [4, 0], |
|
161 | 161 | "lineno": 1, |
|
162 | 162 | "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c", |
|
163 | 163 | "path": "port", |
|
164 | 164 | "rev": 4, |
|
165 | 165 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
166 | 166 | "user": "spam" |
|
167 | 167 | }, |
|
168 | 168 | { |
|
169 | 169 | "date": [4, 0], |
|
170 | 170 | "lineno": 2, |
|
171 | 171 | "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c", |
|
172 | 172 | "path": "port", |
|
173 | 173 | "rev": 4, |
|
174 | 174 | "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}], |
|
175 | 175 | "user": "spam" |
|
176 | 176 | }, |
|
177 | 177 | { |
|
178 | 178 | "date": [4, 0], |
|
179 | 179 | "lineno": 3, |
|
180 | 180 | "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c", |
|
181 | 181 | "path": "port", |
|
182 | 182 | "rev": 4, |
|
183 | 183 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
184 | 184 | "user": "spam" |
|
185 | 185 | }, |
|
186 | 186 | { |
|
187 | 187 | "date": [3, 0], |
|
188 | 188 | "lineno": 1, |
|
189 | 189 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
190 | 190 | "path": "port", |
|
191 | 191 | "rev": 3, |
|
192 | 192 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
193 | 193 | "user": "eggs" |
|
194 | 194 | }, |
|
195 | 195 | { |
|
196 | 196 | "date": [3, 0], |
|
197 | 197 | "lineno": 2, |
|
198 | 198 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
199 | 199 | "path": "port", |
|
200 | 200 | "rev": 3, |
|
201 | 201 | "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}], |
|
202 | 202 | "user": "eggs" |
|
203 | 203 | }, |
|
204 | 204 | { |
|
205 | 205 | "date": [3, 0], |
|
206 | 206 | "lineno": 3, |
|
207 | 207 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
208 | 208 | "path": "port", |
|
209 | 209 | "rev": 3, |
|
210 | 210 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
211 | 211 | "user": "eggs" |
|
212 | 212 | }, |
|
213 | 213 | { |
|
214 | 214 | "date": [3, 0], |
|
215 | 215 | "lineno": 4, |
|
216 | 216 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
217 | 217 | "path": "port", |
|
218 | 218 | "rev": 3, |
|
219 | 219 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
220 | 220 | "user": "eggs" |
|
221 | 221 | }, |
|
222 | 222 | { |
|
223 | 223 | "date": [2, 0], |
|
224 | 224 | "lineno": 1, |
|
225 | 225 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
226 | 226 | "path": "port", |
|
227 | 227 | "rev": 2, |
|
228 | 228 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
229 | 229 | "user": "spam" |
|
230 | 230 | }, |
|
231 | 231 | { |
|
232 | 232 | "date": [2, 0], |
|
233 | 233 | "lineno": 2, |
|
234 | 234 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
235 | 235 | "path": "port", |
|
236 | 236 | "rev": 2, |
|
237 | 237 | "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}], |
|
238 | 238 | "user": "spam" |
|
239 | 239 | }, |
|
240 | 240 | { |
|
241 | 241 | "date": [2, 0], |
|
242 | 242 | "lineno": 3, |
|
243 | 243 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
244 | 244 | "path": "port", |
|
245 | 245 | "rev": 2, |
|
246 | 246 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
247 | 247 | "user": "spam" |
|
248 | 248 | }, |
|
249 | 249 | { |
|
250 | 250 | "date": [1, 0], |
|
251 | 251 | "lineno": 1, |
|
252 | 252 | "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587", |
|
253 | 253 | "path": "port", |
|
254 | 254 | "rev": 1, |
|
255 | 255 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}], |
|
256 | 256 | "user": "eggs" |
|
257 | 257 | }, |
|
258 | 258 | { |
|
259 | 259 | "date": [1, 0], |
|
260 | 260 | "lineno": 2, |
|
261 | 261 | "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587", |
|
262 | 262 | "path": "port", |
|
263 | 263 | "rev": 1, |
|
264 | 264 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
265 | 265 | "user": "eggs" |
|
266 | 266 | }, |
|
267 | 267 | { |
|
268 | 268 | "date": [0, 0], |
|
269 | 269 | "lineno": 1, |
|
270 | 270 | "node": "f31323c9217050ba245ee8b537c713ec2e8ab226", |
|
271 | 271 | "path": "port", |
|
272 | 272 | "rev": 0, |
|
273 | 273 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}], |
|
274 | 274 | "user": "spam" |
|
275 | 275 | } |
|
276 | 276 | ] |
|
277 | 277 | |
|
278 | 278 | simple JSON without matching lines |
|
279 | 279 | |
|
280 | 280 | $ hg grep -r tip:0 -Tjson -l port |
|
281 | 281 | [ |
|
282 | 282 | { |
|
283 | 283 | "date": [4, 0], |
|
284 | 284 | "lineno": 1, |
|
285 | 285 | "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c", |
|
286 | 286 | "path": "port", |
|
287 | 287 | "rev": 4, |
|
288 | 288 | "user": "spam" |
|
289 | 289 | }, |
|
290 | 290 | { |
|
291 | 291 | "date": [3, 0], |
|
292 | 292 | "lineno": 1, |
|
293 | 293 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
294 | 294 | "path": "port", |
|
295 | 295 | "rev": 3, |
|
296 | 296 | "user": "eggs" |
|
297 | 297 | }, |
|
298 | 298 | { |
|
299 | 299 | "date": [2, 0], |
|
300 | 300 | "lineno": 1, |
|
301 | 301 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
302 | 302 | "path": "port", |
|
303 | 303 | "rev": 2, |
|
304 | 304 | "user": "spam" |
|
305 | 305 | }, |
|
306 | 306 | { |
|
307 | 307 | "date": [1, 0], |
|
308 | 308 | "lineno": 1, |
|
309 | 309 | "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587", |
|
310 | 310 | "path": "port", |
|
311 | 311 | "rev": 1, |
|
312 | 312 | "user": "eggs" |
|
313 | 313 | }, |
|
314 | 314 | { |
|
315 | 315 | "date": [0, 0], |
|
316 | 316 | "lineno": 1, |
|
317 | 317 | "node": "f31323c9217050ba245ee8b537c713ec2e8ab226", |
|
318 | 318 | "path": "port", |
|
319 | 319 | "rev": 0, |
|
320 | 320 | "user": "spam" |
|
321 | 321 | } |
|
322 | 322 | ] |
|
323 | 323 | |
|
324 | 324 | all |
|
325 | 325 | |
|
326 | 326 | $ hg grep --traceback --all -nu port port |
|
327 | 327 | port:4:4:-:spam:import/export |
|
328 | 328 | port:3:4:+:eggs:import/export |
|
329 | 329 | port:2:1:-:spam:import |
|
330 | 330 | port:2:2:-:spam:export |
|
331 | 331 | port:2:1:+:spam:export |
|
332 | 332 | port:2:2:+:spam:vaportight |
|
333 | 333 | port:2:3:+:spam:import/export |
|
334 | 334 | port:1:2:+:eggs:export |
|
335 | 335 | port:0:1:+:spam:import |
|
336 | 336 | |
|
337 | 337 | all JSON |
|
338 | 338 | |
|
339 | 339 | $ hg grep --all -Tjson port port |
|
340 | 340 | [ |
|
341 | 341 | { |
|
342 | 342 | "change": "-", |
|
343 | 343 | "date": [4, 0], |
|
344 | 344 | "lineno": 4, |
|
345 | 345 | "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c", |
|
346 | 346 | "path": "port", |
|
347 | 347 | "rev": 4, |
|
348 | 348 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
349 | 349 | "user": "spam" |
|
350 | 350 | }, |
|
351 | 351 | { |
|
352 | 352 | "change": "+", |
|
353 | 353 | "date": [3, 0], |
|
354 | 354 | "lineno": 4, |
|
355 | 355 | "node": "95040cfd017d658c536071c6290230a613c4c2a6", |
|
356 | 356 | "path": "port", |
|
357 | 357 | "rev": 3, |
|
358 | 358 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
359 | 359 | "user": "eggs" |
|
360 | 360 | }, |
|
361 | 361 | { |
|
362 | 362 | "change": "-", |
|
363 | 363 | "date": [2, 0], |
|
364 | 364 | "lineno": 1, |
|
365 | 365 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
366 | 366 | "path": "port", |
|
367 | 367 | "rev": 2, |
|
368 | 368 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}], |
|
369 | 369 | "user": "spam" |
|
370 | 370 | }, |
|
371 | 371 | { |
|
372 | 372 | "change": "-", |
|
373 | 373 | "date": [2, 0], |
|
374 | 374 | "lineno": 2, |
|
375 | 375 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
376 | 376 | "path": "port", |
|
377 | 377 | "rev": 2, |
|
378 | 378 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
379 | 379 | "user": "spam" |
|
380 | 380 | }, |
|
381 | 381 | { |
|
382 | 382 | "change": "+", |
|
383 | 383 | "date": [2, 0], |
|
384 | 384 | "lineno": 1, |
|
385 | 385 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
386 | 386 | "path": "port", |
|
387 | 387 | "rev": 2, |
|
388 | 388 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
389 | 389 | "user": "spam" |
|
390 | 390 | }, |
|
391 | 391 | { |
|
392 | 392 | "change": "+", |
|
393 | 393 | "date": [2, 0], |
|
394 | 394 | "lineno": 2, |
|
395 | 395 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
396 | 396 | "path": "port", |
|
397 | 397 | "rev": 2, |
|
398 | 398 | "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}], |
|
399 | 399 | "user": "spam" |
|
400 | 400 | }, |
|
401 | 401 | { |
|
402 | 402 | "change": "+", |
|
403 | 403 | "date": [2, 0], |
|
404 | 404 | "lineno": 3, |
|
405 | 405 | "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47", |
|
406 | 406 | "path": "port", |
|
407 | 407 | "rev": 2, |
|
408 | 408 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}], |
|
409 | 409 | "user": "spam" |
|
410 | 410 | }, |
|
411 | 411 | { |
|
412 | 412 | "change": "+", |
|
413 | 413 | "date": [1, 0], |
|
414 | 414 | "lineno": 2, |
|
415 | 415 | "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587", |
|
416 | 416 | "path": "port", |
|
417 | 417 | "rev": 1, |
|
418 | 418 | "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}], |
|
419 | 419 | "user": "eggs" |
|
420 | 420 | }, |
|
421 | 421 | { |
|
422 | 422 | "change": "+", |
|
423 | 423 | "date": [0, 0], |
|
424 | 424 | "lineno": 1, |
|
425 | 425 | "node": "f31323c9217050ba245ee8b537c713ec2e8ab226", |
|
426 | 426 | "path": "port", |
|
427 | 427 | "rev": 0, |
|
428 | 428 | "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}], |
|
429 | 429 | "user": "spam" |
|
430 | 430 | } |
|
431 | 431 | ] |
|
432 | 432 | |
|
433 | 433 | other |
|
434 | 434 | |
|
435 | 435 | $ hg grep -r tip:0 -l port port |
|
436 | 436 | port:4 |
|
437 | 437 | port:3 |
|
438 | 438 | port:2 |
|
439 | 439 | port:1 |
|
440 | 440 | port:0 |
|
441 | 441 | $ hg grep -r tip:0 import port |
|
442 | 442 | port:4:import/export |
|
443 | 443 | port:3:import/export |
|
444 | 444 | port:3:import/export |
|
445 | 445 | port:2:import/export |
|
446 | 446 | port:1:import |
|
447 | 447 | port:0:import |
|
448 | 448 | |
|
449 | 449 | $ hg cp port port2 |
|
450 | 450 | $ hg commit -m 4 -u spam -d '5 0' |
|
451 | 451 | |
|
452 | 452 | follow |
|
453 | 453 | |
|
454 | 454 | $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2 |
|
455 | 455 | [1] |
|
456 | 456 | $ echo deport >> port2 |
|
457 | 457 | $ hg commit -m 5 -u eggs -d '6 0' |
|
458 | 458 | $ hg grep -f --all -nu port port2 |
|
459 | 459 | port2:6:4:+:eggs:deport |
|
460 | 460 | port:4:4:-:spam:import/export |
|
461 | 461 | port:3:4:+:eggs:import/export |
|
462 | 462 | port:2:1:-:spam:import |
|
463 | 463 | port:2:2:-:spam:export |
|
464 | 464 | port:2:1:+:spam:export |
|
465 | 465 | port:2:2:+:spam:vaportight |
|
466 | 466 | port:2:3:+:spam:import/export |
|
467 | 467 | port:1:2:+:eggs:export |
|
468 | 468 | port:0:1:+:spam:import |
|
469 | 469 | |
|
470 | 470 | $ hg up -q null |
|
471 | 471 | $ hg grep -r 'reverse(:.)' -f port |
|
472 | 472 | port:0:import |
|
473 | 473 | |
|
474 | 474 | Test wdir |
|
475 | 475 | (at least, this shouldn't crash) |
|
476 | 476 | |
|
477 | 477 | $ hg up -q |
|
478 | 478 | $ echo wport >> port2 |
|
479 | 479 | $ hg stat |
|
480 | 480 | M port2 |
|
481 | 481 | $ hg grep -r 'wdir()' port |
|
482 | 482 | port:2147483647:export |
|
483 | 483 | port:2147483647:vaportight |
|
484 | 484 | port:2147483647:import/export |
|
485 | 485 | port2:2147483647:export |
|
486 | 486 | port2:2147483647:vaportight |
|
487 | 487 | port2:2147483647:import/export |
|
488 | 488 | port2:2147483647:deport |
|
489 | 489 | port2:2147483647:wport |
|
490 | 490 | |
|
491 | 491 | $ cd .. |
|
492 | 492 | $ hg init t2 |
|
493 | 493 | $ cd t2 |
|
494 | 494 | $ hg grep -r tip:0 foobar foo |
|
495 | 495 | [1] |
|
496 | 496 | $ hg grep -r tip:0 foobar |
|
497 | 497 | [1] |
|
498 | 498 | $ echo blue >> color |
|
499 | 499 | $ echo black >> color |
|
500 | 500 | $ hg add color |
|
501 | 501 | $ hg ci -m 0 |
|
502 | 502 | $ echo orange >> color |
|
503 | 503 | $ hg ci -m 1 |
|
504 | 504 | $ echo black > color |
|
505 | 505 | $ hg ci -m 2 |
|
506 | 506 | $ echo orange >> color |
|
507 | 507 | $ echo blue >> color |
|
508 | 508 | $ hg ci -m 3 |
|
509 | 509 | $ hg grep -r tip:0 orange |
|
510 | 510 | color:3:orange |
|
511 | 511 | color:1:orange |
|
512 | 512 | $ hg grep --all orange |
|
513 | 513 | color:3:+:orange |
|
514 | 514 | color:2:-:orange |
|
515 | 515 | color:1:+:orange |
|
516 | 516 | $ hg grep --diff orange --color=debug |
|
517 | 517 | [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange] |
|
518 | 518 | [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange] |
|
519 | 519 | [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange] |
|
520 | 520 | |
|
521 | 521 | $ hg grep --diff orange --color=yes |
|
522 | 522 | \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m3\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc) |
|
523 | 523 | \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m2\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1m-\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc) |
|
524 | 524 | \x1b[0;35mcolor\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;34m1\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32;1m+\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;31;1morange\x1b[0m (esc) |
|
525 | 525 | |
|
526 | 526 | $ hg grep --diff orange |
|
527 | 527 | color:3:+:orange |
|
528 | 528 | color:2:-:orange |
|
529 | 529 | color:1:+:orange |
|
530 | 530 | |
|
531 | 531 | test substring match: '^' should only match at the beginning |
|
532 | 532 | |
|
533 | 533 | $ hg grep -r tip:0 '^.' --config extensions.color= --color debug |
|
534 | 534 | [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack |
|
535 | 535 | [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range |
|
536 | 536 | [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue |
|
537 | 537 | [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack |
|
538 | 538 | [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue |
|
539 | 539 | [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack |
|
540 | 540 | [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range |
|
541 | 541 | [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue |
|
542 | 542 | [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack |
|
543 | 543 | |
|
544 | 544 | match in last "line" without newline |
|
545 | 545 | |
|
546 | 546 | $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();' |
|
547 | 547 | $ hg ci -Amnoeol |
|
548 | 548 | adding noeol |
|
549 | 549 | $ hg grep -r tip:0 loop |
|
550 | 550 | noeol:4:no infinite loop |
|
551 | 551 | |
|
552 | 552 | $ cd .. |
|
553 | 553 | |
|
554 | 554 | Issue685: traceback in grep -r after rename |
|
555 | 555 | |
|
556 | 556 | Got a traceback when using grep on a single |
|
557 | 557 | revision with renamed files. |
|
558 | 558 | |
|
559 | 559 | $ hg init issue685 |
|
560 | 560 | $ cd issue685 |
|
561 | 561 | $ echo octarine > color |
|
562 | 562 | $ hg ci -Amcolor |
|
563 | 563 | adding color |
|
564 | 564 | $ hg rename color colour |
|
565 | 565 | $ hg ci -Am rename |
|
566 | 566 | $ hg grep -r tip:0 octarine |
|
567 | 567 | colour:1:octarine |
|
568 | 568 | color:0:octarine |
|
569 | 569 | |
|
570 | 570 | Used to crash here |
|
571 | 571 | |
|
572 | 572 | $ hg grep -r 1 octarine |
|
573 | 573 | colour:1:octarine |
|
574 | 574 | $ cd .. |
|
575 | 575 | |
|
576 | 576 | |
|
577 | 577 | Issue337: test that grep follows parent-child relationships instead |
|
578 | 578 | of just using revision numbers. |
|
579 | 579 | |
|
580 | 580 | $ hg init issue337 |
|
581 | 581 | $ cd issue337 |
|
582 | 582 | |
|
583 | 583 | $ echo white > color |
|
584 | 584 | $ hg commit -A -m "0 white" |
|
585 | 585 | adding color |
|
586 | 586 | |
|
587 | 587 | $ echo red > color |
|
588 | 588 | $ hg commit -A -m "1 red" |
|
589 | 589 | |
|
590 | 590 | $ hg update 0 |
|
591 | 591 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
592 | 592 | $ echo black > color |
|
593 | 593 | $ hg commit -A -m "2 black" |
|
594 | 594 | created new head |
|
595 | 595 | |
|
596 | 596 | $ hg update --clean 1 |
|
597 | 597 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
598 | 598 | $ echo blue > color |
|
599 | 599 | $ hg commit -A -m "3 blue" |
|
600 | 600 | |
|
601 | 601 | $ hg grep --all red |
|
602 | 602 | color:3:-:red |
|
603 | 603 | color:1:+:red |
|
604 | 604 | |
|
605 | 605 | $ hg grep --diff red |
|
606 | 606 | color:3:-:red |
|
607 | 607 | color:1:+:red |
|
608 | 608 | |
|
609 | 609 | Issue3885: test that changing revision order does not alter the |
|
610 | 610 | revisions printed, just their order. |
|
611 | 611 | |
|
612 | 612 | $ hg grep --all red -r "all()" |
|
613 | 613 | color:1:+:red |
|
614 | 614 | color:3:-:red |
|
615 | 615 | |
|
616 | 616 | $ hg grep --all red -r "reverse(all())" |
|
617 | 617 | color:3:-:red |
|
618 | 618 | color:1:+:red |
|
619 | 619 | |
|
620 | 620 | $ hg grep --diff red -r "all()" |
|
621 | 621 | color:1:+:red |
|
622 | 622 | color:3:-:red |
|
623 | 623 | |
|
624 | 624 | $ hg grep --diff red -r "reverse(all())" |
|
625 | 625 | color:3:-:red |
|
626 | 626 | color:1:+:red |
|
627 | 627 | |
|
628 | 628 | $ cd .. |
|
629 | 629 | |
|
630 | 630 | $ hg init a |
|
631 | 631 | $ cd a |
|
632 | 632 | $ cp "$TESTDIR/binfile.bin" . |
|
633 | 633 | $ hg add binfile.bin |
|
634 | 634 | $ hg ci -m 'add binfile.bin' |
|
635 | 635 | $ hg grep "MaCam" --all |
|
636 | 636 | binfile.bin:0:+: Binary file matches |
|
637 | 637 | |
|
638 | 638 | $ hg grep "MaCam" --diff |
|
639 | 639 | binfile.bin:0:+: Binary file matches |
|
640 | 640 | |
|
641 | 641 | $ cd .. |
|
642 | 642 | |
|
643 | 643 | Test for showing working of allfiles flag |
|
644 | 644 | |
|
645 | 645 | $ hg init sng |
|
646 | 646 | $ cd sng |
|
647 | 647 | $ echo "unmod" >> um |
|
648 | $ hg ci -A -m "adds unmod to um" | |
|
649 | adding um | |
|
648 | $ echo old > old | |
|
649 | $ hg ci -q -A -m "adds unmod to um" | |
|
650 | 650 | $ echo "something else" >> new |
|
651 | 651 | $ hg ci -A -m "second commit" |
|
652 | 652 | adding new |
|
653 | 653 | $ hg grep -r "." "unmod" |
|
654 | 654 | um:1:unmod |
|
655 | 655 | |
|
656 |
|
|
|
656 | Existing tracked files in the working directory are searched by default | |
|
657 | 657 | |
|
658 | 658 | $ echo modified >> new |
|
659 | $ hg grep mod | |
|
659 | $ echo 'added' > added; hg add added | |
|
660 | $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing | |
|
661 | $ echo 'untracked' > untracked | |
|
662 | $ hg rm old | |
|
663 | $ hg grep '[^Z]' | |
|
664 | added:added | |
|
665 | new:something else | |
|
660 | 666 | new:modified |
|
661 | 667 | um:unmod |
|
662 | 668 | |
|
663 | 669 | which can be overridden by -rREV |
|
664 | 670 | |
|
665 | 671 | $ hg grep -r. mod |
|
666 | 672 | um:1:unmod |
|
667 | 673 | |
|
668 | 674 | $ hg grep --diff mod |
|
669 | 675 | um:0:+:unmod |
|
670 | 676 | |
|
671 | 677 | $ cd .. |
|
672 | 678 | |
|
673 | Fix_Wdir(): test that passing wdir() t -r flag does greps on the | |
|
674 | files modified in the working directory | |
|
675 | ||
|
676 | $ cd a | |
|
677 | $ echo "abracadara" >> a | |
|
678 | $ hg add a | |
|
679 | $ hg grep -r "wdir()" "abra" | |
|
680 | a:2147483647:abracadara | |
|
681 | ||
|
682 | $ cd .. | |
|
683 | ||
|
684 | 679 | Change Default of grep by ui.tweakdefaults, that is, the files not in current |
|
685 | 680 | working directory should not be grepp-ed on |
|
686 | 681 | |
|
687 | 682 | $ hg init ab |
|
688 | 683 | $ cd ab |
|
689 | 684 | $ cat <<'EOF' >> .hg/hgrc |
|
690 | 685 | > [ui] |
|
691 | 686 | > tweakdefaults = True |
|
692 | 687 | > EOF |
|
693 | 688 | $ echo "some text">>file1 |
|
694 | 689 | $ hg add file1 |
|
695 | 690 | $ hg commit -m "adds file1" |
|
696 | 691 | $ hg mv file1 file2 |
|
697 | 692 | |
|
698 | 693 | wdir revision is hidden by default: |
|
699 | 694 | |
|
700 | 695 | $ hg grep "some" |
|
701 | 696 | file2:some text |
|
702 | 697 | |
|
703 | 698 | but it should be available in template dict: |
|
704 | 699 | |
|
705 | 700 | $ hg grep "some" -Tjson |
|
706 | 701 | [ |
|
707 | 702 | { |
|
708 | 703 | "date": [0, 0], |
|
709 | 704 | "lineno": 1, |
|
710 | 705 | "node": "ffffffffffffffffffffffffffffffffffffffff", |
|
711 | 706 | "path": "file2", |
|
712 | 707 | "rev": 2147483647, |
|
713 | 708 | "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}], |
|
714 | 709 | "user": "test" |
|
715 | 710 | } |
|
716 | 711 | ] |
|
717 | 712 | |
|
718 | 713 | $ cd .. |
|
719 | 714 | |
|
720 | 715 | test -rMULTIREV |
|
721 | 716 | |
|
722 | 717 | $ cd sng |
|
723 | 718 | $ hg rm um |
|
724 | 719 | $ hg commit -m "deletes um" |
|
725 | 720 | $ hg grep -r "0:2" "unmod" |
|
726 | 721 | um:0:unmod |
|
727 | 722 | um:1:unmod |
|
728 | 723 | $ hg grep -r "0:2" "unmod" um |
|
729 | 724 | um:0:unmod |
|
730 | 725 | um:1:unmod |
|
731 | 726 | $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work |
|
732 | 727 | um:0:unmod |
|
733 | 728 | um:1:unmod |
|
734 | 729 | $ cd .. |
|
735 | 730 |
General Comments 0
You need to be logged in to leave comments.
Login now