Debian Codegraph @

tests/test-grep.t

raw
1 $ hg init t
2 $ cd t
3 $ echo import > port
4 $ hg add port
5 $ hg commit -m 0 -u spam -d '0 0'
6 $ echo export >> port
7 $ hg commit -m 1 -u eggs -d '1 0'
8 $ echo export > port
9 $ echo vaportight >> port
10 $ echo 'import/export' >> port
11 $ hg commit -m 2 -u spam -d '2 0'
12 $ echo 'import/export' >> port
13 $ hg commit -m 3 -u eggs -d '3 0'
14 $ head -n 3 port > port1
15 $ mv port1 port
16 $ hg commit -m 4 -u spam -d '4 0'
17
18 pattern error
19
20 $ hg grep '**test**'
21 grep: invalid match pattern: nothing to repeat* (glob)
22 [1]
23
24 invalid revset syntax
25
26 $ hg log -r 'diffcontains()'
27 hg: parse error: diffcontains takes at least 1 argument
28 [10]
29 $ hg log -r 'diffcontains(:)'
30 hg: parse error: diffcontains requires a string pattern
31 [10]
32 $ hg log -r 'diffcontains("re:**test**")'
33 hg: parse error: invalid regular expression: nothing to repeat* (glob)
34 [10]
35
36 simple
37
38 $ hg grep -r tip:0 '.*'
39 port:4:export
40 port:4:vaportight
41 port:4:import/export
42 port:3:export
43 port:3:vaportight
44 port:3:import/export
45 port:3:import/export
46 port:2:export
47 port:2:vaportight
48 port:2:import/export
49 port:1:import
50 port:1:export
51 port:0:import
52 $ hg grep -r tip:0 port port
53 port:4:export
54 port:4:vaportight
55 port:4:import/export
56 port:3:export
57 port:3:vaportight
58 port:3:import/export
59 port:3:import/export
60 port:2:export
61 port:2:vaportight
62 port:2:import/export
63 port:1:import
64 port:1:export
65 port:0:import
66
67 simple from subdirectory
68
69 $ mkdir dir
70 $ cd dir
71 $ hg grep -r tip:0 port
72 port:4:export
73 port:4:vaportight
74 port:4:import/export
75 port:3:export
76 port:3:vaportight
77 port:3:import/export
78 port:3:import/export
79 port:2:export
80 port:2:vaportight
81 port:2:import/export
82 port:1:import
83 port:1:export
84 port:0:import
85 $ hg grep -r tip:0 port --config ui.relative-paths=yes
86 ../port:4:export
87 ../port:4:vaportight
88 ../port:4:import/export
89 ../port:3:export
90 ../port:3:vaportight
91 ../port:3:import/export
92 ../port:3:import/export
93 ../port:2:export
94 ../port:2:vaportight
95 ../port:2:import/export
96 ../port:1:import
97 ../port:1:export
98 ../port:0:import
99 $ cd ..
100
101 simple with color
102
103 $ hg --config extensions.color= grep --config color.mode=ansi \
104 > --color=always port port -r tip:0
105 \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)
106 \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)
107 \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)
108 \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)
109 \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)
110 \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)
111 \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)
112 \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)
113 \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)
114 \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)
115 \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)
116 \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)
117 \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)
118
119 simple templated
120
121 $ hg grep port -r tip:0 \
122 > -T '{path}:{rev}:{node|short}:{texts % "{if(matched, text|upper, text)}"}\n'
123 port:4:914fa752cdea:exPORT
124 port:4:914fa752cdea:vaPORTight
125 port:4:914fa752cdea:imPORT/exPORT
126 port:3:95040cfd017d:exPORT
127 port:3:95040cfd017d:vaPORTight
128 port:3:95040cfd017d:imPORT/exPORT
129 port:3:95040cfd017d:imPORT/exPORT
130 port:2:3b325e3481a1:exPORT
131 port:2:3b325e3481a1:vaPORTight
132 port:2:3b325e3481a1:imPORT/exPORT
133 port:1:8b20f75c1585:imPORT
134 port:1:8b20f75c1585:exPORT
135 port:0:f31323c92170:imPORT
136
137 $ hg grep port -r tip:0 -T '{path}:{rev}:{texts}\n'
138 port:4:export
139 port:4:vaportight
140 port:4:import/export
141 port:3:export
142 port:3:vaportight
143 port:3:import/export
144 port:3:import/export
145 port:2:export
146 port:2:vaportight
147 port:2:import/export
148 port:1:import
149 port:1:export
150 port:0:import
151
152 $ hg grep port -r tip:0 -T '{path}:{tags}:{texts}\n'
153 port:tip:export
154 port:tip:vaportight
155 port:tip:import/export
156 port::export
157 port::vaportight
158 port::import/export
159 port::import/export
160 port::export
161 port::vaportight
162 port::import/export
163 port::import
164 port::export
165 port::import
166
167 simple JSON (no "change" field)
168
169 $ hg grep -r tip:0 -Tjson port
170 [
171 {
172 "date": [4, 0],
173 "lineno": 1,
174 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
175 "path": "port",
176 "rev": 4,
177 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
178 "user": "spam"
179 },
180 {
181 "date": [4, 0],
182 "lineno": 2,
183 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
184 "path": "port",
185 "rev": 4,
186 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
187 "user": "spam"
188 },
189 {
190 "date": [4, 0],
191 "lineno": 3,
192 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
193 "path": "port",
194 "rev": 4,
195 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
196 "user": "spam"
197 },
198 {
199 "date": [3, 0],
200 "lineno": 1,
201 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
202 "path": "port",
203 "rev": 3,
204 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
205 "user": "eggs"
206 },
207 {
208 "date": [3, 0],
209 "lineno": 2,
210 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
211 "path": "port",
212 "rev": 3,
213 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
214 "user": "eggs"
215 },
216 {
217 "date": [3, 0],
218 "lineno": 3,
219 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
220 "path": "port",
221 "rev": 3,
222 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
223 "user": "eggs"
224 },
225 {
226 "date": [3, 0],
227 "lineno": 4,
228 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
229 "path": "port",
230 "rev": 3,
231 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
232 "user": "eggs"
233 },
234 {
235 "date": [2, 0],
236 "lineno": 1,
237 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
238 "path": "port",
239 "rev": 2,
240 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
241 "user": "spam"
242 },
243 {
244 "date": [2, 0],
245 "lineno": 2,
246 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
247 "path": "port",
248 "rev": 2,
249 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
250 "user": "spam"
251 },
252 {
253 "date": [2, 0],
254 "lineno": 3,
255 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
256 "path": "port",
257 "rev": 2,
258 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
259 "user": "spam"
260 },
261 {
262 "date": [1, 0],
263 "lineno": 1,
264 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
265 "path": "port",
266 "rev": 1,
267 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
268 "user": "eggs"
269 },
270 {
271 "date": [1, 0],
272 "lineno": 2,
273 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
274 "path": "port",
275 "rev": 1,
276 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
277 "user": "eggs"
278 },
279 {
280 "date": [0, 0],
281 "lineno": 1,
282 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
283 "path": "port",
284 "rev": 0,
285 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
286 "user": "spam"
287 }
288 ]
289
290 simple JSON without matching lines
291
292 $ hg grep -r tip:0 -Tjson -l port
293 [
294 {
295 "date": [4, 0],
296 "lineno": 1,
297 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
298 "path": "port",
299 "rev": 4,
300 "user": "spam"
301 },
302 {
303 "date": [3, 0],
304 "lineno": 1,
305 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
306 "path": "port",
307 "rev": 3,
308 "user": "eggs"
309 },
310 {
311 "date": [2, 0],
312 "lineno": 1,
313 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
314 "path": "port",
315 "rev": 2,
316 "user": "spam"
317 },
318 {
319 "date": [1, 0],
320 "lineno": 1,
321 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
322 "path": "port",
323 "rev": 1,
324 "user": "eggs"
325 },
326 {
327 "date": [0, 0],
328 "lineno": 1,
329 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
330 "path": "port",
331 "rev": 0,
332 "user": "spam"
333 }
334 ]
335
336 diff of each revision for reference
337
338 $ hg log -p -T'== rev: {rev} ==\n'
339 == rev: 4 ==
340 diff -r 95040cfd017d -r 914fa752cdea port
341 --- a/port Thu Jan 01 00:00:03 1970 +0000
342 +++ b/port Thu Jan 01 00:00:04 1970 +0000
343 @@ -1,4 +1,3 @@
344 export
345 vaportight
346 import/export
347 -import/export
348
349 == rev: 3 ==
350 diff -r 3b325e3481a1 -r 95040cfd017d port
351 --- a/port Thu Jan 01 00:00:02 1970 +0000
352 +++ b/port Thu Jan 01 00:00:03 1970 +0000
353 @@ -1,3 +1,4 @@
354 export
355 vaportight
356 import/export
357 +import/export
358
359 == rev: 2 ==
360 diff -r 8b20f75c1585 -r 3b325e3481a1 port
361 --- a/port Thu Jan 01 00:00:01 1970 +0000
362 +++ b/port Thu Jan 01 00:00:02 1970 +0000
363 @@ -1,2 +1,3 @@
364 -import
365 export
366 +vaportight
367 +import/export
368
369 == rev: 1 ==
370 diff -r f31323c92170 -r 8b20f75c1585 port
371 --- a/port Thu Jan 01 00:00:00 1970 +0000
372 +++ b/port Thu Jan 01 00:00:01 1970 +0000
373 @@ -1,1 +1,2 @@
374 import
375 +export
376
377 == rev: 0 ==
378 diff -r 000000000000 -r f31323c92170 port
379 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
380 +++ b/port Thu Jan 01 00:00:00 1970 +0000
381 @@ -0,0 +1,1 @@
382 +import
383
384
385 all
386
387 $ hg grep --traceback --all -nu port port
388 port:4:4:-:spam:import/export
389 port:3:4:+:eggs:import/export
390 port:2:1:-:spam:import
391 port:2:2:+:spam:vaportight
392 port:2:3:+:spam:import/export
393 port:1:2:+:eggs:export
394 port:0:1:+:spam:import
395
396 all JSON
397
398 $ hg grep --all -Tjson port port
399 [
400 {
401 "change": "-",
402 "date": [4, 0],
403 "lineno": 4,
404 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
405 "path": "port",
406 "rev": 4,
407 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
408 "user": "spam"
409 },
410 {
411 "change": "+",
412 "date": [3, 0],
413 "lineno": 4,
414 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
415 "path": "port",
416 "rev": 3,
417 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
418 "user": "eggs"
419 },
420 {
421 "change": "-",
422 "date": [2, 0],
423 "lineno": 1,
424 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
425 "path": "port",
426 "rev": 2,
427 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
428 "user": "spam"
429 },
430 {
431 "change": "+",
432 "date": [2, 0],
433 "lineno": 2,
434 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
435 "path": "port",
436 "rev": 2,
437 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
438 "user": "spam"
439 },
440 {
441 "change": "+",
442 "date": [2, 0],
443 "lineno": 3,
444 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
445 "path": "port",
446 "rev": 2,
447 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
448 "user": "spam"
449 },
450 {
451 "change": "+",
452 "date": [1, 0],
453 "lineno": 2,
454 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
455 "path": "port",
456 "rev": 1,
457 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
458 "user": "eggs"
459 },
460 {
461 "change": "+",
462 "date": [0, 0],
463 "lineno": 1,
464 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
465 "path": "port",
466 "rev": 0,
467 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
468 "user": "spam"
469 }
470 ]
471
472 other
473
474 $ hg grep -r tip:0 -l port port
475 port:4
476 port:3
477 port:2
478 port:1
479 port:0
480 $ hg grep -r tip:0 import port
481 port:4:import/export
482 port:3:import/export
483 port:3:import/export
484 port:2:import/export
485 port:1:import
486 port:0:import
487
488 $ hg cp port port2
489 $ hg commit -m 4 -u spam -d '5 0'
490
491 follow
492
493 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
494 [1]
495 $ echo deport >> port2
496 $ hg commit -m 5 -u eggs -d '6 0'
497 $ hg grep -f --all -nu port port2
498 port2:6:4:+:eggs:deport
499 port:4:4:-:spam:import/export
500 port:3:4:+:eggs:import/export
501 port:2:1:-:spam:import
502 port:2:2:+:spam:vaportight
503 port:2:3:+:spam:import/export
504 port:1:2:+:eggs:export
505 port:0:1:+:spam:import
506
507 $ hg up -q null
508 $ hg grep -r 'reverse(:.)' -f port
509 port:0:import
510
511 Test wdir
512 (at least, this shouldn't crash)
513
514 $ hg up -q
515 $ echo wport >> port2
516 $ hg stat
517 M port2
518 $ hg grep -r 'wdir()' port
519 port:2147483647:export
520 port:2147483647:vaportight
521 port:2147483647:import/export
522 port2:2147483647:export
523 port2:2147483647:vaportight
524 port2:2147483647:import/export
525 port2:2147483647:deport
526 port2:2147483647:wport
527
528 Testing include/exclude
529
530 $ hg cp port tort
531 $ hg grep port -X tort
532 port:export
533 port:vaportight
534 port:import/export
535 port2:export
536 port2:vaportight
537 port2:import/export
538 port2:deport
539 port2:wport
540 $ hg grep port -I tort
541 tort:export
542 tort:vaportight
543 tort:import/export
544
545 $ cd ..
546 $ hg init t2
547 $ cd t2
548 $ hg grep -r tip:0 foobar foo
549 [1]
550 $ hg grep -r tip:0 foobar
551 [1]
552 $ echo blue >> color
553 $ echo black >> color
554 $ hg add color
555 $ hg ci -m 0
556 $ echo orange >> color
557 $ hg ci -m 1
558 $ echo black > color
559 $ hg ci -m 2
560 $ echo orange >> color
561 $ echo blue >> color
562 $ hg ci -m 3
563 $ hg grep -r tip:0 orange
564 color:3:orange
565 color:1:orange
566 $ hg grep --all orange
567 color:3:+:orange
568 color:2:-:orange
569 color:1:+:orange
570 $ hg grep --diff orange --color=debug
571 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
572 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
573 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
574
575 $ hg grep --diff orange --color=yes
576 \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)
577 \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)
578 \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)
579
580 $ hg grep --diff orange
581 color:3:+:orange
582 color:2:-:orange
583 color:1:+:orange
584
585 revset predicate for "grep --diff"
586
587 $ hg log -qr 'diffcontains("re:^bl...$")'
588 0:203191eb5e21
589 $ hg log -qr 'diffcontains("orange")'
590 1:7c585a21e0d1
591 2:11bd8bc8d653
592 3:e0116d3829f8
593 $ hg log -qr '2:0 & diffcontains("orange")'
594 2:11bd8bc8d653
595 1:7c585a21e0d1
596
597 test substring match: '^' should only match at the beginning
598
599 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
600 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
601 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
602 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
603 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
604 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
605 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
606 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
607 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
608 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
609
610 match in last "line" without newline
611
612 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
613 $ hg ci -Amnoeol
614 adding noeol
615 $ hg grep -r tip:0 loop
616 noeol:4:no infinite loop
617
618 $ cd ..
619
620 Issue685: traceback in grep -r after rename
621
622 Got a traceback when using grep on a single
623 revision with renamed files.
624
625 $ hg init issue685
626 $ cd issue685
627 $ echo octarine > color
628 $ hg ci -Amcolor
629 adding color
630 $ hg rename color colour
631 $ hg ci -Am rename
632 $ hg grep -r tip:0 octarine
633 colour:1:octarine
634 color:0:octarine
635
636 Used to crash here
637
638 $ hg grep -r 1 octarine
639 colour:1:octarine
640 $ cd ..
641
642
643 Issue337: test that grep follows parent-child relationships instead
644 of just using revision numbers.
645
646 $ hg init issue337
647 $ cd issue337
648
649 $ echo white > color
650 $ hg commit -A -m "0 white"
651 adding color
652
653 $ echo red > color
654 $ hg commit -A -m "1 red"
655
656 $ hg update 0
657 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
658 $ echo black > color
659 $ hg commit -A -m "2 black"
660 created new head
661
662 $ hg update --clean 1
663 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
664 $ echo blue > color
665 $ hg commit -A -m "3 blue"
666
667 $ hg grep --all red
668 color:3:-:red
669 color:1:+:red
670
671 $ hg grep --diff red
672 color:3:-:red
673 color:1:+:red
674
675 Issue3885: test that changing revision order does not alter the
676 revisions printed, just their order.
677
678 $ hg grep --all red -r "all()"
679 color:1:+:red
680 color:3:-:red
681
682 $ hg grep --all red -r "reverse(all())"
683 color:3:-:red
684 color:1:+:red
685
686 $ hg grep --diff red -r "all()"
687 color:1:+:red
688 color:3:-:red
689
690 $ hg grep --diff red -r "reverse(all())"
691 color:3:-:red
692 color:1:+:red
693
694 $ cd ..
695
696 $ hg init a
697 $ cd a
698 $ cp "$TESTDIR/binfile.bin" .
699 $ hg add binfile.bin
700 $ hg ci -m 'add binfile.bin'
701 $ hg grep "MaCam" --all
702 binfile.bin:0:+: Binary file matches
703
704 $ hg grep "MaCam" --diff
705 binfile.bin:0:+: Binary file matches
706
707 $ cd ..
708
709 Moved line may not be collected by "grep --diff" since it first filters
710 the contents to be diffed by the pattern. (i.e.
711 "diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".)
712 This is much faster than generating full diff per revision.
713
714 $ hg init moved-line
715 $ cd moved-line
716 $ cat <<'EOF' > a
717 > foo
718 > bar
719 > baz
720 > EOF
721 $ hg ci -Am initial
722 adding a
723 $ cat <<'EOF' > a
724 > bar
725 > baz
726 > foo
727 > EOF
728 $ hg ci -m reorder
729
730 $ hg diff -c 1
731 diff -r a593cc55e81b -r 69789a3b6e80 a
732 --- a/a Thu Jan 01 00:00:00 1970 +0000
733 +++ b/a Thu Jan 01 00:00:00 1970 +0000
734 @@ -1,3 +1,3 @@
735 -foo
736 bar
737 baz
738 +foo
739
740 can't find the move of "foo" at the revision 1:
741
742 $ hg grep --diff foo -r1
743 [1]
744
745 "bar" isn't moved at the revisoin 1:
746
747 $ hg grep --diff bar -r1
748 [1]
749
750 $ cd ..
751
752 Test for showing working of allfiles flag
753
754 $ hg init sng
755 $ cd sng
756 $ echo "unmod" >> um
757 $ echo old > old
758 $ hg ci -q -A -m "adds unmod to um"
759 $ echo "something else" >> new
760 $ hg ci -A -m "second commit"
761 adding new
762 $ hg grep -r "." "unmod"
763 um:1:unmod
764
765 Existing tracked files in the working directory are searched by default
766
767 $ echo modified >> new
768 $ echo 'added' > added; hg add added
769 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
770 $ echo 'untracked' > untracked
771 $ hg rm old
772 $ hg grep ''
773 added:added
774 new:something else
775 new:modified
776 um:unmod
777
778 #if symlink
779 Grepping a symlink greps its destination
780
781 $ rm -f added; ln -s symlink-added added
782 $ hg grep '' | grep added
783 added:symlink-added
784
785 But we reject symlinks as directories components of a tracked file as
786 usual:
787
788 $ mkdir dir; touch dir/f; hg add dir/f
789 $ rm -rf dir; ln -s / dir
790 $ hg grep ''
791 abort: path 'dir/f' traverses symbolic link 'dir'
792 [255]
793 #endif
794
795 But we can search files from some other revision with -rREV
796
797 $ hg grep -r. mod
798 um:1:unmod
799
800 $ hg grep --diff mod
801 um:0:+:unmod
802
803 $ cd ..
804
805 Change Default of grep by ui.tweakdefaults, that is, the files not in current
806 working directory should not be grepp-ed on
807
808 $ hg init ab
809 $ cd ab
810 $ cat <<'EOF' >> .hg/hgrc
811 > [ui]
812 > tweakdefaults = True
813 > EOF
814 $ echo "some text">>file1
815 $ hg add file1
816 $ hg commit -m "adds file1"
817 $ hg mv file1 file2
818
819 wdir revision is hidden by default:
820
821 $ hg grep "some"
822 file2:some text
823
824 but it should be available in template dict:
825
826 $ hg grep "some" -Tjson
827 [
828 {
829 "date": [0, 0],
830 "lineno": 1,
831 "node": "ffffffffffffffffffffffffffffffffffffffff",
832 "path": "file2",
833 "rev": 2147483647,
834 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
835 "user": "test"
836 }
837 ]
838
839 $ cd ..
840
841 test -rMULTIREV
842
843 $ cd sng
844 $ hg rm um
845 $ hg commit -m "deletes um"
846 $ hg grep -r "0:2" "unmod"
847 um:0:unmod
848 um:1:unmod
849 $ hg grep -r "0:2" "unmod" um
850 um:0:unmod
851 um:1:unmod
852 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
853 um:0:unmod
854 um:1:unmod
855 $ cd ..
856
857 --follow with/without --diff and/or paths
858 -----------------------------------------
859
860 For each test case, we compare the history traversal of "hg log",
861 "hg grep --diff", and "hg grep" (--all-files).
862
863 "hg grep --diff" should traverse the log in the same way as "hg log".
864 "hg grep" (--all-files) is slightly different in that it includes
865 unmodified changes.
866
867 $ hg init follow
868 $ cd follow
869
870 $ cat <<'EOF' >> .hg/hgrc
871 > [command-templates]
872 > log = '{rev}: {join(files % "{status} {path}", ", ")}\n'
873 > EOF
874
875 $ for f in add0 add0-mod1 add0-rm1 add0-mod2 add0-rm2 add0-mod3 add0-mod4 add0-rm4; do
876 > echo data0 >> $f
877 > done
878 $ hg ci -qAm0
879
880 $ hg cp add0 add0-cp1
881 $ hg cp add0 add0-cp1-mod1
882 $ hg cp add0 add0-cp1-mod1-rm3
883 $ hg rm add0-rm1
884 $ for f in *mod1*; do
885 > echo data1 >> $f
886 > done
887 $ hg ci -qAm1
888
889 $ hg update -q 0
890 $ hg cp add0 add0-cp2
891 $ hg cp add0 add0-cp2-mod2
892 $ hg rm add0-rm2
893 $ for f in *mod2*; do
894 > echo data2 >> $f
895 > done
896 $ hg ci -qAm2
897
898 $ hg update -q 1
899 $ hg cp add0-cp1 add0-cp1-cp3
900 $ hg cp add0-cp1-mod1 add0-cp1-mod1-cp3-mod3
901 $ hg rm add0-cp1-mod1-rm3
902 $ for f in *mod3*; do
903 > echo data3 >> $f
904 > done
905 $ hg ci -qAm3
906
907 $ hg cp add0 add0-cp4
908 $ hg cp add0 add0-cp4-mod4
909 $ hg rm add0-rm4
910 $ for f in *mod4*; do
911 > echo data4 >> $f
912 > done
913
914 $ hg log -Gr':wdir()'
915 o 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
916 |
917 @ 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
918 |
919 | o 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
920 | |
921 o | 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
922 |/
923 o 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
924
925
926 follow revision history from wdir parent:
927
928 $ hg log -f
929 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
930 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
931 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
932
933 $ hg grep --diff -f data
934 add0-cp1-mod1-cp3-mod3:3:+:data3
935 add0-mod3:3:+:data3
936 add0-cp1-mod1:1:+:data1
937 add0-cp1-mod1-rm3:1:+:data1
938 add0-mod1:1:+:data1
939 add0:0:+:data0
940 add0-mod1:0:+:data0
941 add0-mod2:0:+:data0
942 add0-mod3:0:+:data0
943 add0-mod4:0:+:data0
944 add0-rm1:0:+:data0
945 add0-rm2:0:+:data0
946 add0-rm4:0:+:data0
947
948 $ hg grep -f data
949 add0:3:data0
950 add0-cp1:3:data0
951 add0-cp1-cp3:3:data0
952 add0-cp1-mod1:3:data0
953 add0-cp1-mod1:3:data1
954 add0-cp1-mod1-cp3-mod3:3:data0
955 add0-cp1-mod1-cp3-mod3:3:data1
956 add0-cp1-mod1-cp3-mod3:3:data3
957 add0-mod1:3:data0
958 add0-mod1:3:data1
959 add0-mod2:3:data0
960 add0-mod3:3:data0
961 add0-mod3:3:data3
962 add0-mod4:3:data0
963 add0-rm2:3:data0
964 add0-rm4:3:data0
965 add0:1:data0
966 add0-cp1:1:data0
967 add0-cp1-mod1:1:data0
968 add0-cp1-mod1:1:data1
969 add0-cp1-mod1-rm3:1:data0
970 add0-cp1-mod1-rm3:1:data1
971 add0-mod1:1:data0
972 add0-mod1:1:data1
973 add0-mod2:1:data0
974 add0-mod3:1:data0
975 add0-mod4:1:data0
976 add0-rm2:1:data0
977 add0-rm4:1:data0
978 add0:0:data0
979 add0-mod1:0:data0
980 add0-mod2:0:data0
981 add0-mod3:0:data0
982 add0-mod4:0:data0
983 add0-rm1:0:data0
984 add0-rm2:0:data0
985 add0-rm4:0:data0
986
987 follow revision history from specified revision:
988
989 $ hg log -fr2
990 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
991 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
992
993 $ hg grep --diff -fr2 data
994 add0-cp2-mod2:2:+:data2
995 add0-mod2:2:+:data2
996 add0:0:+:data0
997 add0-mod1:0:+:data0
998 add0-mod2:0:+:data0
999 add0-mod3:0:+:data0
1000 add0-mod4:0:+:data0
1001 add0-rm1:0:+:data0
1002 add0-rm2:0:+:data0
1003 add0-rm4:0:+:data0
1004
1005 $ hg grep -fr2 data
1006 add0:2:data0
1007 add0-cp2:2:data0
1008 add0-cp2-mod2:2:data0
1009 add0-cp2-mod2:2:data2
1010 add0-mod1:2:data0
1011 add0-mod2:2:data0
1012 add0-mod2:2:data2
1013 add0-mod3:2:data0
1014 add0-mod4:2:data0
1015 add0-rm1:2:data0
1016 add0-rm4:2:data0
1017 add0:0:data0
1018 add0-mod1:0:data0
1019 add0-mod2:0:data0
1020 add0-mod3:0:data0
1021 add0-mod4:0:data0
1022 add0-rm1:0:data0
1023 add0-rm2:0:data0
1024 add0-rm4:0:data0
1025
1026 follow revision history from wdir:
1027
1028 $ hg log -fr'wdir()'
1029 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1030 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1031 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1032 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1033
1034 BROKEN: should not abort because of removed file
1035 $ hg grep --diff -fr'wdir()' data
1036 add0-cp4-mod4:2147483647:+:data4
1037 add0-mod4:2147483647:+:data4
1038 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest
1039 [50]
1040
1041 $ hg grep -fr'wdir()' data
1042 add0:2147483647:data0
1043 add0-cp1:2147483647:data0
1044 add0-cp1-cp3:2147483647:data0
1045 add0-cp1-mod1:2147483647:data0
1046 add0-cp1-mod1:2147483647:data1
1047 add0-cp1-mod1-cp3-mod3:2147483647:data0
1048 add0-cp1-mod1-cp3-mod3:2147483647:data1
1049 add0-cp1-mod1-cp3-mod3:2147483647:data3
1050 add0-cp4:2147483647:data0
1051 add0-cp4-mod4:2147483647:data0
1052 add0-cp4-mod4:2147483647:data4
1053 add0-mod1:2147483647:data0
1054 add0-mod1:2147483647:data1
1055 add0-mod2:2147483647:data0
1056 add0-mod3:2147483647:data0
1057 add0-mod3:2147483647:data3
1058 add0-mod4:2147483647:data0
1059 add0-mod4:2147483647:data4
1060 add0-rm2:2147483647:data0
1061 add0:3:data0
1062 add0-cp1:3:data0
1063 add0-cp1-cp3:3:data0
1064 add0-cp1-mod1:3:data0
1065 add0-cp1-mod1:3:data1
1066 add0-cp1-mod1-cp3-mod3:3:data0
1067 add0-cp1-mod1-cp3-mod3:3:data1
1068 add0-cp1-mod1-cp3-mod3:3:data3
1069 add0-mod1:3:data0
1070 add0-mod1:3:data1
1071 add0-mod2:3:data0
1072 add0-mod3:3:data0
1073 add0-mod3:3:data3
1074 add0-mod4:3:data0
1075 add0-rm2:3:data0
1076 add0-rm4:3:data0
1077 add0:1:data0
1078 add0-cp1:1:data0
1079 add0-cp1-mod1:1:data0
1080 add0-cp1-mod1:1:data1
1081 add0-cp1-mod1-rm3:1:data0
1082 add0-cp1-mod1-rm3:1:data1
1083 add0-mod1:1:data0
1084 add0-mod1:1:data1
1085 add0-mod2:1:data0
1086 add0-mod3:1:data0
1087 add0-mod4:1:data0
1088 add0-rm2:1:data0
1089 add0-rm4:1:data0
1090 add0:0:data0
1091 add0-mod1:0:data0
1092 add0-mod2:0:data0
1093 add0-mod3:0:data0
1094 add0-mod4:0:data0
1095 add0-rm1:0:data0
1096 add0-rm2:0:data0
1097 add0-rm4:0:data0
1098
1099 follow revision history from multiple revisions:
1100
1101 $ hg log -fr'1+2'
1102 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1103 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1104 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1105
1106 $ hg grep --diff -fr'1+2' data
1107 add0-cp2-mod2:2:+:data2
1108 add0-mod2:2:+:data2
1109 add0-cp1-mod1:1:+:data1
1110 add0-cp1-mod1-rm3:1:+:data1
1111 add0-mod1:1:+:data1
1112 add0:0:+:data0
1113 add0-mod1:0:+:data0
1114 add0-mod2:0:+:data0
1115 add0-mod3:0:+:data0
1116 add0-mod4:0:+:data0
1117 add0-rm1:0:+:data0
1118 add0-rm2:0:+:data0
1119 add0-rm4:0:+:data0
1120
1121 $ hg grep -fr'1+2' data
1122 add0:2:data0
1123 add0-cp2:2:data0
1124 add0-cp2-mod2:2:data0
1125 add0-cp2-mod2:2:data2
1126 add0-mod1:2:data0
1127 add0-mod2:2:data0
1128 add0-mod2:2:data2
1129 add0-mod3:2:data0
1130 add0-mod4:2:data0
1131 add0-rm1:2:data0
1132 add0-rm4:2:data0
1133 add0:1:data0
1134 add0-cp1:1:data0
1135 add0-cp1-mod1:1:data0
1136 add0-cp1-mod1:1:data1
1137 add0-cp1-mod1-rm3:1:data0
1138 add0-cp1-mod1-rm3:1:data1
1139 add0-mod1:1:data0
1140 add0-mod1:1:data1
1141 add0-mod2:1:data0
1142 add0-mod3:1:data0
1143 add0-mod4:1:data0
1144 add0-rm2:1:data0
1145 add0-rm4:1:data0
1146 add0:0:data0
1147 add0-mod1:0:data0
1148 add0-mod2:0:data0
1149 add0-mod3:0:data0
1150 add0-mod4:0:data0
1151 add0-rm1:0:data0
1152 add0-rm2:0:data0
1153 add0-rm4:0:data0
1154
1155 follow file history from wdir parent, unmodified in wdir:
1156
1157 $ hg log -f add0-mod3
1158 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1159 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1160
1161 $ hg grep --diff -f data add0-mod3
1162 add0-mod3:3:+:data3
1163 add0-mod3:0:+:data0
1164
1165 $ hg grep -f data add0-mod3
1166 add0-mod3:3:data0
1167 add0-mod3:3:data3
1168 add0-mod3:1:data0
1169 add0-mod3:0:data0
1170
1171 follow file history from wdir parent, modified in wdir:
1172
1173 $ hg log -f add0-mod4
1174 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1175
1176 $ hg grep --diff -f data add0-mod4
1177 add0-mod4:0:+:data0
1178
1179 $ hg grep -f data add0-mod4
1180 add0-mod4:3:data0
1181 add0-mod4:1:data0
1182 add0-mod4:0:data0
1183
1184 follow file history from wdir parent, copied but unmodified:
1185
1186 $ hg log -f add0-cp1-cp3
1187 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1188 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1189 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1190
1191 $ hg grep --diff -f data add0-cp1-cp3
1192 add0:0:+:data0
1193
1194 BROKEN: should follow history across renames
1195 $ hg grep -f data add0-cp1-cp3
1196 add0-cp1-cp3:3:data0
1197
1198 follow file history from wdir parent, copied and modified:
1199
1200 $ hg log -f add0-cp1-mod1-cp3-mod3
1201 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1202 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1203 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1204
1205 $ hg grep --diff -f data add0-cp1-mod1-cp3-mod3
1206 add0-cp1-mod1-cp3-mod3:3:+:data3
1207 add0-cp1-mod1:1:+:data1
1208 add0:0:+:data0
1209
1210 BROKEN: should follow history across renames
1211 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1212 add0-cp1-mod1-cp3-mod3:3:data0
1213 add0-cp1-mod1-cp3-mod3:3:data1
1214 add0-cp1-mod1-cp3-mod3:3:data3
1215
1216 follow file history from wdir parent, copied in wdir:
1217
1218 $ hg log -f add0-cp4
1219 abort: cannot follow nonexistent file: "add0-cp4"
1220 [20]
1221
1222 $ hg grep --diff -f data add0-cp4
1223 abort: cannot follow nonexistent file: "add0-cp4"
1224 [20]
1225
1226 BROKEN: maybe better to abort
1227 $ hg grep -f data add0-cp4
1228 [1]
1229
1230 follow file history from wdir parent, removed:
1231
1232 $ hg log -f add0-cp1-mod1-rm3
1233 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1234 [20]
1235
1236 $ hg grep --diff -f data add0-cp1-mod1-rm3
1237 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1238 [20]
1239
1240 BROKEN: maybe better to abort
1241 $ hg grep -f data add0-cp1-mod1-rm3
1242 add0-cp1-mod1-rm3:1:data0
1243 add0-cp1-mod1-rm3:1:data1
1244
1245 follow file history from wdir parent (explicit), removed:
1246
1247 $ hg log -fr. add0-cp1-mod1-rm3
1248 abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
1249 [20]
1250
1251 $ hg grep --diff -fr. data add0-cp1-mod1-rm3
1252 abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
1253 [20]
1254
1255 BROKEN: should abort
1256 $ hg grep -fr. data add0-cp1-mod1-rm3
1257 add0-cp1-mod1-rm3:1:data0
1258 add0-cp1-mod1-rm3:1:data1
1259
1260 follow file history from wdir parent, removed in wdir:
1261
1262 $ hg log -f add0-rm4
1263 abort: cannot follow file not in parent revision: "add0-rm4"
1264 [20]
1265
1266 $ hg grep --diff -f data add0-rm4
1267 abort: cannot follow file not in parent revision: "add0-rm4"
1268 [20]
1269
1270 BROKEN: should abort
1271 $ hg grep -f data add0-rm4
1272 add0-rm4:3:data0
1273 add0-rm4:1:data0
1274 add0-rm4:0:data0
1275
1276 follow file history from wdir parent (explicit), removed in wdir:
1277
1278 $ hg log -fr. add0-rm4
1279 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1280
1281 $ hg grep --diff -fr. data add0-rm4
1282 add0-rm4:0:+:data0
1283
1284 $ hg grep -fr. data add0-rm4
1285 add0-rm4:3:data0
1286 add0-rm4:1:data0
1287 add0-rm4:0:data0
1288
1289 follow file history from wdir parent, multiple files:
1290
1291 $ hg log -f add0-mod3 add0-cp1-mod1
1292 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1293 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1294 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1295
1296 $ hg grep --diff -f data add0-mod3 add0-cp1-mod1
1297 add0-mod3:3:+:data3
1298 add0-cp1-mod1:1:+:data1
1299 add0:0:+:data0
1300 add0-mod3:0:+:data0
1301
1302 BROKEN: should follow history across renames
1303 $ hg grep -f data add0-mod3 add0-cp1-mod1
1304 add0-cp1-mod1:3:data0
1305 add0-cp1-mod1:3:data1
1306 add0-mod3:3:data0
1307 add0-mod3:3:data3
1308 add0-cp1-mod1:1:data0
1309 add0-cp1-mod1:1:data1
1310 add0-mod3:1:data0
1311 add0-mod3:0:data0
1312
1313 follow file history from specified revision, modified:
1314
1315 $ hg log -fr2 add0-mod2
1316 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1317 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1318
1319 $ hg grep --diff -fr2 data add0-mod2
1320 add0-mod2:2:+:data2
1321 add0-mod2:0:+:data0
1322
1323 $ hg grep -fr2 data add0-mod2
1324 add0-mod2:2:data0
1325 add0-mod2:2:data2
1326 add0-mod2:0:data0
1327
1328 follow file history from specified revision, copied but unmodified:
1329
1330 $ hg log -fr2 add0-cp2
1331 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1332 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1333
1334 $ hg grep --diff -fr2 data add0-cp2
1335 add0:0:+:data0
1336
1337 BROKEN: should follow history across renames
1338 $ hg grep -fr2 data add0-cp2
1339 add0-cp2:2:data0
1340
1341 follow file history from specified revision, copied and modified:
1342
1343 $ hg log -fr2 add0-cp2-mod2
1344 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1345 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1346
1347 $ hg grep --diff -fr2 data add0-cp2-mod2
1348 add0-cp2-mod2:2:+:data2
1349 add0:0:+:data0
1350
1351 BROKEN: should follow history across renames
1352 $ hg grep -fr2 data add0-cp2-mod2
1353 add0-cp2-mod2:2:data0
1354 add0-cp2-mod2:2:data2
1355
1356 follow file history from specified revision, removed:
1357
1358 $ hg log -fr2 add0-rm2
1359 abort: cannot follow file not in any of the specified revisions: "add0-rm2"
1360 [20]
1361
1362 $ hg grep --diff -fr2 data add0-rm2
1363 abort: cannot follow file not in any of the specified revisions: "add0-rm2"
1364 [20]
1365
1366 BROKEN: should abort
1367 $ hg grep -fr2 data add0-rm2
1368 add0-rm2:0:data0
1369
1370 follow file history from specified revision, multiple files:
1371
1372 $ hg log -fr2 add0-cp2 add0-mod2
1373 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1374 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1375
1376 $ hg grep --diff -fr2 data add0-cp2 add0-mod2
1377 add0-mod2:2:+:data2
1378 add0:0:+:data0
1379 add0-mod2:0:+:data0
1380
1381 BROKEN: should follow history across renames
1382 $ hg grep -fr2 data add0-cp2 add0-mod2
1383 add0-cp2:2:data0
1384 add0-mod2:2:data0
1385 add0-mod2:2:data2
1386 add0-mod2:0:data0
1387
1388 follow file history from wdir, unmodified:
1389
1390 $ hg log -fr'wdir()' add0-mod3
1391 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1392 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1393 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1394
1395 $ hg grep --diff -fr'wdir()' data add0-mod3
1396 add0-mod3:3:+:data3
1397 add0-mod3:0:+:data0
1398
1399 $ hg grep -fr'wdir()' data add0-mod3
1400 add0-mod3:2147483647:data0
1401 add0-mod3:2147483647:data3
1402 add0-mod3:3:data0
1403 add0-mod3:3:data3
1404 add0-mod3:1:data0
1405 add0-mod3:0:data0
1406
1407 follow file history from wdir, modified:
1408
1409 $ hg log -fr'wdir()' add0-mod4
1410 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1411 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1412
1413 $ hg grep --diff -fr'wdir()' data add0-mod4
1414 add0-mod4:2147483647:+:data4
1415 add0-mod4:0:+:data0
1416
1417 $ hg grep -fr'wdir()' data add0-mod4
1418 add0-mod4:2147483647:data0
1419 add0-mod4:2147483647:data4
1420 add0-mod4:3:data0
1421 add0-mod4:1:data0
1422 add0-mod4:0:data0
1423
1424 follow file history from wdir, copied but unmodified:
1425
1426 $ hg log -fr'wdir()' add0-cp4
1427 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1428 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1429
1430 $ hg grep --diff -fr'wdir()' data add0-cp4
1431 add0:0:+:data0
1432
1433 BROKEN: should follow history across renames
1434 $ hg grep -fr'wdir()' data add0-cp4
1435 add0-cp4:2147483647:data0
1436
1437 follow file history from wdir, copied and modified:
1438
1439 $ hg log -fr'wdir()' add0-cp4-mod4
1440 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1441 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1442
1443 $ hg grep --diff -fr'wdir()' data add0-cp4-mod4
1444 add0-cp4-mod4:2147483647:+:data4
1445 add0:0:+:data0
1446
1447 BROKEN: should follow history across renames
1448 $ hg grep -fr'wdir()' data add0-cp4-mod4
1449 add0-cp4-mod4:2147483647:data0
1450 add0-cp4-mod4:2147483647:data4
1451
1452 follow file history from wdir, multiple files:
1453
1454 $ hg log -fr'wdir()' add0-cp4 add0-mod4 add0-mod3
1455 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1456 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1457 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1458
1459 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1460 add0-mod4:2147483647:+:data4
1461 add0-mod3:3:+:data3
1462 add0:0:+:data0
1463 add0-mod3:0:+:data0
1464 add0-mod4:0:+:data0
1465
1466 BROKEN: should follow history across renames
1467 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1468 add0-cp4:2147483647:data0
1469 add0-mod3:2147483647:data0
1470 add0-mod3:2147483647:data3
1471 add0-mod4:2147483647:data0
1472 add0-mod4:2147483647:data4
1473 add0-mod3:3:data0
1474 add0-mod3:3:data3
1475 add0-mod4:3:data0
1476 add0-mod3:1:data0
1477 add0-mod4:1:data0
1478 add0-mod3:0:data0
1479 add0-mod4:0:data0
1480
1481 $ cd ..