##// END OF EJS Templates
test-grep: add tests for --follow with/without --diff and/or paths...
Yuya Nishihara -
r46049:20dd2a25 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (516 lines changed) Show them Hide them
@@ -1,815 +1,1331
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 diff of each revision for reference
325 325
326 326 $ hg log -p -T'== rev: {rev} ==\n'
327 327 == rev: 4 ==
328 328 diff -r 95040cfd017d -r 914fa752cdea port
329 329 --- a/port Thu Jan 01 00:00:03 1970 +0000
330 330 +++ b/port Thu Jan 01 00:00:04 1970 +0000
331 331 @@ -1,4 +1,3 @@
332 332 export
333 333 vaportight
334 334 import/export
335 335 -import/export
336 336
337 337 == rev: 3 ==
338 338 diff -r 3b325e3481a1 -r 95040cfd017d port
339 339 --- a/port Thu Jan 01 00:00:02 1970 +0000
340 340 +++ b/port Thu Jan 01 00:00:03 1970 +0000
341 341 @@ -1,3 +1,4 @@
342 342 export
343 343 vaportight
344 344 import/export
345 345 +import/export
346 346
347 347 == rev: 2 ==
348 348 diff -r 8b20f75c1585 -r 3b325e3481a1 port
349 349 --- a/port Thu Jan 01 00:00:01 1970 +0000
350 350 +++ b/port Thu Jan 01 00:00:02 1970 +0000
351 351 @@ -1,2 +1,3 @@
352 352 -import
353 353 export
354 354 +vaportight
355 355 +import/export
356 356
357 357 == rev: 1 ==
358 358 diff -r f31323c92170 -r 8b20f75c1585 port
359 359 --- a/port Thu Jan 01 00:00:00 1970 +0000
360 360 +++ b/port Thu Jan 01 00:00:01 1970 +0000
361 361 @@ -1,1 +1,2 @@
362 362 import
363 363 +export
364 364
365 365 == rev: 0 ==
366 366 diff -r 000000000000 -r f31323c92170 port
367 367 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
368 368 +++ b/port Thu Jan 01 00:00:00 1970 +0000
369 369 @@ -0,0 +1,1 @@
370 370 +import
371 371
372 372
373 373 all
374 374
375 375 $ hg grep --traceback --all -nu port port
376 376 port:4:4:-:spam:import/export
377 377 port:3:4:+:eggs:import/export
378 378 port:2:1:-:spam:import
379 379 port:2:2:+:spam:vaportight
380 380 port:2:3:+:spam:import/export
381 381 port:1:2:+:eggs:export
382 382 port:0:1:+:spam:import
383 383
384 384 all JSON
385 385
386 386 $ hg grep --all -Tjson port port
387 387 [
388 388 {
389 389 "change": "-",
390 390 "date": [4, 0],
391 391 "lineno": 4,
392 392 "node": "914fa752cdea87777ac1a8d5c858b0c736218f6c",
393 393 "path": "port",
394 394 "rev": 4,
395 395 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
396 396 "user": "spam"
397 397 },
398 398 {
399 399 "change": "+",
400 400 "date": [3, 0],
401 401 "lineno": 4,
402 402 "node": "95040cfd017d658c536071c6290230a613c4c2a6",
403 403 "path": "port",
404 404 "rev": 3,
405 405 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
406 406 "user": "eggs"
407 407 },
408 408 {
409 409 "change": "-",
410 410 "date": [2, 0],
411 411 "lineno": 1,
412 412 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
413 413 "path": "port",
414 414 "rev": 2,
415 415 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
416 416 "user": "spam"
417 417 },
418 418 {
419 419 "change": "+",
420 420 "date": [2, 0],
421 421 "lineno": 2,
422 422 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
423 423 "path": "port",
424 424 "rev": 2,
425 425 "texts": [{"matched": false, "text": "va"}, {"matched": true, "text": "port"}, {"matched": false, "text": "ight"}],
426 426 "user": "spam"
427 427 },
428 428 {
429 429 "change": "+",
430 430 "date": [2, 0],
431 431 "lineno": 3,
432 432 "node": "3b325e3481a1f07435d81dfdbfa434d9a0245b47",
433 433 "path": "port",
434 434 "rev": 2,
435 435 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}, {"matched": false, "text": "/ex"}, {"matched": true, "text": "port"}],
436 436 "user": "spam"
437 437 },
438 438 {
439 439 "change": "+",
440 440 "date": [1, 0],
441 441 "lineno": 2,
442 442 "node": "8b20f75c158513ff5ac80bd0e5219bfb6f0eb587",
443 443 "path": "port",
444 444 "rev": 1,
445 445 "texts": [{"matched": false, "text": "ex"}, {"matched": true, "text": "port"}],
446 446 "user": "eggs"
447 447 },
448 448 {
449 449 "change": "+",
450 450 "date": [0, 0],
451 451 "lineno": 1,
452 452 "node": "f31323c9217050ba245ee8b537c713ec2e8ab226",
453 453 "path": "port",
454 454 "rev": 0,
455 455 "texts": [{"matched": false, "text": "im"}, {"matched": true, "text": "port"}],
456 456 "user": "spam"
457 457 }
458 458 ]
459 459
460 460 other
461 461
462 462 $ hg grep -r tip:0 -l port port
463 463 port:4
464 464 port:3
465 465 port:2
466 466 port:1
467 467 port:0
468 468 $ hg grep -r tip:0 import port
469 469 port:4:import/export
470 470 port:3:import/export
471 471 port:3:import/export
472 472 port:2:import/export
473 473 port:1:import
474 474 port:0:import
475 475
476 476 $ hg cp port port2
477 477 $ hg commit -m 4 -u spam -d '5 0'
478 478
479 479 follow
480 480
481 481 $ hg grep -r tip:0 --traceback -f 'import\n\Z' port2
482 482 [1]
483 483 $ echo deport >> port2
484 484 $ hg commit -m 5 -u eggs -d '6 0'
485 485 $ hg grep -f --all -nu port port2
486 486 port2:6:4:+:eggs:deport
487 487 port:4:4:-:spam:import/export
488 488 port:3:4:+:eggs:import/export
489 489 port:2:1:-:spam:import
490 490 port:2:2:+:spam:vaportight
491 491 port:2:3:+:spam:import/export
492 492 port:1:2:+:eggs:export
493 493 port:0:1:+:spam:import
494 494
495 495 $ hg up -q null
496 496 $ hg grep -r 'reverse(:.)' -f port
497 497 port:0:import
498 498
499 499 Test wdir
500 500 (at least, this shouldn't crash)
501 501
502 502 $ hg up -q
503 503 $ echo wport >> port2
504 504 $ hg stat
505 505 M port2
506 506 $ hg grep -r 'wdir()' port
507 507 port:2147483647:export
508 508 port:2147483647:vaportight
509 509 port:2147483647:import/export
510 510 port2:2147483647:export
511 511 port2:2147483647:vaportight
512 512 port2:2147483647:import/export
513 513 port2:2147483647:deport
514 514 port2:2147483647:wport
515 515
516 516 $ cd ..
517 517 $ hg init t2
518 518 $ cd t2
519 519 $ hg grep -r tip:0 foobar foo
520 520 [1]
521 521 $ hg grep -r tip:0 foobar
522 522 [1]
523 523 $ echo blue >> color
524 524 $ echo black >> color
525 525 $ hg add color
526 526 $ hg ci -m 0
527 527 $ echo orange >> color
528 528 $ hg ci -m 1
529 529 $ echo black > color
530 530 $ hg ci -m 2
531 531 $ echo orange >> color
532 532 $ echo blue >> color
533 533 $ hg ci -m 3
534 534 $ hg grep -r tip:0 orange
535 535 color:3:orange
536 536 color:1:orange
537 537 $ hg grep --all orange
538 538 color:3:+:orange
539 539 color:2:-:orange
540 540 color:1:+:orange
541 541 $ hg grep --diff orange --color=debug
542 542 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
543 543 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.deleted grep.change|-][grep.sep|:][grep.match|orange]
544 544 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.inserted grep.change|+][grep.sep|:][grep.match|orange]
545 545
546 546 $ hg grep --diff orange --color=yes
547 547 \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)
548 548 \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)
549 549 \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)
550 550
551 551 $ hg grep --diff orange
552 552 color:3:+:orange
553 553 color:2:-:orange
554 554 color:1:+:orange
555 555
556 556 test substring match: '^' should only match at the beginning
557 557
558 558 $ hg grep -r tip:0 '^.' --config extensions.color= --color debug
559 559 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lack
560 560 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|o]range
561 561 [grep.filename|color][grep.sep|:][grep.rev|3][grep.sep|:][grep.match|b]lue
562 562 [grep.filename|color][grep.sep|:][grep.rev|2][grep.sep|:][grep.match|b]lack
563 563 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lue
564 564 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|b]lack
565 565 [grep.filename|color][grep.sep|:][grep.rev|1][grep.sep|:][grep.match|o]range
566 566 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lue
567 567 [grep.filename|color][grep.sep|:][grep.rev|0][grep.sep|:][grep.match|b]lack
568 568
569 569 match in last "line" without newline
570 570
571 571 $ "$PYTHON" -c 'fp = open("noeol", "wb"); fp.write(b"no infinite loop"); fp.close();'
572 572 $ hg ci -Amnoeol
573 573 adding noeol
574 574 $ hg grep -r tip:0 loop
575 575 noeol:4:no infinite loop
576 576
577 577 $ cd ..
578 578
579 579 Issue685: traceback in grep -r after rename
580 580
581 581 Got a traceback when using grep on a single
582 582 revision with renamed files.
583 583
584 584 $ hg init issue685
585 585 $ cd issue685
586 586 $ echo octarine > color
587 587 $ hg ci -Amcolor
588 588 adding color
589 589 $ hg rename color colour
590 590 $ hg ci -Am rename
591 591 $ hg grep -r tip:0 octarine
592 592 colour:1:octarine
593 593 color:0:octarine
594 594
595 595 Used to crash here
596 596
597 597 $ hg grep -r 1 octarine
598 598 colour:1:octarine
599 599 $ cd ..
600 600
601 601
602 602 Issue337: test that grep follows parent-child relationships instead
603 603 of just using revision numbers.
604 604
605 605 $ hg init issue337
606 606 $ cd issue337
607 607
608 608 $ echo white > color
609 609 $ hg commit -A -m "0 white"
610 610 adding color
611 611
612 612 $ echo red > color
613 613 $ hg commit -A -m "1 red"
614 614
615 615 $ hg update 0
616 616 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
617 617 $ echo black > color
618 618 $ hg commit -A -m "2 black"
619 619 created new head
620 620
621 621 $ hg update --clean 1
622 622 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
623 623 $ echo blue > color
624 624 $ hg commit -A -m "3 blue"
625 625
626 626 $ hg grep --all red
627 627 color:3:-:red
628 628 color:1:+:red
629 629
630 630 $ hg grep --diff red
631 631 color:3:-:red
632 632 color:1:+:red
633 633
634 634 Issue3885: test that changing revision order does not alter the
635 635 revisions printed, just their order.
636 636
637 637 $ hg grep --all red -r "all()"
638 638 color:1:+:red
639 639 color:3:-:red
640 640
641 641 $ hg grep --all red -r "reverse(all())"
642 642 color:3:-:red
643 643 color:1:+:red
644 644
645 645 $ hg grep --diff red -r "all()"
646 646 color:1:+:red
647 647 color:3:-:red
648 648
649 649 $ hg grep --diff red -r "reverse(all())"
650 650 color:3:-:red
651 651 color:1:+:red
652 652
653 653 $ cd ..
654 654
655 655 $ hg init a
656 656 $ cd a
657 657 $ cp "$TESTDIR/binfile.bin" .
658 658 $ hg add binfile.bin
659 659 $ hg ci -m 'add binfile.bin'
660 660 $ hg grep "MaCam" --all
661 661 binfile.bin:0:+: Binary file matches
662 662
663 663 $ hg grep "MaCam" --diff
664 664 binfile.bin:0:+: Binary file matches
665 665
666 666 $ cd ..
667 667
668 668 Moved line may not be collected by "grep --diff" since it first filters
669 669 the contents to be diffed by the pattern. (i.e.
670 670 "diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".)
671 671 This is much faster than generating full diff per revision.
672 672
673 673 $ hg init moved-line
674 674 $ cd moved-line
675 675 $ cat <<'EOF' > a
676 676 > foo
677 677 > bar
678 678 > baz
679 679 > EOF
680 680 $ hg ci -Am initial
681 681 adding a
682 682 $ cat <<'EOF' > a
683 683 > bar
684 684 > baz
685 685 > foo
686 686 > EOF
687 687 $ hg ci -m reorder
688 688
689 689 $ hg diff -c 1
690 690 diff -r a593cc55e81b -r 69789a3b6e80 a
691 691 --- a/a Thu Jan 01 00:00:00 1970 +0000
692 692 +++ b/a Thu Jan 01 00:00:00 1970 +0000
693 693 @@ -1,3 +1,3 @@
694 694 -foo
695 695 bar
696 696 baz
697 697 +foo
698 698
699 699 can't find the move of "foo" at the revision 1:
700 700
701 701 $ hg grep --diff foo -r1
702 702 [1]
703 703
704 704 "bar" isn't moved at the revisoin 1:
705 705
706 706 $ hg grep --diff bar -r1
707 707 [1]
708 708
709 709 $ cd ..
710 710
711 711 Test for showing working of allfiles flag
712 712
713 713 $ hg init sng
714 714 $ cd sng
715 715 $ echo "unmod" >> um
716 716 $ echo old > old
717 717 $ hg ci -q -A -m "adds unmod to um"
718 718 $ echo "something else" >> new
719 719 $ hg ci -A -m "second commit"
720 720 adding new
721 721 $ hg grep -r "." "unmod"
722 722 um:1:unmod
723 723
724 724 Existing tracked files in the working directory are searched by default
725 725
726 726 $ echo modified >> new
727 727 $ echo 'added' > added; hg add added
728 728 $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
729 729 $ echo 'untracked' > untracked
730 730 $ hg rm old
731 731 $ hg grep ''
732 732 added:added
733 733 new:something else
734 734 new:modified
735 735 um:unmod
736 736
737 737 #if symlink
738 738 Grepping a symlink greps its destination
739 739
740 740 $ rm -f added; ln -s symlink-added added
741 741 $ hg grep '' | grep added
742 742 added:symlink-added
743 743
744 744 But we reject symlinks as directories components of a tracked file as
745 745 usual:
746 746
747 747 $ mkdir dir; touch dir/f; hg add dir/f
748 748 $ rm -rf dir; ln -s / dir
749 749 $ hg grep ''
750 750 abort: path 'dir/f' traverses symbolic link 'dir'
751 751 [255]
752 752 #endif
753 753
754 754 But we can search files from some other revision with -rREV
755 755
756 756 $ hg grep -r. mod
757 757 um:1:unmod
758 758
759 759 $ hg grep --diff mod
760 760 um:0:+:unmod
761 761
762 762 $ cd ..
763 763
764 764 Change Default of grep by ui.tweakdefaults, that is, the files not in current
765 765 working directory should not be grepp-ed on
766 766
767 767 $ hg init ab
768 768 $ cd ab
769 769 $ cat <<'EOF' >> .hg/hgrc
770 770 > [ui]
771 771 > tweakdefaults = True
772 772 > EOF
773 773 $ echo "some text">>file1
774 774 $ hg add file1
775 775 $ hg commit -m "adds file1"
776 776 $ hg mv file1 file2
777 777
778 778 wdir revision is hidden by default:
779 779
780 780 $ hg grep "some"
781 781 file2:some text
782 782
783 783 but it should be available in template dict:
784 784
785 785 $ hg grep "some" -Tjson
786 786 [
787 787 {
788 788 "date": [0, 0],
789 789 "lineno": 1,
790 790 "node": "ffffffffffffffffffffffffffffffffffffffff",
791 791 "path": "file2",
792 792 "rev": 2147483647,
793 793 "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
794 794 "user": "test"
795 795 }
796 796 ]
797 797
798 798 $ cd ..
799 799
800 800 test -rMULTIREV
801 801
802 802 $ cd sng
803 803 $ hg rm um
804 804 $ hg commit -m "deletes um"
805 805 $ hg grep -r "0:2" "unmod"
806 806 um:0:unmod
807 807 um:1:unmod
808 808 $ hg grep -r "0:2" "unmod" um
809 809 um:0:unmod
810 810 um:1:unmod
811 811 $ hg grep -r "0:2" "unmod" "glob:**/um" # Check that patterns also work
812 812 um:0:unmod
813 813 um:1:unmod
814 814 $ cd ..
815 815
816 --follow with/without --diff and/or paths
817 -----------------------------------------
818
819 For each test case, we compare the history traversal of "hg log",
820 "hg grep --diff", and "hg grep" (--all-files).
821
822 "hg grep --diff" should traverse the log in the same way as "hg log".
823 "hg grep" (--all-files) is slightly different in that it includes
824 unmodified changes.
825
826 $ hg init follow
827 $ cd follow
828
829 $ cat <<'EOF' >> .hg/hgrc
830 > [ui]
831 > logtemplate = '{rev}: {join(files % "{status} {path}", ", ")}\n'
832 > EOF
833
834 $ for f in add0 add0-mod1 add0-rm1 add0-mod2 add0-rm2 add0-mod3 add0-mod4 add0-rm4; do
835 > echo data0 >> $f
836 > done
837 $ hg ci -qAm0
838
839 $ hg cp add0 add0-cp1
840 $ hg cp add0 add0-cp1-mod1
841 $ hg cp add0 add0-cp1-mod1-rm3
842 $ hg rm add0-rm1
843 $ for f in *mod1*; do
844 > echo data1 >> $f
845 > done
846 $ hg ci -qAm1
847
848 $ hg update -q 0
849 $ hg cp add0 add0-cp2
850 $ hg cp add0 add0-cp2-mod2
851 $ hg rm add0-rm2
852 $ for f in *mod2*; do
853 > echo data2 >> $f
854 > done
855 $ hg ci -qAm2
856
857 $ hg update -q 1
858 $ hg cp add0-cp1 add0-cp1-cp3
859 $ hg cp add0-cp1-mod1 add0-cp1-mod1-cp3-mod3
860 $ hg rm add0-cp1-mod1-rm3
861 $ for f in *mod3*; do
862 > echo data3 >> $f
863 > done
864 $ hg ci -qAm3
865
866 $ hg cp add0 add0-cp4
867 $ hg cp add0 add0-cp4-mod4
868 $ hg rm add0-rm4
869 $ for f in *mod4*; do
870 > echo data4 >> $f
871 > done
872
873 $ hg log -Gr':wdir()'
874 o 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
875 |
876 @ 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
877 |
878 | o 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
879 | |
880 o | 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
881 |/
882 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
883
884
885 follow revision history from wdir parent:
886
887 $ hg log -f
888 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
889 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
890 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
891
892 $ hg grep --diff -f data
893 add0-cp1-mod1-cp3-mod3:3:+:data3
894 add0-mod3:3:+:data3
895 add0-cp1-mod1:1:+:data1
896 add0-cp1-mod1-rm3:1:+:data1
897 add0-mod1:1:+:data1
898 add0:0:+:data0
899 add0-mod1:0:+:data0
900 add0-mod2:0:+:data0
901 add0-mod3:0:+:data0
902 add0-mod4:0:+:data0
903 add0-rm1:0:+:data0
904 add0-rm2:0:+:data0
905 add0-rm4:0:+:data0
906
907 BROKEN: should not fall back to plain grep
908 $ hg grep -f data
909 add0:data0
910 add0-cp1:data0
911 add0-cp1-cp3:data0
912 add0-cp1-mod1:data0
913 add0-cp1-mod1:data1
914 add0-cp1-mod1-cp3-mod3:data0
915 add0-cp1-mod1-cp3-mod3:data1
916 add0-cp1-mod1-cp3-mod3:data3
917 add0-cp4:data0
918 add0-cp4-mod4:data0
919 add0-cp4-mod4:data4
920 add0-mod1:data0
921 add0-mod1:data1
922 add0-mod2:data0
923 add0-mod3:data0
924 add0-mod3:data3
925 add0-mod4:data0
926 add0-mod4:data4
927 add0-rm2:data0
928
929 follow revision history from specified revision:
930
931 $ hg log -fr2
932 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
933 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
934
935 BROKEN: should follow history
936 $ hg grep --diff -fr2 data
937 add0-cp2-mod2:2:+:data2
938 add0-mod2:2:+:data2
939
940 BROKEN: should follow history
941 $ hg grep -fr2 data
942 add0:2:data0
943 add0-cp2:2:data0
944 add0-cp2-mod2:2:data0
945 add0-cp2-mod2:2:data2
946 add0-mod1:2:data0
947 add0-mod2:2:data0
948 add0-mod2:2:data2
949 add0-mod3:2:data0
950 add0-mod4:2:data0
951 add0-rm1:2:data0
952 add0-rm4:2:data0
953
954 follow revision history from wdir:
955
956 $ hg log -fr'wdir()'
957 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
958 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
959 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
960 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
961
962 BROKEN: should follow history
963 BROKEN: should not abort because of removed file
964 $ hg grep --diff -fr'wdir()' data
965 add0-cp4-mod4:2147483647:+:data4
966 add0-mod4:2147483647:+:data4
967 add0-rm4:2147483647:-:abort: add0-rm4@None: not found in manifest!
968 [255]
969
970 BROKEN: should follow history
971 $ hg grep -fr'wdir()' data
972 add0:2147483647:data0
973 add0-cp1:2147483647:data0
974 add0-cp1-cp3:2147483647:data0
975 add0-cp1-mod1:2147483647:data0
976 add0-cp1-mod1:2147483647:data1
977 add0-cp1-mod1-cp3-mod3:2147483647:data0
978 add0-cp1-mod1-cp3-mod3:2147483647:data1
979 add0-cp1-mod1-cp3-mod3:2147483647:data3
980 add0-cp4:2147483647:data0
981 add0-cp4-mod4:2147483647:data0
982 add0-cp4-mod4:2147483647:data4
983 add0-mod1:2147483647:data0
984 add0-mod1:2147483647:data1
985 add0-mod2:2147483647:data0
986 add0-mod3:2147483647:data0
987 add0-mod3:2147483647:data3
988 add0-mod4:2147483647:data0
989 add0-mod4:2147483647:data4
990 add0-rm2:2147483647:data0
991
992 follow revision history from multiple revisions:
993
994 $ hg log -fr'1+2'
995 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
996 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
997 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
998
999 BROKEN: should follow history
1000 BROKEN: should include the revision 2
1001 $ hg grep --diff -fr'1+2' data
1002 add0-cp1-mod1:1:+:data1
1003 add0-cp1-mod1-rm3:1:+:data1
1004 add0-mod1:1:+:data1
1005
1006 BROKEN: should follow history
1007 BROKEN: should include the revision 2
1008 $ hg grep -fr'1+2' data
1009 add0:1:data0
1010 add0-cp1:1:data0
1011 add0-cp1-mod1:1:data0
1012 add0-cp1-mod1:1:data1
1013 add0-cp1-mod1-rm3:1:data0
1014 add0-cp1-mod1-rm3:1:data1
1015 add0-mod1:1:data0
1016 add0-mod1:1:data1
1017 add0-mod2:1:data0
1018 add0-mod3:1:data0
1019 add0-mod4:1:data0
1020 add0-rm2:1:data0
1021 add0-rm4:1:data0
1022
1023 follow file history from wdir parent, unmodified in wdir:
1024
1025 $ hg log -f add0-mod3
1026 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1027 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1028
1029 $ hg grep --diff -f data add0-mod3
1030 add0-mod3:3:+:data3
1031 add0-mod3:0:+:data0
1032
1033 BROKEN: should not fall back to plain grep
1034 $ hg grep -f data add0-mod3
1035 add0-mod3:data0
1036 add0-mod3:data3
1037
1038 follow file history from wdir parent, modified in wdir:
1039
1040 $ hg log -f add0-mod4
1041 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1042
1043 $ hg grep --diff -f data add0-mod4
1044 add0-mod4:0:+:data0
1045
1046 BROKEN: should not fall back to plain grep
1047 $ hg grep -f data add0-mod4
1048 add0-mod4:data0
1049 add0-mod4:data4
1050
1051 follow file history from wdir parent, copied but unmodified:
1052
1053 $ hg log -f add0-cp1-cp3
1054 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1055 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1056 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1057
1058 $ hg grep --diff -f data add0-cp1-cp3
1059 add0:0:+:data0
1060
1061 BROKEN: should not fall back to plain grep
1062 $ hg grep -f data add0-cp1-cp3
1063 add0-cp1-cp3:data0
1064
1065 follow file history from wdir parent, copied and modified:
1066
1067 $ hg log -f add0-cp1-mod1-cp3-mod3
1068 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1069 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1070 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1071
1072 $ hg grep --diff -f data add0-cp1-mod1-cp3-mod3
1073 add0-cp1-mod1-cp3-mod3:3:+:data3
1074 add0-cp1-mod1:1:+:data1
1075 add0:0:+:data0
1076
1077 BROKEN: should not fall back to plain grep
1078 $ hg grep -f data add0-cp1-mod1-cp3-mod3
1079 add0-cp1-mod1-cp3-mod3:data0
1080 add0-cp1-mod1-cp3-mod3:data1
1081 add0-cp1-mod1-cp3-mod3:data3
1082
1083 follow file history from wdir parent, copied in wdir:
1084
1085 $ hg log -f add0-cp4
1086 abort: cannot follow nonexistent file: "add0-cp4"
1087 [255]
1088
1089 $ hg grep --diff -f data add0-cp4
1090 abort: cannot follow file not in parent revision: "add0-cp4"
1091 [255]
1092
1093 BROKEN: should not fall back to plain grep
1094 $ hg grep -f data add0-cp4
1095 add0-cp4:data0
1096
1097 follow file history from wdir parent, removed:
1098
1099 $ hg log -f add0-cp1-mod1-rm3
1100 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1101 [255]
1102
1103 $ hg grep --diff -f data add0-cp1-mod1-rm3
1104 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1105 [255]
1106
1107 BROKEN: should not fall back to plain grep
1108 $ hg grep -f data add0-cp1-mod1-rm3
1109 [1]
1110
1111 follow file history from wdir parent (explicit), removed:
1112
1113 $ hg log -fr. add0-cp1-mod1-rm3
1114 abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
1115 [255]
1116
1117 $ hg grep --diff -fr. data add0-cp1-mod1-rm3
1118 abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
1119 [255]
1120
1121 BROKEN: should abort
1122 $ hg grep -fr. data add0-cp1-mod1-rm3
1123 [1]
1124
1125 follow file history from wdir parent, removed in wdir:
1126
1127 $ hg log -f add0-rm4
1128 abort: cannot follow file not in parent revision: "add0-rm4"
1129 [255]
1130
1131 BROKEN: may be okay, but different behavior from "hg log"
1132 $ hg grep --diff -f data add0-rm4
1133 add0-rm4:0:+:data0
1134
1135 BROKEN: should not fall back to plain grep
1136 $ hg grep -f data add0-rm4
1137 [1]
1138
1139 follow file history from wdir parent (explicit), removed in wdir:
1140
1141 $ hg log -fr. add0-rm4
1142 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1143
1144 BROKEN: should follow history
1145 $ hg grep --diff -fr. data add0-rm4
1146 [1]
1147
1148 BROKEN: should follow history
1149 $ hg grep -fr. data add0-rm4
1150 add0-rm4:3:data0
1151
1152 follow file history from wdir parent, multiple files:
1153
1154 $ hg log -f add0-mod3 add0-cp1-mod1
1155 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1156 1: A add0-cp1, A add0-cp1-mod1, A add0-cp1-mod1-rm3, M add0-mod1, R add0-rm1
1157 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1158
1159 $ hg grep --diff -f data add0-mod3 add0-cp1-mod1
1160 add0-mod3:3:+:data3
1161 add0-cp1-mod1:1:+:data1
1162 add0:0:+:data0
1163 add0-mod3:0:+:data0
1164
1165 BROKEN: should not fall back to plain grep
1166 $ hg grep -f data add0-mod3 add0-cp1-mod1
1167 add0-cp1-mod1:data0
1168 add0-cp1-mod1:data1
1169 add0-mod3:data0
1170 add0-mod3:data3
1171
1172 follow file history from specified revision, modified:
1173
1174 $ hg log -fr2 add0-mod2
1175 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1176 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1177
1178 BROKEN: should follow history from the specified revision
1179 $ hg grep --diff -fr2 data add0-mod2
1180 [1]
1181
1182 BROKEN: should follow history
1183 $ hg grep -fr2 data add0-mod2
1184 add0-mod2:2:data0
1185 add0-mod2:2:data2
1186
1187 follow file history from specified revision, copied but unmodified:
1188
1189 $ hg log -fr2 add0-cp2
1190 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1191 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1192
1193 BROKEN: should follow history from the specified revision
1194 $ hg grep --diff -fr2 data add0-cp2
1195 abort: cannot follow file not in parent revision: "add0-cp2"
1196 [255]
1197
1198 BROKEN: should follow history across renames
1199 $ hg grep -fr2 data add0-cp2
1200 add0-cp2:2:data0
1201
1202 follow file history from specified revision, copied and modified:
1203
1204 $ hg log -fr2 add0-cp2-mod2
1205 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1206 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1207
1208 BROKEN: should follow history from the specified revision
1209 $ hg grep --diff -fr2 data add0-cp2-mod2
1210 abort: cannot follow file not in parent revision: "add0-cp2-mod2"
1211 [255]
1212
1213 BROKEN: should follow history across renames
1214 $ hg grep -fr2 data add0-cp2-mod2
1215 add0-cp2-mod2:2:data0
1216 add0-cp2-mod2:2:data2
1217
1218 follow file history from specified revision, removed:
1219
1220 $ hg log -fr2 add0-rm2
1221 abort: cannot follow file not in any of the specified revisions: "add0-rm2"
1222 [255]
1223
1224 BROKEN: should abort
1225 $ hg grep --diff -fr2 data add0-rm2
1226 [1]
1227
1228 BROKEN: should abort
1229 $ hg grep -fr2 data add0-rm2
1230 [1]
1231
1232 follow file history from specified revision, multiple files:
1233
1234 $ hg log -fr2 add0-cp2 add0-mod2
1235 2: A add0-cp2, A add0-cp2-mod2, M add0-mod2, R add0-rm2
1236 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1237
1238 BROKEN: should follow history from the specified revision
1239 $ hg grep --diff -fr2 data add0-cp2 add0-mod2
1240 abort: cannot follow file not in parent revision: "add0-cp2"
1241 [255]
1242
1243 BROKEN: should follow history
1244 $ hg grep -fr2 data add0-cp2 add0-mod2
1245 add0-cp2:2:data0
1246 add0-mod2:2:data0
1247 add0-mod2:2:data2
1248
1249 follow file history from wdir, unmodified:
1250
1251 $ hg log -fr'wdir()' add0-mod3
1252 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1253 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1254 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1255
1256 BROKEN: should follow history
1257 $ hg grep --diff -fr'wdir()' data add0-mod3
1258 [1]
1259
1260 BROKEN: should follow history
1261 $ hg grep -fr'wdir()' data add0-mod3
1262 add0-mod3:2147483647:data0
1263 add0-mod3:2147483647:data3
1264
1265 follow file history from wdir, modified:
1266
1267 $ hg log -fr'wdir()' add0-mod4
1268 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1269 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1270
1271 BROKEN: should follow history and show the changes in wdir
1272 $ hg grep --diff -fr'wdir()' data add0-mod4
1273 [1]
1274
1275 BROKEN: should follow history
1276 $ hg grep -fr'wdir()' data add0-mod4
1277 add0-mod4:2147483647:data0
1278 add0-mod4:2147483647:data4
1279
1280 follow file history from wdir, copied but unmodified:
1281
1282 $ hg log -fr'wdir()' add0-cp4
1283 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1284 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1285
1286 BROKEN: should follow history
1287 $ hg grep --diff -fr'wdir()' data add0-cp4
1288 abort: cannot follow file not in parent revision: "add0-cp4"
1289 [255]
1290
1291 BROKEN: should follow history across renames
1292 $ hg grep -fr'wdir()' data add0-cp4
1293 add0-cp4:2147483647:data0
1294
1295 follow file history from wdir, copied and modified:
1296
1297 $ hg log -fr'wdir()' add0-cp4-mod4
1298 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1299 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1300
1301 BROKEN: should follow history
1302 $ hg grep --diff -fr'wdir()' data add0-cp4-mod4
1303 abort: cannot follow file not in parent revision: "add0-cp4-mod4"
1304 [255]
1305
1306 BROKEN: should follow history across renames
1307 $ hg grep -fr'wdir()' data add0-cp4-mod4
1308 add0-cp4-mod4:2147483647:data0
1309 add0-cp4-mod4:2147483647:data4
1310
1311 follow file history from wdir, multiple files:
1312
1313 $ hg log -fr'wdir()' add0-cp4 add0-mod4 add0-mod3
1314 2147483647: A add0-cp4, A add0-cp4-mod4, M add0-mod4, R add0-rm4
1315 3: A add0-cp1-cp3, A add0-cp1-mod1-cp3-mod3, R add0-cp1-mod1-rm3, M add0-mod3
1316 0: A add0, A add0-mod1, A add0-mod2, A add0-mod3, A add0-mod4, A add0-rm1, A add0-rm2, A add0-rm4
1317
1318 BROKEN: should follow history
1319 $ hg grep --diff -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1320 abort: cannot follow file not in parent revision: "add0-cp4"
1321 [255]
1322
1323 BROKEN: should follow history
1324 $ hg grep -fr'wdir()' data add0-cp4 add0-mod4 add0-mod3
1325 add0-cp4:2147483647:data0
1326 add0-mod3:2147483647:data0
1327 add0-mod3:2147483647:data3
1328 add0-mod4:2147483647:data0
1329 add0-mod4:2147483647:data4
1330
1331 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now