##// END OF EJS Templates
tests: add tests for matching keyword...
Angel Ezquerra -
r16447:60c379da default
parent child Browse files
Show More
@@ -1,711 +1,716 b''
1 1 $ "$TESTDIR/hghave" no-msys || exit 80 # MSYS will translate /a/b/c/ as if it was a real file path
2 2
3 3 $ HGENCODING=utf-8
4 4 $ export HGENCODING
5 5
6 6 $ try() {
7 7 > hg debugrevspec --debug "$@"
8 8 > }
9 9
10 10 $ log() {
11 11 > hg log --template '{rev}\n' -r "$1"
12 12 > }
13 13
14 14 $ hg init repo
15 15 $ cd repo
16 16
17 17 $ echo a > a
18 18 $ hg branch a
19 19 marked working directory as branch a
20 20 (branches are permanent and global, did you want a bookmark?)
21 21 $ hg ci -Aqm0
22 22
23 23 $ echo b > b
24 24 $ hg branch b
25 25 marked working directory as branch b
26 26 (branches are permanent and global, did you want a bookmark?)
27 27 $ hg ci -Aqm1
28 28
29 29 $ rm a
30 30 $ hg branch a-b-c-
31 31 marked working directory as branch a-b-c-
32 32 (branches are permanent and global, did you want a bookmark?)
33 33 $ hg ci -Aqm2 -u Bob
34 34
35 35 $ hg co 1
36 36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 37 $ hg branch +a+b+c+
38 38 marked working directory as branch +a+b+c+
39 39 (branches are permanent and global, did you want a bookmark?)
40 40 $ hg ci -Aqm3
41 41
42 42 $ hg co 2 # interleave
43 43 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
44 44 $ echo bb > b
45 45 $ hg branch -- -a-b-c-
46 46 marked working directory as branch -a-b-c-
47 47 (branches are permanent and global, did you want a bookmark?)
48 48 $ hg ci -Aqm4 -d "May 12 2005"
49 49
50 50 $ hg co 3
51 51 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 52 $ hg branch /a/b/c/
53 53 marked working directory as branch /a/b/c/
54 54 (branches are permanent and global, did you want a bookmark?)
55 55 $ hg ci -Aqm"5 bug"
56 56
57 57 $ hg merge 4
58 58 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
59 59 (branch merge, don't forget to commit)
60 60 $ hg branch _a_b_c_
61 61 marked working directory as branch _a_b_c_
62 62 (branches are permanent and global, did you want a bookmark?)
63 63 $ hg ci -Aqm"6 issue619"
64 64
65 65 $ hg branch .a.b.c.
66 66 marked working directory as branch .a.b.c.
67 67 (branches are permanent and global, did you want a bookmark?)
68 68 $ hg ci -Aqm7
69 69
70 70 $ hg branch all
71 71 marked working directory as branch all
72 72 (branches are permanent and global, did you want a bookmark?)
73 73 $ hg ci --close-branch -Aqm8
74 74 abort: can only close branch heads
75 75 [255]
76 76
77 77 $ hg co 4
78 78 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
79 79 $ hg branch Γ©
80 80 marked working directory as branch \xc3\xa9 (esc)
81 81 (branches are permanent and global, did you want a bookmark?)
82 82 $ hg ci -Aqm9
83 83
84 84 $ hg tag -r6 1.0
85 85
86 86 $ hg clone --quiet -U -r 7 . ../remote1
87 87 $ hg clone --quiet -U -r 8 . ../remote2
88 88 $ echo "[paths]" >> .hg/hgrc
89 89 $ echo "default = ../remote1" >> .hg/hgrc
90 90
91 91 names that should work without quoting
92 92
93 93 $ try a
94 94 ('symbol', 'a')
95 95 0
96 96 $ try b-a
97 97 (minus
98 98 ('symbol', 'b')
99 99 ('symbol', 'a'))
100 100 1
101 101 $ try _a_b_c_
102 102 ('symbol', '_a_b_c_')
103 103 6
104 104 $ try _a_b_c_-a
105 105 (minus
106 106 ('symbol', '_a_b_c_')
107 107 ('symbol', 'a'))
108 108 6
109 109 $ try .a.b.c.
110 110 ('symbol', '.a.b.c.')
111 111 7
112 112 $ try .a.b.c.-a
113 113 (minus
114 114 ('symbol', '.a.b.c.')
115 115 ('symbol', 'a'))
116 116 7
117 117 $ try -- '-a-b-c-' # complains
118 118 hg: parse error at 7: not a prefix: end
119 119 [255]
120 120 $ log -a-b-c- # succeeds with fallback
121 121 4
122 122 $ try -- -a-b-c--a # complains
123 123 (minus
124 124 (minus
125 125 (minus
126 126 (negate
127 127 ('symbol', 'a'))
128 128 ('symbol', 'b'))
129 129 ('symbol', 'c'))
130 130 (negate
131 131 ('symbol', 'a')))
132 132 abort: unknown revision '-a'!
133 133 [255]
134 134 $ try Γ©
135 135 ('symbol', '\xc3\xa9')
136 136 9
137 137
138 138 quoting needed
139 139
140 140 $ try '"-a-b-c-"-a'
141 141 (minus
142 142 ('string', '-a-b-c-')
143 143 ('symbol', 'a'))
144 144 4
145 145
146 146 $ log '1 or 2'
147 147 1
148 148 2
149 149 $ log '1|2'
150 150 1
151 151 2
152 152 $ log '1 and 2'
153 153 $ log '1&2'
154 154 $ try '1&2|3' # precedence - and is higher
155 155 (or
156 156 (and
157 157 ('symbol', '1')
158 158 ('symbol', '2'))
159 159 ('symbol', '3'))
160 160 3
161 161 $ try '1|2&3'
162 162 (or
163 163 ('symbol', '1')
164 164 (and
165 165 ('symbol', '2')
166 166 ('symbol', '3')))
167 167 1
168 168 $ try '1&2&3' # associativity
169 169 (and
170 170 (and
171 171 ('symbol', '1')
172 172 ('symbol', '2'))
173 173 ('symbol', '3'))
174 174 $ try '1|(2|3)'
175 175 (or
176 176 ('symbol', '1')
177 177 (group
178 178 (or
179 179 ('symbol', '2')
180 180 ('symbol', '3'))))
181 181 1
182 182 2
183 183 3
184 184 $ log '1.0' # tag
185 185 6
186 186 $ log 'a' # branch
187 187 0
188 188 $ log '2785f51ee'
189 189 0
190 190 $ log 'date(2005)'
191 191 4
192 192 $ log 'date(this is a test)'
193 193 hg: parse error at 10: unexpected token: symbol
194 194 [255]
195 195 $ log 'date()'
196 196 hg: parse error: date requires a string
197 197 [255]
198 198 $ log 'date'
199 199 hg: parse error: can't use date here
200 200 [255]
201 201 $ log 'date('
202 202 hg: parse error at 5: not a prefix: end
203 203 [255]
204 204 $ log 'date(tip)'
205 205 abort: invalid date: 'tip'
206 206 [255]
207 207 $ log '"date"'
208 208 abort: unknown revision 'date'!
209 209 [255]
210 210 $ log 'date(2005) and 1::'
211 211 4
212 212
213 213 $ log 'ancestor(1)'
214 214 hg: parse error: ancestor requires two arguments
215 215 [255]
216 216 $ log 'ancestor(4,5)'
217 217 1
218 218 $ log 'ancestor(4,5) and 4'
219 219 $ log 'ancestors(5)'
220 220 0
221 221 1
222 222 3
223 223 5
224 224 $ log 'author(bob)'
225 225 2
226 226 $ log 'branch(Γ©)'
227 227 8
228 228 9
229 229 $ log 'children(ancestor(4,5))'
230 230 2
231 231 3
232 232 $ log 'closed()'
233 233 $ log 'contains(a)'
234 234 0
235 235 1
236 236 3
237 237 5
238 238 $ log 'desc(B)'
239 239 5
240 240 $ log 'descendants(2 or 3)'
241 241 2
242 242 3
243 243 4
244 244 5
245 245 6
246 246 7
247 247 8
248 248 9
249 249 $ log 'file("b*")'
250 250 1
251 251 4
252 252 $ log 'follow()'
253 253 0
254 254 1
255 255 2
256 256 4
257 257 8
258 258 9
259 259 $ log 'grep("issue\d+")'
260 260 6
261 261 $ try 'grep("(")' # invalid regular expression
262 262 (func
263 263 ('symbol', 'grep')
264 264 ('string', '('))
265 265 hg: parse error: invalid match pattern: unbalanced parenthesis
266 266 [255]
267 267 $ try 'grep("\bissue\d+")'
268 268 (func
269 269 ('symbol', 'grep')
270 270 ('string', '\x08issue\\d+'))
271 271 $ try 'grep(r"\bissue\d+")'
272 272 (func
273 273 ('symbol', 'grep')
274 274 ('string', '\\bissue\\d+'))
275 275 6
276 276 $ try 'grep(r"\")'
277 277 hg: parse error at 7: unterminated string
278 278 [255]
279 279 $ log 'head()'
280 280 0
281 281 1
282 282 2
283 283 3
284 284 4
285 285 5
286 286 6
287 287 7
288 288 9
289 289 $ log 'heads(6::)'
290 290 7
291 291 $ log 'keyword(issue)'
292 292 6
293 293 $ log 'limit(head(), 1)'
294 294 0
295 $ log 'matching(6)'
296 6
297 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
298 6
299 7
295 300 $ log 'max(contains(a))'
296 301 5
297 302 $ log 'min(contains(a))'
298 303 0
299 304 $ log 'merge()'
300 305 6
301 306 $ log 'modifies(b)'
302 307 4
303 308 $ log 'id(5)'
304 309 2
305 310 $ log 'outgoing()'
306 311 8
307 312 9
308 313 $ log 'outgoing("../remote1")'
309 314 8
310 315 9
311 316 $ log 'outgoing("../remote2")'
312 317 3
313 318 5
314 319 6
315 320 7
316 321 9
317 322 $ log 'p1(merge())'
318 323 5
319 324 $ log 'p2(merge())'
320 325 4
321 326 $ log 'parents(merge())'
322 327 4
323 328 5
324 329 $ log 'removes(a)'
325 330 2
326 331 6
327 332 $ log 'roots(all())'
328 333 0
329 334 $ log 'reverse(2 or 3 or 4 or 5)'
330 335 5
331 336 4
332 337 3
333 338 2
334 339 $ log 'rev(5)'
335 340 5
336 341 $ log 'sort(limit(reverse(all()), 3))'
337 342 7
338 343 8
339 344 9
340 345 $ log 'sort(2 or 3 or 4 or 5, date)'
341 346 2
342 347 3
343 348 5
344 349 4
345 350 $ log 'tagged()'
346 351 6
347 352 $ log 'tag()'
348 353 6
349 354 $ log 'tag(1.0)'
350 355 6
351 356 $ log 'tag(tip)'
352 357 9
353 358 $ log 'tag(unknown)'
354 359 abort: tag 'unknown' does not exist
355 360 [255]
356 361 $ log 'branch(unknown)'
357 362 abort: unknown revision 'unknown'!
358 363 [255]
359 364 $ log 'user(bob)'
360 365 2
361 366
362 367 $ log '4::8'
363 368 4
364 369 8
365 370 $ log '4:8'
366 371 4
367 372 5
368 373 6
369 374 7
370 375 8
371 376
372 377 $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
373 378 4
374 379 2
375 380 5
376 381
377 382 $ log 'not 0 and 0:2'
378 383 1
379 384 2
380 385 $ log 'not 1 and 0:2'
381 386 0
382 387 2
383 388 $ log 'not 2 and 0:2'
384 389 0
385 390 1
386 391 $ log '(1 and 2)::'
387 392 $ log '(1 and 2):'
388 393 $ log '(1 and 2):3'
389 394 $ log 'sort(head(), -rev)'
390 395 9
391 396 7
392 397 6
393 398 5
394 399 4
395 400 3
396 401 2
397 402 1
398 403 0
399 404 $ log '4::8 - 8'
400 405 4
401 406
402 407 issue2437
403 408
404 409 $ log '3 and p1(5)'
405 410 3
406 411 $ log '4 and p2(6)'
407 412 4
408 413 $ log '1 and parents(:2)'
409 414 1
410 415 $ log '2 and children(1:)'
411 416 2
412 417 $ log 'roots(all()) or roots(all())'
413 418 0
414 419 $ hg debugrevspec 'roots(all()) or roots(all())'
415 420 0
416 421 $ log 'heads(branch(Γ©)) or heads(branch(Γ©))'
417 422 9
418 423 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))'
419 424 4
420 425
421 426 issue2654: report a parse error if the revset was not completely parsed
422 427
423 428 $ log '1 OR 2'
424 429 hg: parse error at 2: invalid token
425 430 [255]
426 431
427 432 or operator should preserve ordering:
428 433 $ log 'reverse(2::4) or tip'
429 434 4
430 435 2
431 436 9
432 437
433 438 parentrevspec
434 439
435 440 $ log 'merge()^0'
436 441 6
437 442 $ log 'merge()^'
438 443 5
439 444 $ log 'merge()^1'
440 445 5
441 446 $ log 'merge()^2'
442 447 4
443 448 $ log 'merge()^^'
444 449 3
445 450 $ log 'merge()^1^'
446 451 3
447 452 $ log 'merge()^^^'
448 453 1
449 454
450 455 $ log 'merge()~0'
451 456 6
452 457 $ log 'merge()~1'
453 458 5
454 459 $ log 'merge()~2'
455 460 3
456 461 $ log 'merge()~2^1'
457 462 1
458 463 $ log 'merge()~3'
459 464 1
460 465
461 466 $ log '(-3:tip)^'
462 467 4
463 468 6
464 469 8
465 470
466 471 $ log 'tip^foo'
467 472 hg: parse error: ^ expects a number 0, 1, or 2
468 473 [255]
469 474
470 475 aliases:
471 476
472 477 $ echo '[revsetalias]' >> .hg/hgrc
473 478 $ echo 'm = merge()' >> .hg/hgrc
474 479 $ echo 'sincem = descendants(m)' >> .hg/hgrc
475 480 $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
476 481 $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
477 482 $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
478 483
479 484 $ try m
480 485 ('symbol', 'm')
481 486 (func
482 487 ('symbol', 'merge')
483 488 None)
484 489 6
485 490
486 491 test alias recursion
487 492
488 493 $ try sincem
489 494 ('symbol', 'sincem')
490 495 (func
491 496 ('symbol', 'descendants')
492 497 (func
493 498 ('symbol', 'merge')
494 499 None))
495 500 6
496 501 7
497 502
498 503 test infinite recursion
499 504
500 505 $ echo 'recurse1 = recurse2' >> .hg/hgrc
501 506 $ echo 'recurse2 = recurse1' >> .hg/hgrc
502 507 $ try recurse1
503 508 ('symbol', 'recurse1')
504 509 hg: parse error: infinite expansion of revset alias "recurse1" detected
505 510 [255]
506 511
507 512 test nesting and variable passing
508 513
509 514 $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
510 515 $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
511 516 $ echo 'nested3($1) = max($1)' >> .hg/hgrc
512 517 $ try 'nested(2:5)'
513 518 (func
514 519 ('symbol', 'nested')
515 520 (range
516 521 ('symbol', '2')
517 522 ('symbol', '5')))
518 523 (func
519 524 ('symbol', 'max')
520 525 (range
521 526 ('symbol', '2')
522 527 ('symbol', '5')))
523 528 5
524 529
525 530 test variable isolation, variable placeholders are rewritten as string
526 531 then parsed and matched again as string. Check they do not leak too
527 532 far away.
528 533
529 534 $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
530 535 $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
531 536 $ try 'callinjection(2:5)'
532 537 (func
533 538 ('symbol', 'callinjection')
534 539 (range
535 540 ('symbol', '2')
536 541 ('symbol', '5')))
537 542 (func
538 543 ('symbol', 'descendants')
539 544 (func
540 545 ('symbol', 'max')
541 546 ('string', '$1')))
542 547 abort: unknown revision '$1'!
543 548 [255]
544 549
545 550 $ try 'd(2:5)'
546 551 (func
547 552 ('symbol', 'd')
548 553 (range
549 554 ('symbol', '2')
550 555 ('symbol', '5')))
551 556 (func
552 557 ('symbol', 'reverse')
553 558 (func
554 559 ('symbol', 'sort')
555 560 (list
556 561 (range
557 562 ('symbol', '2')
558 563 ('symbol', '5'))
559 564 ('symbol', 'date'))))
560 565 4
561 566 5
562 567 3
563 568 2
564 569 $ try 'rs(2 or 3, date)'
565 570 (func
566 571 ('symbol', 'rs')
567 572 (list
568 573 (or
569 574 ('symbol', '2')
570 575 ('symbol', '3'))
571 576 ('symbol', 'date')))
572 577 (func
573 578 ('symbol', 'reverse')
574 579 (func
575 580 ('symbol', 'sort')
576 581 (list
577 582 (or
578 583 ('symbol', '2')
579 584 ('symbol', '3'))
580 585 ('symbol', 'date'))))
581 586 3
582 587 2
583 588 $ try 'rs()'
584 589 (func
585 590 ('symbol', 'rs')
586 591 None)
587 592 hg: parse error: invalid number of arguments: 0
588 593 [255]
589 594 $ try 'rs(2)'
590 595 (func
591 596 ('symbol', 'rs')
592 597 ('symbol', '2'))
593 598 hg: parse error: invalid number of arguments: 1
594 599 [255]
595 600 $ try 'rs(2, data, 7)'
596 601 (func
597 602 ('symbol', 'rs')
598 603 (list
599 604 (list
600 605 ('symbol', '2')
601 606 ('symbol', 'data'))
602 607 ('symbol', '7')))
603 608 hg: parse error: invalid number of arguments: 3
604 609 [255]
605 610 $ try 'rs4(2 or 3, x, x, date)'
606 611 (func
607 612 ('symbol', 'rs4')
608 613 (list
609 614 (list
610 615 (list
611 616 (or
612 617 ('symbol', '2')
613 618 ('symbol', '3'))
614 619 ('symbol', 'x'))
615 620 ('symbol', 'x'))
616 621 ('symbol', 'date')))
617 622 (func
618 623 ('symbol', 'reverse')
619 624 (func
620 625 ('symbol', 'sort')
621 626 (list
622 627 (or
623 628 ('symbol', '2')
624 629 ('symbol', '3'))
625 630 ('symbol', 'date'))))
626 631 3
627 632 2
628 633
629 634 issue2549 - correct optimizations
630 635
631 636 $ log 'limit(1 or 2 or 3, 2) and not 2'
632 637 1
633 638 $ log 'max(1 or 2) and not 2'
634 639 $ log 'min(1 or 2) and not 1'
635 640 $ log 'last(1 or 2, 1) and not 2'
636 641
637 642 tests for 'remote()' predicate:
638 643 #. (csets in remote) (id) (remote)
639 644 1. less than local current branch "default"
640 645 2. same with local specified "default"
641 646 3. more than local specified specified
642 647
643 648 $ hg clone --quiet -U . ../remote3
644 649 $ cd ../remote3
645 650 $ hg update -q 7
646 651 $ echo r > r
647 652 $ hg ci -Aqm 10
648 653 $ log 'remote()'
649 654 7
650 655 $ log 'remote("a-b-c-")'
651 656 2
652 657 $ cd ../repo
653 658 $ log 'remote(".a.b.c.", "../remote3")'
654 659
655 660 $ cd ..
656 661
657 662 test author/desc/keyword in problematic encoding
658 663 # unicode: cp932:
659 664 # u30A2 0x83 0x41(= 'A')
660 665 # u30C2 0x83 0x61(= 'a')
661 666
662 667 $ hg init problematicencoding
663 668 $ cd problematicencoding
664 669
665 670 $ python > setup.sh <<EOF
666 671 > print u'''
667 672 > echo a > text
668 673 > hg add text
669 674 > hg --encoding utf-8 commit -u '\u30A2' -m none
670 675 > echo b > text
671 676 > hg --encoding utf-8 commit -u '\u30C2' -m none
672 677 > echo c > text
673 678 > hg --encoding utf-8 commit -u none -m '\u30A2'
674 679 > echo d > text
675 680 > hg --encoding utf-8 commit -u none -m '\u30C2'
676 681 > '''.encode('utf-8')
677 682 > EOF
678 683 $ sh < setup.sh
679 684
680 685 test in problematic encoding
681 686 $ python > test.sh <<EOF
682 687 > print u'''
683 688 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
684 689 > echo ====
685 690 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
686 691 > echo ====
687 692 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
688 693 > echo ====
689 694 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
690 695 > echo ====
691 696 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
692 697 > echo ====
693 698 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
694 699 > '''.encode('cp932')
695 700 > EOF
696 701 $ sh < test.sh
697 702 0
698 703 ====
699 704 1
700 705 ====
701 706 2
702 707 ====
703 708 3
704 709 ====
705 710 0
706 711 2
707 712 ====
708 713 1
709 714 3
710 715
711 716 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now