##// END OF EJS Templates
tests: split test-revset.t in half...
Durham Goode -
r34128:af13097b default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (1728 lines changed) Show them Hide them
@@ -1,4467 +1,2739
1 1 $ HGENCODING=utf-8
2 2 $ export HGENCODING
3 3 $ cat > testrevset.py << EOF
4 4 > import mercurial.revset
5 5 >
6 6 > baseset = mercurial.revset.baseset
7 7 >
8 8 > def r3232(repo, subset, x):
9 9 > """"simple revset that return [3,2,3,2]
10 10 >
11 11 > revisions duplicated on purpose.
12 12 > """
13 13 > if 3 not in subset:
14 14 > if 2 in subset:
15 15 > return baseset([2,2])
16 16 > return baseset()
17 17 > return baseset([3,3,2,2])
18 18 >
19 19 > mercurial.revset.symbols['r3232'] = r3232
20 20 > EOF
21 21 $ cat >> $HGRCPATH << EOF
22 22 > [extensions]
23 23 > drawdag=$TESTDIR/drawdag.py
24 24 > testrevset=$TESTTMP/testrevset.py
25 25 > EOF
26 26
27 27 $ try() {
28 28 > hg debugrevspec --debug "$@"
29 29 > }
30 30
31 31 $ log() {
32 32 > hg log --template '{rev}\n' -r "$1"
33 33 > }
34 34
35 35 extension to build '_intlist()' and '_hexlist()', which is necessary because
36 36 these predicates use '\0' as a separator:
37 37
38 38 $ cat <<EOF > debugrevlistspec.py
39 39 > from __future__ import absolute_import
40 40 > from mercurial import (
41 41 > node as nodemod,
42 42 > registrar,
43 43 > revset,
44 44 > revsetlang,
45 45 > smartset,
46 46 > )
47 47 > cmdtable = {}
48 48 > command = registrar.command(cmdtable)
49 49 > @command(b'debugrevlistspec',
50 50 > [('', 'optimize', None, 'print parsed tree after optimizing'),
51 51 > ('', 'bin', None, 'unhexlify arguments')])
52 52 > def debugrevlistspec(ui, repo, fmt, *args, **opts):
53 53 > if opts['bin']:
54 54 > args = map(nodemod.bin, args)
55 55 > expr = revsetlang.formatspec(fmt, list(args))
56 56 > if ui.verbose:
57 57 > tree = revsetlang.parse(expr, lookup=repo.__contains__)
58 58 > ui.note(revsetlang.prettyformat(tree), "\n")
59 59 > if opts["optimize"]:
60 60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 61 > ui.note("* optimized:\n", revsetlang.prettyformat(opttree),
62 62 > "\n")
63 63 > func = revset.match(ui, expr, repo)
64 64 > revs = func(repo)
65 65 > if ui.verbose:
66 66 > ui.note("* set:\n", smartset.prettyformat(revs), "\n")
67 67 > for c in revs:
68 68 > ui.write("%s\n" % c)
69 69 > EOF
70 70 $ cat <<EOF >> $HGRCPATH
71 71 > [extensions]
72 72 > debugrevlistspec = $TESTTMP/debugrevlistspec.py
73 73 > EOF
74 74 $ trylist() {
75 75 > hg debugrevlistspec --debug "$@"
76 76 > }
77 77
78 78 $ hg init repo
79 79 $ cd repo
80 80
81 81 $ echo a > a
82 82 $ hg branch a
83 83 marked working directory as branch a
84 84 (branches are permanent and global, did you want a bookmark?)
85 85 $ hg ci -Aqm0
86 86
87 87 $ echo b > b
88 88 $ hg branch b
89 89 marked working directory as branch b
90 90 $ hg ci -Aqm1
91 91
92 92 $ rm a
93 93 $ hg branch a-b-c-
94 94 marked working directory as branch a-b-c-
95 95 $ hg ci -Aqm2 -u Bob
96 96
97 97 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
98 98 2
99 99 $ hg log -r "extra('branch')" --template '{rev}\n'
100 100 0
101 101 1
102 102 2
103 103 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
104 104 0 a
105 105 2 a-b-c-
106 106
107 107 $ hg co 1
108 108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 109 $ hg branch +a+b+c+
110 110 marked working directory as branch +a+b+c+
111 111 $ hg ci -Aqm3
112 112
113 113 $ hg co 2 # interleave
114 114 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 115 $ echo bb > b
116 116 $ hg branch -- -a-b-c-
117 117 marked working directory as branch -a-b-c-
118 118 $ hg ci -Aqm4 -d "May 12 2005"
119 119
120 120 $ hg co 3
121 121 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 122 $ hg branch !a/b/c/
123 123 marked working directory as branch !a/b/c/
124 124 $ hg ci -Aqm"5 bug"
125 125
126 126 $ hg merge 4
127 127 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
128 128 (branch merge, don't forget to commit)
129 129 $ hg branch _a_b_c_
130 130 marked working directory as branch _a_b_c_
131 131 $ hg ci -Aqm"6 issue619"
132 132
133 133 $ hg branch .a.b.c.
134 134 marked working directory as branch .a.b.c.
135 135 $ hg ci -Aqm7
136 136
137 137 $ hg branch all
138 138 marked working directory as branch all
139 139
140 140 $ hg co 4
141 141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 142 $ hg branch Γ©
143 143 marked working directory as branch \xc3\xa9 (esc)
144 144 $ hg ci -Aqm9
145 145
146 146 $ hg tag -r6 1.0
147 147 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
148 148
149 149 $ hg clone --quiet -U -r 7 . ../remote1
150 150 $ hg clone --quiet -U -r 8 . ../remote2
151 151 $ echo "[paths]" >> .hg/hgrc
152 152 $ echo "default = ../remote1" >> .hg/hgrc
153 153
154 154 trivial
155 155
156 156 $ try 0:1
157 157 (range
158 158 (symbol '0')
159 159 (symbol '1'))
160 160 * set:
161 161 <spanset+ 0:2>
162 162 0
163 163 1
164 164 $ try --optimize :
165 165 (rangeall
166 166 None)
167 167 * optimized:
168 168 (rangeall
169 169 None)
170 170 * set:
171 171 <spanset+ 0:10>
172 172 0
173 173 1
174 174 2
175 175 3
176 176 4
177 177 5
178 178 6
179 179 7
180 180 8
181 181 9
182 182 $ try 3::6
183 183 (dagrange
184 184 (symbol '3')
185 185 (symbol '6'))
186 186 * set:
187 187 <baseset+ [3, 5, 6]>
188 188 3
189 189 5
190 190 6
191 191 $ try '0|1|2'
192 192 (or
193 193 (list
194 194 (symbol '0')
195 195 (symbol '1')
196 196 (symbol '2')))
197 197 * set:
198 198 <baseset [0, 1, 2]>
199 199 0
200 200 1
201 201 2
202 202
203 203 names that should work without quoting
204 204
205 205 $ try a
206 206 (symbol 'a')
207 207 * set:
208 208 <baseset [0]>
209 209 0
210 210 $ try b-a
211 211 (minus
212 212 (symbol 'b')
213 213 (symbol 'a'))
214 214 * set:
215 215 <filteredset
216 216 <baseset [1]>,
217 217 <not
218 218 <baseset [0]>>>
219 219 1
220 220 $ try _a_b_c_
221 221 (symbol '_a_b_c_')
222 222 * set:
223 223 <baseset [6]>
224 224 6
225 225 $ try _a_b_c_-a
226 226 (minus
227 227 (symbol '_a_b_c_')
228 228 (symbol 'a'))
229 229 * set:
230 230 <filteredset
231 231 <baseset [6]>,
232 232 <not
233 233 <baseset [0]>>>
234 234 6
235 235 $ try .a.b.c.
236 236 (symbol '.a.b.c.')
237 237 * set:
238 238 <baseset [7]>
239 239 7
240 240 $ try .a.b.c.-a
241 241 (minus
242 242 (symbol '.a.b.c.')
243 243 (symbol 'a'))
244 244 * set:
245 245 <filteredset
246 246 <baseset [7]>,
247 247 <not
248 248 <baseset [0]>>>
249 249 7
250 250
251 251 names that should be caught by fallback mechanism
252 252
253 253 $ try -- '-a-b-c-'
254 254 (symbol '-a-b-c-')
255 255 * set:
256 256 <baseset [4]>
257 257 4
258 258 $ log -a-b-c-
259 259 4
260 260 $ try '+a+b+c+'
261 261 (symbol '+a+b+c+')
262 262 * set:
263 263 <baseset [3]>
264 264 3
265 265 $ try '+a+b+c+:'
266 266 (rangepost
267 267 (symbol '+a+b+c+'))
268 268 * set:
269 269 <spanset+ 3:10>
270 270 3
271 271 4
272 272 5
273 273 6
274 274 7
275 275 8
276 276 9
277 277 $ try ':+a+b+c+'
278 278 (rangepre
279 279 (symbol '+a+b+c+'))
280 280 * set:
281 281 <spanset+ 0:4>
282 282 0
283 283 1
284 284 2
285 285 3
286 286 $ try -- '-a-b-c-:+a+b+c+'
287 287 (range
288 288 (symbol '-a-b-c-')
289 289 (symbol '+a+b+c+'))
290 290 * set:
291 291 <spanset- 3:5>
292 292 4
293 293 3
294 294 $ log '-a-b-c-:+a+b+c+'
295 295 4
296 296 3
297 297
298 298 $ try -- -a-b-c--a # complains
299 299 (minus
300 300 (minus
301 301 (minus
302 302 (negate
303 303 (symbol 'a'))
304 304 (symbol 'b'))
305 305 (symbol 'c'))
306 306 (negate
307 307 (symbol 'a')))
308 308 abort: unknown revision '-a'!
309 309 [255]
310 310 $ try Γ©
311 311 (symbol '\xc3\xa9')
312 312 * set:
313 313 <baseset [9]>
314 314 9
315 315
316 316 no quoting needed
317 317
318 318 $ log ::a-b-c-
319 319 0
320 320 1
321 321 2
322 322
323 323 quoting needed
324 324
325 325 $ try '"-a-b-c-"-a'
326 326 (minus
327 327 (string '-a-b-c-')
328 328 (symbol 'a'))
329 329 * set:
330 330 <filteredset
331 331 <baseset [4]>,
332 332 <not
333 333 <baseset [0]>>>
334 334 4
335 335
336 336 $ log '1 or 2'
337 337 1
338 338 2
339 339 $ log '1|2'
340 340 1
341 341 2
342 342 $ log '1 and 2'
343 343 $ log '1&2'
344 344 $ try '1&2|3' # precedence - and is higher
345 345 (or
346 346 (list
347 347 (and
348 348 (symbol '1')
349 349 (symbol '2'))
350 350 (symbol '3')))
351 351 * set:
352 352 <addset
353 353 <baseset []>,
354 354 <baseset [3]>>
355 355 3
356 356 $ try '1|2&3'
357 357 (or
358 358 (list
359 359 (symbol '1')
360 360 (and
361 361 (symbol '2')
362 362 (symbol '3'))))
363 363 * set:
364 364 <addset
365 365 <baseset [1]>,
366 366 <baseset []>>
367 367 1
368 368 $ try '1&2&3' # associativity
369 369 (and
370 370 (and
371 371 (symbol '1')
372 372 (symbol '2'))
373 373 (symbol '3'))
374 374 * set:
375 375 <baseset []>
376 376 $ try '1|(2|3)'
377 377 (or
378 378 (list
379 379 (symbol '1')
380 380 (group
381 381 (or
382 382 (list
383 383 (symbol '2')
384 384 (symbol '3'))))))
385 385 * set:
386 386 <addset
387 387 <baseset [1]>,
388 388 <baseset [2, 3]>>
389 389 1
390 390 2
391 391 3
392 392 $ log '1.0' # tag
393 393 6
394 394 $ log 'a' # branch
395 395 0
396 396 $ log '2785f51ee'
397 397 0
398 398 $ log 'date(2005)'
399 399 4
400 400 $ log 'date(this is a test)'
401 401 hg: parse error at 10: unexpected token: symbol
402 402 [255]
403 403 $ log 'date()'
404 404 hg: parse error: date requires a string
405 405 [255]
406 406 $ log 'date'
407 407 abort: unknown revision 'date'!
408 408 [255]
409 409 $ log 'date('
410 410 hg: parse error at 5: not a prefix: end
411 411 [255]
412 412 $ log 'date("\xy")'
413 413 hg: parse error: invalid \x escape
414 414 [255]
415 415 $ log 'date(tip)'
416 416 hg: parse error: invalid date: 'tip'
417 417 [255]
418 418 $ log '0:date'
419 419 abort: unknown revision 'date'!
420 420 [255]
421 421 $ log '::"date"'
422 422 abort: unknown revision 'date'!
423 423 [255]
424 424 $ hg book date -r 4
425 425 $ log '0:date'
426 426 0
427 427 1
428 428 2
429 429 3
430 430 4
431 431 $ log '::date'
432 432 0
433 433 1
434 434 2
435 435 4
436 436 $ log '::"date"'
437 437 0
438 438 1
439 439 2
440 440 4
441 441 $ log 'date(2005) and 1::'
442 442 4
443 443 $ hg book -d date
444 444
445 445 function name should be a symbol
446 446
447 447 $ log '"date"(2005)'
448 448 hg: parse error: not a symbol
449 449 [255]
450 450
451 451 keyword arguments
452 452
453 453 $ log 'extra(branch, value=a)'
454 454 0
455 455
456 456 $ log 'extra(branch, a, b)'
457 457 hg: parse error: extra takes at most 2 positional arguments
458 458 [255]
459 459 $ log 'extra(a, label=b)'
460 460 hg: parse error: extra got multiple values for keyword argument 'label'
461 461 [255]
462 462 $ log 'extra(label=branch, default)'
463 463 hg: parse error: extra got an invalid argument
464 464 [255]
465 465 $ log 'extra(branch, foo+bar=baz)'
466 466 hg: parse error: extra got an invalid argument
467 467 [255]
468 468 $ log 'extra(unknown=branch)'
469 469 hg: parse error: extra got an unexpected keyword argument 'unknown'
470 470 [255]
471 471
472 472 $ try 'foo=bar|baz'
473 473 (keyvalue
474 474 (symbol 'foo')
475 475 (or
476 476 (list
477 477 (symbol 'bar')
478 478 (symbol 'baz'))))
479 479 hg: parse error: can't use a key-value pair in this context
480 480 [255]
481 481
482 482 right-hand side should be optimized recursively
483 483
484 484 $ try --optimize 'foo=(not public())'
485 485 (keyvalue
486 486 (symbol 'foo')
487 487 (group
488 488 (not
489 489 (func
490 490 (symbol 'public')
491 491 None))))
492 492 * optimized:
493 493 (keyvalue
494 494 (symbol 'foo')
495 495 (func
496 496 (symbol '_notpublic')
497 497 None))
498 498 hg: parse error: can't use a key-value pair in this context
499 499 [255]
500 500
501 501 relation-subscript operator has the highest binding strength (as function call):
502 502
503 503 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
504 504 * parsed:
505 505 (range
506 506 (symbol 'tip')
507 507 (relsubscript
508 508 (parentpost
509 509 (symbol 'tip'))
510 510 (symbol 'generations')
511 511 (negate
512 512 (symbol '1'))))
513 513 9
514 514 8
515 515 7
516 516 6
517 517 5
518 518 4
519 519
520 520 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
521 521 * parsed:
522 522 (not
523 523 (relsubscript
524 524 (func
525 525 (symbol 'public')
526 526 None)
527 527 (symbol 'generations')
528 528 (symbol '0')))
529 529
530 530 left-hand side of relation-subscript operator should be optimized recursively:
531 531
532 532 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
533 533 > '(not public())#generations[0]'
534 534 * analyzed:
535 535 (relsubscript
536 536 (not
537 537 (func
538 538 (symbol 'public')
539 539 None))
540 540 (symbol 'generations')
541 541 (symbol '0'))
542 542 * optimized:
543 543 (relsubscript
544 544 (func
545 545 (symbol '_notpublic')
546 546 None)
547 547 (symbol 'generations')
548 548 (symbol '0'))
549 549
550 550 resolution of subscript and relation-subscript ternary operators:
551 551
552 552 $ hg debugrevspec -p analyzed 'tip[0]'
553 553 * analyzed:
554 554 (subscript
555 555 (symbol 'tip')
556 556 (symbol '0'))
557 557 hg: parse error: can't use a subscript in this context
558 558 [255]
559 559
560 560 $ hg debugrevspec -p analyzed 'tip#rel[0]'
561 561 * analyzed:
562 562 (relsubscript
563 563 (symbol 'tip')
564 564 (symbol 'rel')
565 565 (symbol '0'))
566 566 hg: parse error: unknown identifier: rel
567 567 [255]
568 568
569 569 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
570 570 * analyzed:
571 571 (subscript
572 572 (relation
573 573 (symbol 'tip')
574 574 (symbol 'rel'))
575 575 (symbol '0'))
576 576 hg: parse error: can't use a subscript in this context
577 577 [255]
578 578
579 579 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
580 580 * analyzed:
581 581 (subscript
582 582 (relsubscript
583 583 (symbol 'tip')
584 584 (symbol 'rel')
585 585 (symbol '0'))
586 586 (symbol '1'))
587 587 hg: parse error: can't use a subscript in this context
588 588 [255]
589 589
590 590 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
591 591 * analyzed:
592 592 (relsubscript
593 593 (relation
594 594 (symbol 'tip')
595 595 (symbol 'rel0'))
596 596 (symbol 'rel1')
597 597 (symbol '1'))
598 598 hg: parse error: unknown identifier: rel1
599 599 [255]
600 600
601 601 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
602 602 * analyzed:
603 603 (relsubscript
604 604 (relsubscript
605 605 (symbol 'tip')
606 606 (symbol 'rel0')
607 607 (symbol '0'))
608 608 (symbol 'rel1')
609 609 (symbol '1'))
610 610 hg: parse error: unknown identifier: rel1
611 611 [255]
612 612
613 613 parse errors of relation, subscript and relation-subscript operators:
614 614
615 615 $ hg debugrevspec '[0]'
616 616 hg: parse error at 0: not a prefix: [
617 617 [255]
618 618 $ hg debugrevspec '.#'
619 619 hg: parse error at 2: not a prefix: end
620 620 [255]
621 621 $ hg debugrevspec '#rel'
622 622 hg: parse error at 0: not a prefix: #
623 623 [255]
624 624 $ hg debugrevspec '.#rel[0'
625 625 hg: parse error at 7: unexpected token: end
626 626 [255]
627 627 $ hg debugrevspec '.]'
628 628 hg: parse error at 1: invalid token
629 629 [255]
630 630
631 631 $ hg debugrevspec '.#generations[a]'
632 632 hg: parse error: relation subscript must be an integer
633 633 [255]
634 634 $ hg debugrevspec '.#generations[1-2]'
635 635 hg: parse error: relation subscript must be an integer
636 636 [255]
637 637
638 638 parsed tree at stages:
639 639
640 640 $ hg debugrevspec -p all '()'
641 641 * parsed:
642 642 (group
643 643 None)
644 644 * expanded:
645 645 (group
646 646 None)
647 647 * concatenated:
648 648 (group
649 649 None)
650 650 * analyzed:
651 651 None
652 652 * optimized:
653 653 None
654 654 hg: parse error: missing argument
655 655 [255]
656 656
657 657 $ hg debugrevspec --no-optimized -p all '()'
658 658 * parsed:
659 659 (group
660 660 None)
661 661 * expanded:
662 662 (group
663 663 None)
664 664 * concatenated:
665 665 (group
666 666 None)
667 667 * analyzed:
668 668 None
669 669 hg: parse error: missing argument
670 670 [255]
671 671
672 672 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
673 673 * parsed:
674 674 (minus
675 675 (group
676 676 (or
677 677 (list
678 678 (symbol '0')
679 679 (symbol '1'))))
680 680 (symbol '1'))
681 681 * analyzed:
682 682 (and
683 683 (or
684 684 (list
685 685 (symbol '0')
686 686 (symbol '1')))
687 687 (not
688 688 (symbol '1')))
689 689 * optimized:
690 690 (difference
691 691 (func
692 692 (symbol '_list')
693 693 (string '0\x001'))
694 694 (symbol '1'))
695 695 0
696 696
697 697 $ hg debugrevspec -p unknown '0'
698 698 abort: invalid stage name: unknown
699 699 [255]
700 700
701 701 $ hg debugrevspec -p all --optimize '0'
702 702 abort: cannot use --optimize with --show-stage
703 703 [255]
704 704
705 705 verify optimized tree:
706 706
707 707 $ hg debugrevspec --verify '0|1'
708 708
709 709 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
710 710 * analyzed:
711 711 (and
712 712 (func
713 713 (symbol 'r3232')
714 714 None)
715 715 (symbol '2'))
716 716 * optimized:
717 717 (andsmally
718 718 (func
719 719 (symbol 'r3232')
720 720 None)
721 721 (symbol '2'))
722 722 * analyzed set:
723 723 <baseset [2]>
724 724 * optimized set:
725 725 <baseset [2, 2]>
726 726 --- analyzed
727 727 +++ optimized
728 728 2
729 729 +2
730 730 [1]
731 731
732 732 $ hg debugrevspec --no-optimized --verify-optimized '0'
733 733 abort: cannot use --verify-optimized with --no-optimized
734 734 [255]
735 735
736 736 Test that symbols only get parsed as functions if there's an opening
737 737 parenthesis.
738 738
739 739 $ hg book only -r 9
740 740 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
741 741 8
742 742 9
743 743
744 744 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
745 745 may be hidden (issue5385)
746 746
747 747 $ try -p parsed -p analyzed ':'
748 748 * parsed:
749 749 (rangeall
750 750 None)
751 751 * analyzed:
752 752 (rangeall
753 753 None)
754 754 * set:
755 755 <spanset+ 0:10>
756 756 0
757 757 1
758 758 2
759 759 3
760 760 4
761 761 5
762 762 6
763 763 7
764 764 8
765 765 9
766 766 $ try -p analyzed ':1'
767 767 * analyzed:
768 768 (rangepre
769 769 (symbol '1'))
770 770 * set:
771 771 <spanset+ 0:2>
772 772 0
773 773 1
774 774 $ try -p analyzed ':(1|2)'
775 775 * analyzed:
776 776 (rangepre
777 777 (or
778 778 (list
779 779 (symbol '1')
780 780 (symbol '2'))))
781 781 * set:
782 782 <spanset+ 0:3>
783 783 0
784 784 1
785 785 2
786 786 $ try -p analyzed ':(1&2)'
787 787 * analyzed:
788 788 (rangepre
789 789 (and
790 790 (symbol '1')
791 791 (symbol '2')))
792 792 * set:
793 793 <baseset []>
794 794
795 795 infix/suffix resolution of ^ operator (issue2884):
796 796
797 797 x^:y means (x^):y
798 798
799 799 $ try '1^:2'
800 800 (range
801 801 (parentpost
802 802 (symbol '1'))
803 803 (symbol '2'))
804 804 * set:
805 805 <spanset+ 0:3>
806 806 0
807 807 1
808 808 2
809 809
810 810 $ try '1^::2'
811 811 (dagrange
812 812 (parentpost
813 813 (symbol '1'))
814 814 (symbol '2'))
815 815 * set:
816 816 <baseset+ [0, 1, 2]>
817 817 0
818 818 1
819 819 2
820 820
821 821 $ try '9^:'
822 822 (rangepost
823 823 (parentpost
824 824 (symbol '9')))
825 825 * set:
826 826 <spanset+ 8:10>
827 827 8
828 828 9
829 829
830 830 x^:y should be resolved before omitting group operators
831 831
832 832 $ try '1^(:2)'
833 833 (parent
834 834 (symbol '1')
835 835 (group
836 836 (rangepre
837 837 (symbol '2'))))
838 838 hg: parse error: ^ expects a number 0, 1, or 2
839 839 [255]
840 840
841 841 x^:y should be resolved recursively
842 842
843 843 $ try 'sort(1^:2)'
844 844 (func
845 845 (symbol 'sort')
846 846 (range
847 847 (parentpost
848 848 (symbol '1'))
849 849 (symbol '2')))
850 850 * set:
851 851 <spanset+ 0:3>
852 852 0
853 853 1
854 854 2
855 855
856 856 $ try '(3^:4)^:2'
857 857 (range
858 858 (parentpost
859 859 (group
860 860 (range
861 861 (parentpost
862 862 (symbol '3'))
863 863 (symbol '4'))))
864 864 (symbol '2'))
865 865 * set:
866 866 <spanset+ 0:3>
867 867 0
868 868 1
869 869 2
870 870
871 871 $ try '(3^::4)^::2'
872 872 (dagrange
873 873 (parentpost
874 874 (group
875 875 (dagrange
876 876 (parentpost
877 877 (symbol '3'))
878 878 (symbol '4'))))
879 879 (symbol '2'))
880 880 * set:
881 881 <baseset+ [0, 1, 2]>
882 882 0
883 883 1
884 884 2
885 885
886 886 $ try '(9^:)^:'
887 887 (rangepost
888 888 (parentpost
889 889 (group
890 890 (rangepost
891 891 (parentpost
892 892 (symbol '9'))))))
893 893 * set:
894 894 <spanset+ 4:10>
895 895 4
896 896 5
897 897 6
898 898 7
899 899 8
900 900 9
901 901
902 902 x^ in alias should also be resolved
903 903
904 904 $ try 'A' --config 'revsetalias.A=1^:2'
905 905 (symbol 'A')
906 906 * expanded:
907 907 (range
908 908 (parentpost
909 909 (symbol '1'))
910 910 (symbol '2'))
911 911 * set:
912 912 <spanset+ 0:3>
913 913 0
914 914 1
915 915 2
916 916
917 917 $ try 'A:2' --config 'revsetalias.A=1^'
918 918 (range
919 919 (symbol 'A')
920 920 (symbol '2'))
921 921 * expanded:
922 922 (range
923 923 (parentpost
924 924 (symbol '1'))
925 925 (symbol '2'))
926 926 * set:
927 927 <spanset+ 0:3>
928 928 0
929 929 1
930 930 2
931 931
932 932 but not beyond the boundary of alias expansion, because the resolution should
933 933 be made at the parsing stage
934 934
935 935 $ try '1^A' --config 'revsetalias.A=:2'
936 936 (parent
937 937 (symbol '1')
938 938 (symbol 'A'))
939 939 * expanded:
940 940 (parent
941 941 (symbol '1')
942 942 (rangepre
943 943 (symbol '2')))
944 944 hg: parse error: ^ expects a number 0, 1, or 2
945 945 [255]
946 946
947 947 ancestor can accept 0 or more arguments
948 948
949 949 $ log 'ancestor()'
950 950 $ log 'ancestor(1)'
951 951 1
952 952 $ log 'ancestor(4,5)'
953 953 1
954 954 $ log 'ancestor(4,5) and 4'
955 955 $ log 'ancestor(0,0,1,3)'
956 956 0
957 957 $ log 'ancestor(3,1,5,3,5,1)'
958 958 1
959 959 $ log 'ancestor(0,1,3,5)'
960 960 0
961 961 $ log 'ancestor(1,2,3,4,5)'
962 962 1
963 963
964 964 test ancestors
965 965
966 966 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
967 967 @ 9
968 968 o 8
969 969 | o 7
970 970 | o 6
971 971 |/|
972 972 | o 5
973 973 o | 4
974 974 | o 3
975 975 o | 2
976 976 |/
977 977 o 1
978 978 o 0
979 979
980 980 $ log 'ancestors(5)'
981 981 0
982 982 1
983 983 3
984 984 5
985 985 $ log 'ancestor(ancestors(5))'
986 986 0
987 987 $ log '::r3232()'
988 988 0
989 989 1
990 990 2
991 991 3
992 992
993 993 test ancestors with depth limit
994 994
995 995 (depth=0 selects the node itself)
996 996
997 997 $ log 'reverse(ancestors(9, depth=0))'
998 998 9
999 999
1000 1000 (interleaved: '4' would be missing if heap queue were higher depth first)
1001 1001
1002 1002 $ log 'reverse(ancestors(8:9, depth=1))'
1003 1003 9
1004 1004 8
1005 1005 4
1006 1006
1007 1007 (interleaved: '2' would be missing if heap queue were higher depth first)
1008 1008
1009 1009 $ log 'reverse(ancestors(7+8, depth=2))'
1010 1010 8
1011 1011 7
1012 1012 6
1013 1013 5
1014 1014 4
1015 1015 2
1016 1016
1017 1017 (walk example above by separate queries)
1018 1018
1019 1019 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1020 1020 8
1021 1021 4
1022 1022 2
1023 1023 7
1024 1024 6
1025 1025 5
1026 1026
1027 1027 (walk 2nd and 3rd ancestors)
1028 1028
1029 1029 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1030 1030 5
1031 1031 4
1032 1032 3
1033 1033 2
1034 1034
1035 1035 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1036 1036
1037 1037 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1038 1038 5
1039 1039 4
1040 1040 2
1041 1041
1042 1042 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1043 1043 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1044 1044 multiple depths)
1045 1045
1046 1046 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1047 1047 5
1048 1048 2
1049 1049
1050 1050 test bad arguments passed to ancestors()
1051 1051
1052 1052 $ log 'ancestors(., depth=-1)'
1053 1053 hg: parse error: negative depth
1054 1054 [255]
1055 1055 $ log 'ancestors(., depth=foo)'
1056 1056 hg: parse error: ancestors expects an integer depth
1057 1057 [255]
1058 1058
1059 1059 test descendants
1060 1060
1061 1061 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1062 1062 @ 9
1063 1063 o 8
1064 1064 | o 7
1065 1065 | o 6
1066 1066 |/|
1067 1067 | o 5
1068 1068 o | 4
1069 1069 | o 3
1070 1070 o | 2
1071 1071 |/
1072 1072 o 1
1073 1073 o 0
1074 1074
1075 1075 (null is ultimate root and has optimized path)
1076 1076
1077 1077 $ log 'null:4 & descendants(null)'
1078 1078 -1
1079 1079 0
1080 1080 1
1081 1081 2
1082 1082 3
1083 1083 4
1084 1084
1085 1085 (including merge)
1086 1086
1087 1087 $ log ':8 & descendants(2)'
1088 1088 2
1089 1089 4
1090 1090 6
1091 1091 7
1092 1092 8
1093 1093
1094 1094 (multiple roots)
1095 1095
1096 1096 $ log ':8 & descendants(2+5)'
1097 1097 2
1098 1098 4
1099 1099 5
1100 1100 6
1101 1101 7
1102 1102 8
1103 1103
1104 1104 test descendants with depth limit
1105 1105
1106 1106 (depth=0 selects the node itself)
1107 1107
1108 1108 $ log 'descendants(0, depth=0)'
1109 1109 0
1110 1110 $ log 'null: & descendants(null, depth=0)'
1111 1111 -1
1112 1112
1113 1113 (p2 = null should be ignored)
1114 1114
1115 1115 $ log 'null: & descendants(null, depth=2)'
1116 1116 -1
1117 1117 0
1118 1118 1
1119 1119
1120 1120 (multiple paths: depth(6) = (2, 3))
1121 1121
1122 1122 $ log 'descendants(1+3, depth=2)'
1123 1123 1
1124 1124 2
1125 1125 3
1126 1126 4
1127 1127 5
1128 1128 6
1129 1129
1130 1130 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1131 1131
1132 1132 $ log 'descendants(3+1, depth=2, startdepth=2)'
1133 1133 4
1134 1134 5
1135 1135 6
1136 1136
1137 1137 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1138 1138
1139 1139 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1140 1140 1
1141 1141 2
1142 1142 3
1143 1143 4
1144 1144 5
1145 1145 6
1146 1146 7
1147 1147
1148 1148 (multiple depths: depth(6) = (0, 4), no match)
1149 1149
1150 1150 $ log 'descendants(0+6, depth=3, startdepth=1)'
1151 1151 1
1152 1152 2
1153 1153 3
1154 1154 4
1155 1155 5
1156 1156 7
1157 1157
1158 1158 test ancestors/descendants relation subscript:
1159 1159
1160 1160 $ log 'tip#generations[0]'
1161 1161 9
1162 1162 $ log '.#generations[-1]'
1163 1163 8
1164 1164 $ log '.#g[(-1)]'
1165 1165 8
1166 1166
1167 1167 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1168 1168 * parsed:
1169 1169 (relsubscript
1170 1170 (func
1171 1171 (symbol 'roots')
1172 1172 (rangeall
1173 1173 None))
1174 1174 (symbol 'g')
1175 1175 (symbol '2'))
1176 1176 2
1177 1177 3
1178 1178
1179 1179 test author
1180 1180
1181 1181 $ log 'author(bob)'
1182 1182 2
1183 1183 $ log 'author("re:bob|test")'
1184 1184 0
1185 1185 1
1186 1186 2
1187 1187 3
1188 1188 4
1189 1189 5
1190 1190 6
1191 1191 7
1192 1192 8
1193 1193 9
1194 1194 $ log 'author(r"re:\S")'
1195 1195 0
1196 1196 1
1197 1197 2
1198 1198 3
1199 1199 4
1200 1200 5
1201 1201 6
1202 1202 7
1203 1203 8
1204 1204 9
1205 1205 $ log 'branch(Γ©)'
1206 1206 8
1207 1207 9
1208 1208 $ log 'branch(a)'
1209 1209 0
1210 1210 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1211 1211 0 a
1212 1212 2 a-b-c-
1213 1213 3 +a+b+c+
1214 1214 4 -a-b-c-
1215 1215 5 !a/b/c/
1216 1216 6 _a_b_c_
1217 1217 7 .a.b.c.
1218 1218 $ log 'children(ancestor(4,5))'
1219 1219 2
1220 1220 3
1221 1221
1222 1222 $ log 'children(4)'
1223 1223 6
1224 1224 8
1225 1225 $ log 'children(null)'
1226 1226 0
1227 1227
1228 1228 $ log 'closed()'
1229 1229 $ log 'contains(a)'
1230 1230 0
1231 1231 1
1232 1232 3
1233 1233 5
1234 1234 $ log 'contains("../repo/a")'
1235 1235 0
1236 1236 1
1237 1237 3
1238 1238 5
1239 1239 $ log 'desc(B)'
1240 1240 5
1241 1241 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1242 1242 5 5 bug
1243 1243 6 6 issue619
1244 1244 $ log 'descendants(2 or 3)'
1245 1245 2
1246 1246 3
1247 1247 4
1248 1248 5
1249 1249 6
1250 1250 7
1251 1251 8
1252 1252 9
1253 1253 $ log 'file("b*")'
1254 1254 1
1255 1255 4
1256 1256 $ log 'filelog("b")'
1257 1257 1
1258 1258 4
1259 1259 $ log 'filelog("../repo/b")'
1260 1260 1
1261 1261 4
1262 1262 $ log 'follow()'
1263 1263 0
1264 1264 1
1265 1265 2
1266 1266 4
1267 1267 8
1268 1268 9
1269 1269 $ log 'grep("issue\d+")'
1270 1270 6
1271 1271 $ try 'grep("(")' # invalid regular expression
1272 1272 (func
1273 1273 (symbol 'grep')
1274 1274 (string '('))
1275 1275 hg: parse error: invalid match pattern: unbalanced parenthesis
1276 1276 [255]
1277 1277 $ try 'grep("\bissue\d+")'
1278 1278 (func
1279 1279 (symbol 'grep')
1280 1280 (string '\x08issue\\d+'))
1281 1281 * set:
1282 1282 <filteredset
1283 1283 <fullreposet+ 0:10>,
1284 1284 <grep '\x08issue\\d+'>>
1285 1285 $ try 'grep(r"\bissue\d+")'
1286 1286 (func
1287 1287 (symbol 'grep')
1288 1288 (string '\\bissue\\d+'))
1289 1289 * set:
1290 1290 <filteredset
1291 1291 <fullreposet+ 0:10>,
1292 1292 <grep '\\bissue\\d+'>>
1293 1293 6
1294 1294 $ try 'grep(r"\")'
1295 1295 hg: parse error at 7: unterminated string
1296 1296 [255]
1297 1297 $ log 'head()'
1298 1298 0
1299 1299 1
1300 1300 2
1301 1301 3
1302 1302 4
1303 1303 5
1304 1304 6
1305 1305 7
1306 1306 9
1307 1307 $ log 'heads(6::)'
1308 1308 7
1309 1309 $ log 'keyword(issue)'
1310 1310 6
1311 1311 $ log 'keyword("test a")'
1312 1312
1313 1313 Test first (=limit) and last
1314 1314
1315 1315 $ log 'limit(head(), 1)'
1316 1316 0
1317 1317 $ log 'limit(author("re:bob|test"), 3, 5)'
1318 1318 5
1319 1319 6
1320 1320 7
1321 1321 $ log 'limit(author("re:bob|test"), offset=6)'
1322 1322 6
1323 1323 $ log 'limit(author("re:bob|test"), offset=10)'
1324 1324 $ log 'limit(all(), 1, -1)'
1325 1325 hg: parse error: negative offset
1326 1326 [255]
1327 1327 $ log 'limit(all(), -1)'
1328 1328 hg: parse error: negative number to select
1329 1329 [255]
1330 1330 $ log 'limit(all(), 0)'
1331 1331
1332 1332 $ log 'last(all(), -1)'
1333 1333 hg: parse error: negative number to select
1334 1334 [255]
1335 1335 $ log 'last(all(), 0)'
1336 1336 $ log 'last(all(), 1)'
1337 1337 9
1338 1338 $ log 'last(all(), 2)'
1339 1339 8
1340 1340 9
1341 1341
1342 1342 Test smartset.slice() by first/last()
1343 1343
1344 1344 (using unoptimized set, filteredset as example)
1345 1345
1346 1346 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1347 1347 * set:
1348 1348 <filteredset
1349 1349 <spanset+ 0:8>,
1350 1350 <branch 're:'>>
1351 1351 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1352 1352 4
1353 1353 5
1354 1354 6
1355 1355 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1356 1356 3
1357 1357 2
1358 1358 1
1359 1359 $ log 'last(0:7 & branch("re:"), 2)'
1360 1360 6
1361 1361 7
1362 1362
1363 1363 (using baseset)
1364 1364
1365 1365 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1366 1366 * set:
1367 1367 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1368 1368 $ hg debugrevspec --no-show-revs -s 0::7
1369 1369 * set:
1370 1370 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1371 1371 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1372 1372 4
1373 1373 5
1374 1374 6
1375 1375 $ log 'limit(sort(0::7, rev), 3, 4)'
1376 1376 4
1377 1377 5
1378 1378 6
1379 1379 $ log 'limit(sort(0::7, -rev), 3, 4)'
1380 1380 3
1381 1381 2
1382 1382 1
1383 1383 $ log 'last(sort(0::7, rev), 2)'
1384 1384 6
1385 1385 7
1386 1386 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1387 1387 * set:
1388 1388 <baseset+ [6, 7]>
1389 1389 6
1390 1390 7
1391 1391 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1392 1392 * set:
1393 1393 <baseset+ []>
1394 1394 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1395 1395 * set:
1396 1396 <baseset- [0, 1]>
1397 1397 1
1398 1398 0
1399 1399 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1400 1400 * set:
1401 1401 <baseset- []>
1402 1402 $ hg debugrevspec -s 'limit(0::7, 0)'
1403 1403 * set:
1404 1404 <baseset+ []>
1405 1405
1406 1406 (using spanset)
1407 1407
1408 1408 $ hg debugrevspec --no-show-revs -s 0:7
1409 1409 * set:
1410 1410 <spanset+ 0:8>
1411 1411 $ log 'limit(0:7, 3, 4)'
1412 1412 4
1413 1413 5
1414 1414 6
1415 1415 $ log 'limit(7:0, 3, 4)'
1416 1416 3
1417 1417 2
1418 1418 1
1419 1419 $ log 'limit(0:7, 3, 6)'
1420 1420 6
1421 1421 7
1422 1422 $ log 'limit(7:0, 3, 6)'
1423 1423 1
1424 1424 0
1425 1425 $ log 'last(0:7, 2)'
1426 1426 6
1427 1427 7
1428 1428 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1429 1429 * set:
1430 1430 <spanset+ 6:8>
1431 1431 6
1432 1432 7
1433 1433 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1434 1434 * set:
1435 1435 <spanset+ 8:8>
1436 1436 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1437 1437 * set:
1438 1438 <spanset- 0:2>
1439 1439 1
1440 1440 0
1441 1441 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1442 1442 * set:
1443 1443 <spanset- 0:0>
1444 1444 $ hg debugrevspec -s 'limit(0:7, 0)'
1445 1445 * set:
1446 1446 <spanset+ 0:0>
1447 1447
1448 1448 Test order of first/last revisions
1449 1449
1450 1450 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1451 1451 * set:
1452 1452 <filteredset
1453 1453 <spanset- 2:5>,
1454 1454 <spanset+ 3:10>>
1455 1455 4
1456 1456 3
1457 1457
1458 1458 $ hg debugrevspec -s '3: & first(4:0, 3)'
1459 1459 * set:
1460 1460 <filteredset
1461 1461 <spanset+ 3:10>,
1462 1462 <spanset- 2:5>>
1463 1463 3
1464 1464 4
1465 1465
1466 1466 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1467 1467 * set:
1468 1468 <filteredset
1469 1469 <spanset- 0:3>,
1470 1470 <spanset+ 0:2>>
1471 1471 1
1472 1472 0
1473 1473
1474 1474 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1475 1475 * set:
1476 1476 <filteredset
1477 1477 <spanset+ 0:2>,
1478 1478 <spanset+ 0:3>>
1479 1479 0
1480 1480 1
1481 1481
1482 1482 Test scmutil.revsingle() should return the last revision
1483 1483
1484 1484 $ hg debugrevspec -s 'last(0::)'
1485 1485 * set:
1486 1486 <baseset slice=0:1
1487 1487 <generatorset->>
1488 1488 9
1489 1489 $ hg identify -r '0::' --num
1490 1490 9
1491 1491
1492 1492 Test matching
1493 1493
1494 1494 $ log 'matching(6)'
1495 1495 6
1496 1496 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1497 1497 6
1498 1498 7
1499 1499
1500 1500 Testing min and max
1501 1501
1502 1502 max: simple
1503 1503
1504 1504 $ log 'max(contains(a))'
1505 1505 5
1506 1506
1507 1507 max: simple on unordered set)
1508 1508
1509 1509 $ log 'max((4+0+2+5+7) and contains(a))'
1510 1510 5
1511 1511
1512 1512 max: no result
1513 1513
1514 1514 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1515 1515
1516 1516 max: no result on unordered set
1517 1517
1518 1518 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1519 1519
1520 1520 min: simple
1521 1521
1522 1522 $ log 'min(contains(a))'
1523 1523 0
1524 1524
1525 1525 min: simple on unordered set
1526 1526
1527 1527 $ log 'min((4+0+2+5+7) and contains(a))'
1528 1528 0
1529 1529
1530 1530 min: empty
1531 1531
1532 1532 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1533 1533
1534 1534 min: empty on unordered set
1535 1535
1536 1536 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1537 1537
1538 1538
1539 1539 $ log 'merge()'
1540 1540 6
1541 1541 $ log 'branchpoint()'
1542 1542 1
1543 1543 4
1544 1544 $ log 'modifies(b)'
1545 1545 4
1546 1546 $ log 'modifies("path:b")'
1547 1547 4
1548 1548 $ log 'modifies("*")'
1549 1549 4
1550 1550 6
1551 1551 $ log 'modifies("set:modified()")'
1552 1552 4
1553 1553 $ log 'id(5)'
1554 1554 2
1555 1555 $ log 'only(9)'
1556 1556 8
1557 1557 9
1558 1558 $ log 'only(8)'
1559 1559 8
1560 1560 $ log 'only(9, 5)'
1561 1561 2
1562 1562 4
1563 1563 8
1564 1564 9
1565 1565 $ log 'only(7 + 9, 5 + 2)'
1566 1566 4
1567 1567 6
1568 1568 7
1569 1569 8
1570 1570 9
1571 1571
1572 1572 Test empty set input
1573 1573 $ log 'only(p2())'
1574 1574 $ log 'only(p1(), p2())'
1575 1575 0
1576 1576 1
1577 1577 2
1578 1578 4
1579 1579 8
1580 1580 9
1581 1581
1582 1582 Test '%' operator
1583 1583
1584 1584 $ log '9%'
1585 1585 8
1586 1586 9
1587 1587 $ log '9%5'
1588 1588 2
1589 1589 4
1590 1590 8
1591 1591 9
1592 1592 $ log '(7 + 9)%(5 + 2)'
1593 1593 4
1594 1594 6
1595 1595 7
1596 1596 8
1597 1597 9
1598 1598
1599 1599 Test operand of '%' is optimized recursively (issue4670)
1600 1600
1601 1601 $ try --optimize '8:9-8%'
1602 1602 (onlypost
1603 1603 (minus
1604 1604 (range
1605 1605 (symbol '8')
1606 1606 (symbol '9'))
1607 1607 (symbol '8')))
1608 1608 * optimized:
1609 1609 (func
1610 1610 (symbol 'only')
1611 1611 (difference
1612 1612 (range
1613 1613 (symbol '8')
1614 1614 (symbol '9'))
1615 1615 (symbol '8')))
1616 1616 * set:
1617 1617 <baseset+ [8, 9]>
1618 1618 8
1619 1619 9
1620 1620 $ try --optimize '(9)%(5)'
1621 1621 (only
1622 1622 (group
1623 1623 (symbol '9'))
1624 1624 (group
1625 1625 (symbol '5')))
1626 1626 * optimized:
1627 1627 (func
1628 1628 (symbol 'only')
1629 1629 (list
1630 1630 (symbol '9')
1631 1631 (symbol '5')))
1632 1632 * set:
1633 1633 <baseset+ [2, 4, 8, 9]>
1634 1634 2
1635 1635 4
1636 1636 8
1637 1637 9
1638 1638
1639 1639 Test the order of operations
1640 1640
1641 1641 $ log '7 + 9%5 + 2'
1642 1642 7
1643 1643 2
1644 1644 4
1645 1645 8
1646 1646 9
1647 1647
1648 1648 Test explicit numeric revision
1649 1649 $ log 'rev(-2)'
1650 1650 $ log 'rev(-1)'
1651 1651 -1
1652 1652 $ log 'rev(0)'
1653 1653 0
1654 1654 $ log 'rev(9)'
1655 1655 9
1656 1656 $ log 'rev(10)'
1657 1657 $ log 'rev(tip)'
1658 1658 hg: parse error: rev expects a number
1659 1659 [255]
1660 1660
1661 1661 Test hexadecimal revision
1662 1662 $ log 'id(2)'
1663 1663 abort: 00changelog.i@2: ambiguous identifier!
1664 1664 [255]
1665 1665 $ log 'id(23268)'
1666 1666 4
1667 1667 $ log 'id(2785f51eece)'
1668 1668 0
1669 1669 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1670 1670 8
1671 1671 $ log 'id(d5d0dcbdc4a)'
1672 1672 $ log 'id(d5d0dcbdc4w)'
1673 1673 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1674 1674 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1675 1675 $ log 'id(1.0)'
1676 1676 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1677 1677
1678 1678 Test null revision
1679 1679 $ log '(null)'
1680 1680 -1
1681 1681 $ log '(null:0)'
1682 1682 -1
1683 1683 0
1684 1684 $ log '(0:null)'
1685 1685 0
1686 1686 -1
1687 1687 $ log 'null::0'
1688 1688 -1
1689 1689 0
1690 1690 $ log 'null:tip - 0:'
1691 1691 -1
1692 1692 $ log 'null: and null::' | head -1
1693 1693 -1
1694 1694 $ log 'null: or 0:' | head -2
1695 1695 -1
1696 1696 0
1697 1697 $ log 'ancestors(null)'
1698 1698 -1
1699 1699 $ log 'reverse(null:)' | tail -2
1700 1700 0
1701 1701 -1
1702 1702 $ log 'first(null:)'
1703 1703 -1
1704 1704 $ log 'min(null:)'
1705 1705 BROKEN: should be '-1'
1706 1706 $ log 'tip:null and all()' | tail -2
1707 1707 1
1708 1708 0
1709 1709
1710 1710 Test working-directory revision
1711 1711 $ hg debugrevspec 'wdir()'
1712 1712 2147483647
1713 1713 $ hg debugrevspec 'wdir()^'
1714 1714 9
1715 1715 $ hg up 7
1716 1716 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1717 1717 $ hg debugrevspec 'wdir()^'
1718 1718 7
1719 1719 $ hg debugrevspec 'wdir()^0'
1720 1720 2147483647
1721 1721 $ hg debugrevspec 'wdir()~3'
1722 1722 5
1723 1723 $ hg debugrevspec 'ancestors(wdir())'
1724 1724 0
1725 1725 1
1726 1726 2
1727 1727 3
1728 1728 4
1729 1729 5
1730 1730 6
1731 1731 7
1732 1732 2147483647
1733 1733 $ hg debugrevspec 'wdir()~0'
1734 1734 2147483647
1735 1735 $ hg debugrevspec 'p1(wdir())'
1736 1736 7
1737 1737 $ hg debugrevspec 'p2(wdir())'
1738 1738 $ hg debugrevspec 'parents(wdir())'
1739 1739 7
1740 1740 $ hg debugrevspec 'wdir()^1'
1741 1741 7
1742 1742 $ hg debugrevspec 'wdir()^2'
1743 1743 $ hg debugrevspec 'wdir()^3'
1744 1744 hg: parse error: ^ expects a number 0, 1, or 2
1745 1745 [255]
1746 1746 For tests consistency
1747 1747 $ hg up 9
1748 1748 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1749 1749 $ hg debugrevspec 'tip or wdir()'
1750 1750 9
1751 1751 2147483647
1752 1752 $ hg debugrevspec '0:tip and wdir()'
1753 1753 $ log '0:wdir()' | tail -3
1754 1754 8
1755 1755 9
1756 1756 2147483647
1757 1757 $ log 'wdir():0' | head -3
1758 1758 2147483647
1759 1759 9
1760 1760 8
1761 1761 $ log 'wdir():wdir()'
1762 1762 2147483647
1763 1763 $ log '(all() + wdir()) & min(. + wdir())'
1764 1764 9
1765 1765 $ log '(all() + wdir()) & max(. + wdir())'
1766 1766 2147483647
1767 1767 $ log 'first(wdir() + .)'
1768 1768 2147483647
1769 1769 $ log 'last(. + wdir())'
1770 1770 2147483647
1771 1771
1772 1772 Test working-directory integer revision and node id
1773 1773 (BUG: '0:wdir()' is still needed to populate wdir revision)
1774 1774
1775 1775 $ hg debugrevspec '0:wdir() & 2147483647'
1776 1776 2147483647
1777 1777 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1778 1778 2147483647
1779 1779 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1780 1780 2147483647
1781 1781 $ hg debugrevspec '0:wdir() & ffffffffffff'
1782 1782 2147483647
1783 1783 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1784 1784 2147483647
1785 1785 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1786 1786 2147483647
1787 1787
1788 1788 $ cd ..
1789 1789
1790 1790 Test short 'ff...' hash collision
1791 1791 (BUG: '0:wdir()' is still needed to populate wdir revision)
1792 1792
1793 1793 $ hg init wdir-hashcollision
1794 1794 $ cd wdir-hashcollision
1795 1795 $ cat <<EOF >> .hg/hgrc
1796 1796 > [experimental]
1797 1797 > stabilization = createmarkers
1798 1798 > EOF
1799 1799 $ echo 0 > a
1800 1800 $ hg ci -qAm 0
1801 1801 $ for i in 2463 2961 6726 78127; do
1802 1802 > hg up -q 0
1803 1803 > echo $i > a
1804 1804 > hg ci -qm $i
1805 1805 > done
1806 1806 $ hg up -q null
1807 1807 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1808 1808 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1809 1809 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1810 1810 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1811 1811 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1812 1812 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1813 1813 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
1814 1814 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
1815 1815 obsoleted 1 changesets
1816 1816
1817 1817 $ hg debugrevspec '0:wdir() & fff'
1818 1818 abort: 00changelog.i@fff: ambiguous identifier!
1819 1819 [255]
1820 1820 $ hg debugrevspec '0:wdir() & ffff'
1821 1821 abort: 00changelog.i@ffff: ambiguous identifier!
1822 1822 [255]
1823 1823 $ hg debugrevspec '0:wdir() & fffb'
1824 1824 abort: 00changelog.i@fffb: ambiguous identifier!
1825 1825 [255]
1826 1826 BROKEN should be '2' (node lookup uses unfiltered repo since dc25ed84bee8)
1827 1827 $ hg debugrevspec '0:wdir() & id(fffb)'
1828 1828 2
1829 1829 $ hg debugrevspec '0:wdir() & ffff8'
1830 1830 4
1831 1831 $ hg debugrevspec '0:wdir() & fffff'
1832 1832 2147483647
1833 1833
1834 1834 $ cd ..
1835 1835
1836 1836 Test branch() with wdir()
1837 1837
1838 1838 $ cd repo
1839 1839
1840 1840 $ log '0:wdir() & branch("literal:Γ©")'
1841 1841 8
1842 1842 9
1843 1843 2147483647
1844 1844 $ log '0:wdir() & branch("re:Γ©")'
1845 1845 8
1846 1846 9
1847 1847 2147483647
1848 1848 $ log '0:wdir() & branch("re:^a")'
1849 1849 0
1850 1850 2
1851 1851 $ log '0:wdir() & branch(8)'
1852 1852 8
1853 1853 9
1854 1854 2147483647
1855 1855
1856 1856 branch(wdir()) returns all revisions belonging to the working branch. The wdir
1857 1857 itself isn't returned unless it is explicitly populated.
1858 1858
1859 1859 $ log 'branch(wdir())'
1860 1860 8
1861 1861 9
1862 1862 $ log '0:wdir() & branch(wdir())'
1863 1863 8
1864 1864 9
1865 1865 2147483647
1866 1866
1867 1867 $ log 'outgoing()'
1868 1868 8
1869 1869 9
1870 1870 $ log 'outgoing("../remote1")'
1871 1871 8
1872 1872 9
1873 1873 $ log 'outgoing("../remote2")'
1874 1874 3
1875 1875 5
1876 1876 6
1877 1877 7
1878 1878 9
1879 1879 $ log 'p1(merge())'
1880 1880 5
1881 1881 $ log 'p2(merge())'
1882 1882 4
1883 1883 $ log 'parents(merge())'
1884 1884 4
1885 1885 5
1886 1886 $ log 'p1(branchpoint())'
1887 1887 0
1888 1888 2
1889 1889 $ log 'p2(branchpoint())'
1890 1890 $ log 'parents(branchpoint())'
1891 1891 0
1892 1892 2
1893 1893 $ log 'removes(a)'
1894 1894 2
1895 1895 6
1896 1896 $ log 'roots(all())'
1897 1897 0
1898 1898 $ log 'reverse(2 or 3 or 4 or 5)'
1899 1899 5
1900 1900 4
1901 1901 3
1902 1902 2
1903 1903 $ log 'reverse(all())'
1904 1904 9
1905 1905 8
1906 1906 7
1907 1907 6
1908 1908 5
1909 1909 4
1910 1910 3
1911 1911 2
1912 1912 1
1913 1913 0
1914 1914 $ log 'reverse(all()) & filelog(b)'
1915 1915 4
1916 1916 1
1917 1917 $ log 'rev(5)'
1918 1918 5
1919 1919 $ log 'sort(limit(reverse(all()), 3))'
1920 1920 7
1921 1921 8
1922 1922 9
1923 1923 $ log 'sort(2 or 3 or 4 or 5, date)'
1924 1924 2
1925 1925 3
1926 1926 5
1927 1927 4
1928 1928 $ log 'tagged()'
1929 1929 6
1930 1930 $ log 'tag()'
1931 1931 6
1932 1932 $ log 'tag(1.0)'
1933 1933 6
1934 1934 $ log 'tag(tip)'
1935 1935 9
1936 1936
1937 1937 Test order of revisions in compound expression
1938 1938 ----------------------------------------------
1939 1939
1940 1940 The general rule is that only the outermost (= leftmost) predicate can
1941 1941 enforce its ordering requirement. The other predicates should take the
1942 1942 ordering defined by it.
1943 1943
1944 1944 'A & B' should follow the order of 'A':
1945 1945
1946 1946 $ log '2:0 & 0::2'
1947 1947 2
1948 1948 1
1949 1949 0
1950 1950
1951 1951 'head()' combines sets in right order:
1952 1952
1953 1953 $ log '2:0 & head()'
1954 1954 2
1955 1955 1
1956 1956 0
1957 1957
1958 1958 'x:y' takes ordering parameter into account:
1959 1959
1960 1960 $ try -p optimized '3:0 & 0:3 & not 2:1'
1961 1961 * optimized:
1962 1962 (difference
1963 1963 (and
1964 1964 (range
1965 1965 (symbol '3')
1966 1966 (symbol '0'))
1967 1967 (range
1968 1968 (symbol '0')
1969 1969 (symbol '3')))
1970 1970 (range
1971 1971 (symbol '2')
1972 1972 (symbol '1')))
1973 1973 * set:
1974 1974 <filteredset
1975 1975 <filteredset
1976 1976 <spanset- 0:4>,
1977 1977 <spanset+ 0:4>>,
1978 1978 <not
1979 1979 <spanset+ 1:3>>>
1980 1980 3
1981 1981 0
1982 1982
1983 1983 'a + b', which is optimized to '_list(a b)', should take the ordering of
1984 1984 the left expression:
1985 1985
1986 1986 $ try --optimize '2:0 & (0 + 1 + 2)'
1987 1987 (and
1988 1988 (range
1989 1989 (symbol '2')
1990 1990 (symbol '0'))
1991 1991 (group
1992 1992 (or
1993 1993 (list
1994 1994 (symbol '0')
1995 1995 (symbol '1')
1996 1996 (symbol '2')))))
1997 1997 * optimized:
1998 1998 (and
1999 1999 (range
2000 2000 (symbol '2')
2001 2001 (symbol '0'))
2002 2002 (func
2003 2003 (symbol '_list')
2004 2004 (string '0\x001\x002')))
2005 2005 * set:
2006 2006 <filteredset
2007 2007 <spanset- 0:3>,
2008 2008 <baseset [0, 1, 2]>>
2009 2009 2
2010 2010 1
2011 2011 0
2012 2012
2013 2013 'A + B' should take the ordering of the left expression:
2014 2014
2015 2015 $ try --optimize '2:0 & (0:1 + 2)'
2016 2016 (and
2017 2017 (range
2018 2018 (symbol '2')
2019 2019 (symbol '0'))
2020 2020 (group
2021 2021 (or
2022 2022 (list
2023 2023 (range
2024 2024 (symbol '0')
2025 2025 (symbol '1'))
2026 2026 (symbol '2')))))
2027 2027 * optimized:
2028 2028 (and
2029 2029 (range
2030 2030 (symbol '2')
2031 2031 (symbol '0'))
2032 2032 (or
2033 2033 (list
2034 2034 (range
2035 2035 (symbol '0')
2036 2036 (symbol '1'))
2037 2037 (symbol '2'))))
2038 2038 * set:
2039 2039 <filteredset
2040 2040 <spanset- 0:3>,
2041 2041 <addset
2042 2042 <spanset+ 0:2>,
2043 2043 <baseset [2]>>>
2044 2044 2
2045 2045 1
2046 2046 0
2047 2047
2048 2048 '_intlist(a b)' should behave like 'a + b':
2049 2049
2050 2050 $ trylist --optimize '2:0 & %ld' 0 1 2
2051 2051 (and
2052 2052 (range
2053 2053 (symbol '2')
2054 2054 (symbol '0'))
2055 2055 (func
2056 2056 (symbol '_intlist')
2057 2057 (string '0\x001\x002')))
2058 2058 * optimized:
2059 2059 (andsmally
2060 2060 (range
2061 2061 (symbol '2')
2062 2062 (symbol '0'))
2063 2063 (func
2064 2064 (symbol '_intlist')
2065 2065 (string '0\x001\x002')))
2066 2066 * set:
2067 2067 <filteredset
2068 2068 <spanset- 0:3>,
2069 2069 <baseset+ [0, 1, 2]>>
2070 2070 2
2071 2071 1
2072 2072 0
2073 2073
2074 2074 $ trylist --optimize '%ld & 2:0' 0 2 1
2075 2075 (and
2076 2076 (func
2077 2077 (symbol '_intlist')
2078 2078 (string '0\x002\x001'))
2079 2079 (range
2080 2080 (symbol '2')
2081 2081 (symbol '0')))
2082 2082 * optimized:
2083 2083 (and
2084 2084 (func
2085 2085 (symbol '_intlist')
2086 2086 (string '0\x002\x001'))
2087 2087 (range
2088 2088 (symbol '2')
2089 2089 (symbol '0')))
2090 2090 * set:
2091 2091 <filteredset
2092 2092 <baseset [0, 2, 1]>,
2093 2093 <spanset- 0:3>>
2094 2094 0
2095 2095 2
2096 2096 1
2097 2097
2098 2098 '_hexlist(a b)' should behave like 'a + b':
2099 2099
2100 2100 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2101 2101 (and
2102 2102 (range
2103 2103 (symbol '2')
2104 2104 (symbol '0'))
2105 2105 (func
2106 2106 (symbol '_hexlist')
2107 2107 (string '*'))) (glob)
2108 2108 * optimized:
2109 2109 (and
2110 2110 (range
2111 2111 (symbol '2')
2112 2112 (symbol '0'))
2113 2113 (func
2114 2114 (symbol '_hexlist')
2115 2115 (string '*'))) (glob)
2116 2116 * set:
2117 2117 <filteredset
2118 2118 <spanset- 0:3>,
2119 2119 <baseset [0, 1, 2]>>
2120 2120 2
2121 2121 1
2122 2122 0
2123 2123
2124 2124 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2125 2125 (and
2126 2126 (func
2127 2127 (symbol '_hexlist')
2128 2128 (string '*')) (glob)
2129 2129 (range
2130 2130 (symbol '2')
2131 2131 (symbol '0')))
2132 2132 * optimized:
2133 2133 (andsmally
2134 2134 (func
2135 2135 (symbol '_hexlist')
2136 2136 (string '*')) (glob)
2137 2137 (range
2138 2138 (symbol '2')
2139 2139 (symbol '0')))
2140 2140 * set:
2141 2141 <baseset [0, 2, 1]>
2142 2142 0
2143 2143 2
2144 2144 1
2145 2145
2146 2146 '_list' should not go through the slow follow-order path if order doesn't
2147 2147 matter:
2148 2148
2149 2149 $ try -p optimized '2:0 & not (0 + 1)'
2150 2150 * optimized:
2151 2151 (difference
2152 2152 (range
2153 2153 (symbol '2')
2154 2154 (symbol '0'))
2155 2155 (func
2156 2156 (symbol '_list')
2157 2157 (string '0\x001')))
2158 2158 * set:
2159 2159 <filteredset
2160 2160 <spanset- 0:3>,
2161 2161 <not
2162 2162 <baseset [0, 1]>>>
2163 2163 2
2164 2164
2165 2165 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2166 2166 * optimized:
2167 2167 (difference
2168 2168 (range
2169 2169 (symbol '2')
2170 2170 (symbol '0'))
2171 2171 (and
2172 2172 (range
2173 2173 (symbol '0')
2174 2174 (symbol '2'))
2175 2175 (func
2176 2176 (symbol '_list')
2177 2177 (string '0\x001'))))
2178 2178 * set:
2179 2179 <filteredset
2180 2180 <spanset- 0:3>,
2181 2181 <not
2182 2182 <baseset [0, 1]>>>
2183 2183 2
2184 2184
2185 2185 because 'present()' does nothing other than suppressing an error, the
2186 2186 ordering requirement should be forwarded to the nested expression
2187 2187
2188 2188 $ try -p optimized 'present(2 + 0 + 1)'
2189 2189 * optimized:
2190 2190 (func
2191 2191 (symbol 'present')
2192 2192 (func
2193 2193 (symbol '_list')
2194 2194 (string '2\x000\x001')))
2195 2195 * set:
2196 2196 <baseset [2, 0, 1]>
2197 2197 2
2198 2198 0
2199 2199 1
2200 2200
2201 2201 $ try --optimize '2:0 & present(0 + 1 + 2)'
2202 2202 (and
2203 2203 (range
2204 2204 (symbol '2')
2205 2205 (symbol '0'))
2206 2206 (func
2207 2207 (symbol 'present')
2208 2208 (or
2209 2209 (list
2210 2210 (symbol '0')
2211 2211 (symbol '1')
2212 2212 (symbol '2')))))
2213 2213 * optimized:
2214 2214 (and
2215 2215 (range
2216 2216 (symbol '2')
2217 2217 (symbol '0'))
2218 2218 (func
2219 2219 (symbol 'present')
2220 2220 (func
2221 2221 (symbol '_list')
2222 2222 (string '0\x001\x002'))))
2223 2223 * set:
2224 2224 <filteredset
2225 2225 <spanset- 0:3>,
2226 2226 <baseset [0, 1, 2]>>
2227 2227 2
2228 2228 1
2229 2229 0
2230 2230
2231 2231 'reverse()' should take effect only if it is the outermost expression:
2232 2232
2233 2233 $ try --optimize '0:2 & reverse(all())'
2234 2234 (and
2235 2235 (range
2236 2236 (symbol '0')
2237 2237 (symbol '2'))
2238 2238 (func
2239 2239 (symbol 'reverse')
2240 2240 (func
2241 2241 (symbol 'all')
2242 2242 None)))
2243 2243 * optimized:
2244 2244 (and
2245 2245 (range
2246 2246 (symbol '0')
2247 2247 (symbol '2'))
2248 2248 (func
2249 2249 (symbol 'reverse')
2250 2250 (func
2251 2251 (symbol 'all')
2252 2252 None)))
2253 2253 * set:
2254 2254 <filteredset
2255 2255 <spanset+ 0:3>,
2256 2256 <spanset+ 0:10>>
2257 2257 0
2258 2258 1
2259 2259 2
2260 2260
2261 2261 'sort()' should take effect only if it is the outermost expression:
2262 2262
2263 2263 $ try --optimize '0:2 & sort(all(), -rev)'
2264 2264 (and
2265 2265 (range
2266 2266 (symbol '0')
2267 2267 (symbol '2'))
2268 2268 (func
2269 2269 (symbol 'sort')
2270 2270 (list
2271 2271 (func
2272 2272 (symbol 'all')
2273 2273 None)
2274 2274 (negate
2275 2275 (symbol 'rev')))))
2276 2276 * optimized:
2277 2277 (and
2278 2278 (range
2279 2279 (symbol '0')
2280 2280 (symbol '2'))
2281 2281 (func
2282 2282 (symbol 'sort')
2283 2283 (list
2284 2284 (func
2285 2285 (symbol 'all')
2286 2286 None)
2287 2287 (string '-rev'))))
2288 2288 * set:
2289 2289 <filteredset
2290 2290 <spanset+ 0:3>,
2291 2291 <spanset+ 0:10>>
2292 2292 0
2293 2293 1
2294 2294 2
2295 2295
2296 2296 invalid argument passed to noop sort():
2297 2297
2298 2298 $ log '0:2 & sort()'
2299 2299 hg: parse error: sort requires one or two arguments
2300 2300 [255]
2301 2301 $ log '0:2 & sort(all(), -invalid)'
2302 2302 hg: parse error: unknown sort key '-invalid'
2303 2303 [255]
2304 2304
2305 2305 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2306 2306
2307 2307 $ try --optimize '2:0 & first(1 + 0 + 2)'
2308 2308 (and
2309 2309 (range
2310 2310 (symbol '2')
2311 2311 (symbol '0'))
2312 2312 (func
2313 2313 (symbol 'first')
2314 2314 (or
2315 2315 (list
2316 2316 (symbol '1')
2317 2317 (symbol '0')
2318 2318 (symbol '2')))))
2319 2319 * optimized:
2320 2320 (and
2321 2321 (range
2322 2322 (symbol '2')
2323 2323 (symbol '0'))
2324 2324 (func
2325 2325 (symbol 'first')
2326 2326 (func
2327 2327 (symbol '_list')
2328 2328 (string '1\x000\x002'))))
2329 2329 * set:
2330 2330 <filteredset
2331 2331 <baseset [1]>,
2332 2332 <spanset- 0:3>>
2333 2333 1
2334 2334
2335 2335 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2336 2336 (and
2337 2337 (range
2338 2338 (symbol '2')
2339 2339 (symbol '0'))
2340 2340 (not
2341 2341 (func
2342 2342 (symbol 'last')
2343 2343 (or
2344 2344 (list
2345 2345 (symbol '0')
2346 2346 (symbol '2')
2347 2347 (symbol '1'))))))
2348 2348 * optimized:
2349 2349 (difference
2350 2350 (range
2351 2351 (symbol '2')
2352 2352 (symbol '0'))
2353 2353 (func
2354 2354 (symbol 'last')
2355 2355 (func
2356 2356 (symbol '_list')
2357 2357 (string '0\x002\x001'))))
2358 2358 * set:
2359 2359 <filteredset
2360 2360 <spanset- 0:3>,
2361 2361 <not
2362 2362 <baseset [1]>>>
2363 2363 2
2364 2364 0
2365 2365
2366 2366 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2367 2367
2368 2368 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2369 2369 (and
2370 2370 (range
2371 2371 (symbol '2')
2372 2372 (symbol '0'))
2373 2373 (range
2374 2374 (group
2375 2375 (or
2376 2376 (list
2377 2377 (symbol '1')
2378 2378 (symbol '0')
2379 2379 (symbol '2'))))
2380 2380 (group
2381 2381 (or
2382 2382 (list
2383 2383 (symbol '0')
2384 2384 (symbol '2')
2385 2385 (symbol '1'))))))
2386 2386 * optimized:
2387 2387 (and
2388 2388 (range
2389 2389 (symbol '2')
2390 2390 (symbol '0'))
2391 2391 (range
2392 2392 (func
2393 2393 (symbol '_list')
2394 2394 (string '1\x000\x002'))
2395 2395 (func
2396 2396 (symbol '_list')
2397 2397 (string '0\x002\x001'))))
2398 2398 * set:
2399 2399 <filteredset
2400 2400 <spanset- 0:3>,
2401 2401 <baseset [1]>>
2402 2402 1
2403 2403
2404 2404 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2405 2405
2406 2406 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2407 2407 (and
2408 2408 (func
2409 2409 (symbol 'contains')
2410 2410 (string 'glob:*'))
2411 2411 (group
2412 2412 (or
2413 2413 (list
2414 2414 (symbol '2')
2415 2415 (symbol '0')
2416 2416 (symbol '1')))))
2417 2417 * optimized:
2418 2418 (andsmally
2419 2419 (func
2420 2420 (symbol 'contains')
2421 2421 (string 'glob:*'))
2422 2422 (func
2423 2423 (symbol '_list')
2424 2424 (string '2\x000\x001')))
2425 2425 * set:
2426 2426 <filteredset
2427 2427 <baseset+ [0, 1, 2]>,
2428 2428 <contains 'glob:*'>>
2429 2429 0
2430 2430 1
2431 2431 2
2432 2432
2433 2433 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2434 2434 the order appropriately:
2435 2435
2436 2436 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2437 2437 (and
2438 2438 (func
2439 2439 (symbol 'reverse')
2440 2440 (func
2441 2441 (symbol 'contains')
2442 2442 (string 'glob:*')))
2443 2443 (group
2444 2444 (or
2445 2445 (list
2446 2446 (symbol '0')
2447 2447 (symbol '2')
2448 2448 (symbol '1')))))
2449 2449 * optimized:
2450 2450 (andsmally
2451 2451 (func
2452 2452 (symbol 'reverse')
2453 2453 (func
2454 2454 (symbol 'contains')
2455 2455 (string 'glob:*')))
2456 2456 (func
2457 2457 (symbol '_list')
2458 2458 (string '0\x002\x001')))
2459 2459 * set:
2460 2460 <filteredset
2461 2461 <baseset- [0, 1, 2]>,
2462 2462 <contains 'glob:*'>>
2463 2463 2
2464 2464 1
2465 2465 0
2466 2466
2467 2467 test sort revset
2468 2468 --------------------------------------------
2469 2469
2470 2470 test when adding two unordered revsets
2471 2471
2472 2472 $ log 'sort(keyword(issue) or modifies(b))'
2473 2473 4
2474 2474 6
2475 2475
2476 2476 test when sorting a reversed collection in the same way it is
2477 2477
2478 2478 $ log 'sort(reverse(all()), -rev)'
2479 2479 9
2480 2480 8
2481 2481 7
2482 2482 6
2483 2483 5
2484 2484 4
2485 2485 3
2486 2486 2
2487 2487 1
2488 2488 0
2489 2489
2490 2490 test when sorting a reversed collection
2491 2491
2492 2492 $ log 'sort(reverse(all()), rev)'
2493 2493 0
2494 2494 1
2495 2495 2
2496 2496 3
2497 2497 4
2498 2498 5
2499 2499 6
2500 2500 7
2501 2501 8
2502 2502 9
2503 2503
2504 2504
2505 2505 test sorting two sorted collections in different orders
2506 2506
2507 2507 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2508 2508 2
2509 2509 6
2510 2510 8
2511 2511 9
2512 2512
2513 2513 test sorting two sorted collections in different orders backwards
2514 2514
2515 2515 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2516 2516 9
2517 2517 8
2518 2518 6
2519 2519 2
2520 2520
2521 2521 test empty sort key which is noop
2522 2522
2523 2523 $ log 'sort(0 + 2 + 1, "")'
2524 2524 0
2525 2525 2
2526 2526 1
2527 2527
2528 2528 test invalid sort keys
2529 2529
2530 2530 $ log 'sort(all(), -invalid)'
2531 2531 hg: parse error: unknown sort key '-invalid'
2532 2532 [255]
2533 2533
2534 2534 $ cd ..
2535 2535
2536 2536 test sorting by multiple keys including variable-length strings
2537 2537
2538 2538 $ hg init sorting
2539 2539 $ cd sorting
2540 2540 $ cat <<EOF >> .hg/hgrc
2541 2541 > [ui]
2542 2542 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2543 2543 > [templatealias]
2544 2544 > p5(s) = pad(s, 5)
2545 2545 > EOF
2546 2546 $ hg branch -qf b12
2547 2547 $ hg ci -m m111 -u u112 -d '111 10800'
2548 2548 $ hg branch -qf b11
2549 2549 $ hg ci -m m12 -u u111 -d '112 7200'
2550 2550 $ hg branch -qf b111
2551 2551 $ hg ci -m m11 -u u12 -d '111 3600'
2552 2552 $ hg branch -qf b112
2553 2553 $ hg ci -m m111 -u u11 -d '120 0'
2554 2554 $ hg branch -qf b111
2555 2555 $ hg ci -m m112 -u u111 -d '110 14400'
2556 2556 created new head
2557 2557
2558 2558 compare revisions (has fast path):
2559 2559
2560 2560 $ hg log -r 'sort(all(), rev)'
2561 2561 0 b12 m111 u112 111 10800
2562 2562 1 b11 m12 u111 112 7200
2563 2563 2 b111 m11 u12 111 3600
2564 2564 3 b112 m111 u11 120 0
2565 2565 4 b111 m112 u111 110 14400
2566 2566
2567 2567 $ hg log -r 'sort(all(), -rev)'
2568 2568 4 b111 m112 u111 110 14400
2569 2569 3 b112 m111 u11 120 0
2570 2570 2 b111 m11 u12 111 3600
2571 2571 1 b11 m12 u111 112 7200
2572 2572 0 b12 m111 u112 111 10800
2573 2573
2574 2574 compare variable-length strings (issue5218):
2575 2575
2576 2576 $ hg log -r 'sort(all(), branch)'
2577 2577 1 b11 m12 u111 112 7200
2578 2578 2 b111 m11 u12 111 3600
2579 2579 4 b111 m112 u111 110 14400
2580 2580 3 b112 m111 u11 120 0
2581 2581 0 b12 m111 u112 111 10800
2582 2582
2583 2583 $ hg log -r 'sort(all(), -branch)'
2584 2584 0 b12 m111 u112 111 10800
2585 2585 3 b112 m111 u11 120 0
2586 2586 2 b111 m11 u12 111 3600
2587 2587 4 b111 m112 u111 110 14400
2588 2588 1 b11 m12 u111 112 7200
2589 2589
2590 2590 $ hg log -r 'sort(all(), desc)'
2591 2591 2 b111 m11 u12 111 3600
2592 2592 0 b12 m111 u112 111 10800
2593 2593 3 b112 m111 u11 120 0
2594 2594 4 b111 m112 u111 110 14400
2595 2595 1 b11 m12 u111 112 7200
2596 2596
2597 2597 $ hg log -r 'sort(all(), -desc)'
2598 2598 1 b11 m12 u111 112 7200
2599 2599 4 b111 m112 u111 110 14400
2600 2600 0 b12 m111 u112 111 10800
2601 2601 3 b112 m111 u11 120 0
2602 2602 2 b111 m11 u12 111 3600
2603 2603
2604 2604 $ hg log -r 'sort(all(), user)'
2605 2605 3 b112 m111 u11 120 0
2606 2606 1 b11 m12 u111 112 7200
2607 2607 4 b111 m112 u111 110 14400
2608 2608 0 b12 m111 u112 111 10800
2609 2609 2 b111 m11 u12 111 3600
2610 2610
2611 2611 $ hg log -r 'sort(all(), -user)'
2612 2612 2 b111 m11 u12 111 3600
2613 2613 0 b12 m111 u112 111 10800
2614 2614 1 b11 m12 u111 112 7200
2615 2615 4 b111 m112 u111 110 14400
2616 2616 3 b112 m111 u11 120 0
2617 2617
2618 2618 compare dates (tz offset should have no effect):
2619 2619
2620 2620 $ hg log -r 'sort(all(), date)'
2621 2621 4 b111 m112 u111 110 14400
2622 2622 0 b12 m111 u112 111 10800
2623 2623 2 b111 m11 u12 111 3600
2624 2624 1 b11 m12 u111 112 7200
2625 2625 3 b112 m111 u11 120 0
2626 2626
2627 2627 $ hg log -r 'sort(all(), -date)'
2628 2628 3 b112 m111 u11 120 0
2629 2629 1 b11 m12 u111 112 7200
2630 2630 0 b12 m111 u112 111 10800
2631 2631 2 b111 m11 u12 111 3600
2632 2632 4 b111 m112 u111 110 14400
2633 2633
2634 2634 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2635 2635 because '-k' reverses the comparison, not the list itself:
2636 2636
2637 2637 $ hg log -r 'sort(0 + 2, date)'
2638 2638 0 b12 m111 u112 111 10800
2639 2639 2 b111 m11 u12 111 3600
2640 2640
2641 2641 $ hg log -r 'sort(0 + 2, -date)'
2642 2642 0 b12 m111 u112 111 10800
2643 2643 2 b111 m11 u12 111 3600
2644 2644
2645 2645 $ hg log -r 'reverse(sort(0 + 2, date))'
2646 2646 2 b111 m11 u12 111 3600
2647 2647 0 b12 m111 u112 111 10800
2648 2648
2649 2649 sort by multiple keys:
2650 2650
2651 2651 $ hg log -r 'sort(all(), "branch -rev")'
2652 2652 1 b11 m12 u111 112 7200
2653 2653 4 b111 m112 u111 110 14400
2654 2654 2 b111 m11 u12 111 3600
2655 2655 3 b112 m111 u11 120 0
2656 2656 0 b12 m111 u112 111 10800
2657 2657
2658 2658 $ hg log -r 'sort(all(), "-desc -date")'
2659 2659 1 b11 m12 u111 112 7200
2660 2660 4 b111 m112 u111 110 14400
2661 2661 3 b112 m111 u11 120 0
2662 2662 0 b12 m111 u112 111 10800
2663 2663 2 b111 m11 u12 111 3600
2664 2664
2665 2665 $ hg log -r 'sort(all(), "user -branch date rev")'
2666 2666 3 b112 m111 u11 120 0
2667 2667 4 b111 m112 u111 110 14400
2668 2668 1 b11 m12 u111 112 7200
2669 2669 0 b12 m111 u112 111 10800
2670 2670 2 b111 m11 u12 111 3600
2671 2671
2672 2672 toposort prioritises graph branches
2673 2673
2674 2674 $ hg up 2
2675 2675 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2676 2676 $ touch a
2677 2677 $ hg addremove
2678 2678 adding a
2679 2679 $ hg ci -m 't1' -u 'tu' -d '130 0'
2680 2680 created new head
2681 2681 $ echo 'a' >> a
2682 2682 $ hg ci -m 't2' -u 'tu' -d '130 0'
2683 2683 $ hg book book1
2684 2684 $ hg up 4
2685 2685 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2686 2686 (leaving bookmark book1)
2687 2687 $ touch a
2688 2688 $ hg addremove
2689 2689 adding a
2690 2690 $ hg ci -m 't3' -u 'tu' -d '130 0'
2691 2691
2692 2692 $ hg log -r 'sort(all(), topo)'
2693 2693 7 b111 t3 tu 130 0
2694 2694 4 b111 m112 u111 110 14400
2695 2695 3 b112 m111 u11 120 0
2696 2696 6 b111 t2 tu 130 0
2697 2697 5 b111 t1 tu 130 0
2698 2698 2 b111 m11 u12 111 3600
2699 2699 1 b11 m12 u111 112 7200
2700 2700 0 b12 m111 u112 111 10800
2701 2701
2702 2702 $ hg log -r 'sort(all(), -topo)'
2703 2703 0 b12 m111 u112 111 10800
2704 2704 1 b11 m12 u111 112 7200
2705 2705 2 b111 m11 u12 111 3600
2706 2706 5 b111 t1 tu 130 0
2707 2707 6 b111 t2 tu 130 0
2708 2708 3 b112 m111 u11 120 0
2709 2709 4 b111 m112 u111 110 14400
2710 2710 7 b111 t3 tu 130 0
2711 2711
2712 2712 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2713 2713 6 b111 t2 tu 130 0
2714 2714 5 b111 t1 tu 130 0
2715 2715 7 b111 t3 tu 130 0
2716 2716 4 b111 m112 u111 110 14400
2717 2717 3 b112 m111 u11 120 0
2718 2718 2 b111 m11 u12 111 3600
2719 2719 1 b11 m12 u111 112 7200
2720 2720 0 b12 m111 u112 111 10800
2721 2721
2722 2722 topographical sorting can't be combined with other sort keys, and you can't
2723 2723 use the topo.firstbranch option when topo sort is not active:
2724 2724
2725 2725 $ hg log -r 'sort(all(), "topo user")'
2726 2726 hg: parse error: topo sort order cannot be combined with other sort keys
2727 2727 [255]
2728 2728
2729 2729 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2730 2730 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2731 2731 [255]
2732 2732
2733 2733 topo.firstbranch should accept any kind of expressions:
2734 2734
2735 2735 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2736 2736 0 b12 m111 u112 111 10800
2737 2737
2738 2738 $ cd ..
2739 2739 $ cd repo
2740
2741 test subtracting something from an addset
2742
2743 $ log '(outgoing() or removes(a)) - removes(a)'
2744 8
2745 9
2746
2747 test intersecting something with an addset
2748
2749 $ log 'parents(outgoing() or removes(a))'
2750 1
2751 4
2752 5
2753 8
2754
2755 test that `or` operation combines elements in the right order:
2756
2757 $ log '3:4 or 2:5'
2758 3
2759 4
2760 2
2761 5
2762 $ log '3:4 or 5:2'
2763 3
2764 4
2765 5
2766 2
2767 $ log 'sort(3:4 or 2:5)'
2768 2
2769 3
2770 4
2771 5
2772 $ log 'sort(3:4 or 5:2)'
2773 2
2774 3
2775 4
2776 5
2777
2778 test that more than one `-r`s are combined in the right order and deduplicated:
2779
2780 $ hg log -T '{rev}\n' -r 3 -r 3 -r 4 -r 5:2 -r 'ancestors(4)'
2781 3
2782 4
2783 5
2784 2
2785 0
2786 1
2787
2788 test that `or` operation skips duplicated revisions from right-hand side
2789
2790 $ try 'reverse(1::5) or ancestors(4)'
2791 (or
2792 (list
2793 (func
2794 (symbol 'reverse')
2795 (dagrange
2796 (symbol '1')
2797 (symbol '5')))
2798 (func
2799 (symbol 'ancestors')
2800 (symbol '4'))))
2801 * set:
2802 <addset
2803 <baseset- [1, 3, 5]>,
2804 <generatorset+>>
2805 5
2806 3
2807 1
2808 0
2809 2
2810 4
2811 $ try 'sort(ancestors(4) or reverse(1::5))'
2812 (func
2813 (symbol 'sort')
2814 (or
2815 (list
2816 (func
2817 (symbol 'ancestors')
2818 (symbol '4'))
2819 (func
2820 (symbol 'reverse')
2821 (dagrange
2822 (symbol '1')
2823 (symbol '5'))))))
2824 * set:
2825 <addset+
2826 <generatorset+>,
2827 <baseset- [1, 3, 5]>>
2828 0
2829 1
2830 2
2831 3
2832 4
2833 5
2834
2835 test optimization of trivial `or` operation
2836
2837 $ try --optimize '0|(1)|"2"|-2|tip|null'
2838 (or
2839 (list
2840 (symbol '0')
2841 (group
2842 (symbol '1'))
2843 (string '2')
2844 (negate
2845 (symbol '2'))
2846 (symbol 'tip')
2847 (symbol 'null')))
2848 * optimized:
2849 (func
2850 (symbol '_list')
2851 (string '0\x001\x002\x00-2\x00tip\x00null'))
2852 * set:
2853 <baseset [0, 1, 2, 8, 9, -1]>
2854 0
2855 1
2856 2
2857 8
2858 9
2859 -1
2860
2861 $ try --optimize '0|1|2:3'
2862 (or
2863 (list
2864 (symbol '0')
2865 (symbol '1')
2866 (range
2867 (symbol '2')
2868 (symbol '3'))))
2869 * optimized:
2870 (or
2871 (list
2872 (func
2873 (symbol '_list')
2874 (string '0\x001'))
2875 (range
2876 (symbol '2')
2877 (symbol '3'))))
2878 * set:
2879 <addset
2880 <baseset [0, 1]>,
2881 <spanset+ 2:4>>
2882 0
2883 1
2884 2
2885 3
2886
2887 $ try --optimize '0:1|2|3:4|5|6'
2888 (or
2889 (list
2890 (range
2891 (symbol '0')
2892 (symbol '1'))
2893 (symbol '2')
2894 (range
2895 (symbol '3')
2896 (symbol '4'))
2897 (symbol '5')
2898 (symbol '6')))
2899 * optimized:
2900 (or
2901 (list
2902 (range
2903 (symbol '0')
2904 (symbol '1'))
2905 (symbol '2')
2906 (range
2907 (symbol '3')
2908 (symbol '4'))
2909 (func
2910 (symbol '_list')
2911 (string '5\x006'))))
2912 * set:
2913 <addset
2914 <addset
2915 <spanset+ 0:2>,
2916 <baseset [2]>>,
2917 <addset
2918 <spanset+ 3:5>,
2919 <baseset [5, 6]>>>
2920 0
2921 1
2922 2
2923 3
2924 4
2925 5
2926 6
2927
2928 unoptimized `or` looks like this
2929
2930 $ try --no-optimized -p analyzed '0|1|2|3|4'
2931 * analyzed:
2932 (or
2933 (list
2934 (symbol '0')
2935 (symbol '1')
2936 (symbol '2')
2937 (symbol '3')
2938 (symbol '4')))
2939 * set:
2940 <addset
2941 <addset
2942 <baseset [0]>,
2943 <baseset [1]>>,
2944 <addset
2945 <baseset [2]>,
2946 <addset
2947 <baseset [3]>,
2948 <baseset [4]>>>>
2949 0
2950 1
2951 2
2952 3
2953 4
2954
2955 test that `_list` should be narrowed by provided `subset`
2956
2957 $ log '0:2 and (null|1|2|3)'
2958 1
2959 2
2960
2961 test that `_list` should remove duplicates
2962
2963 $ log '0|1|2|1|2|-1|tip'
2964 0
2965 1
2966 2
2967 9
2968
2969 test unknown revision in `_list`
2970
2971 $ log '0|unknown'
2972 abort: unknown revision 'unknown'!
2973 [255]
2974
2975 test integer range in `_list`
2976
2977 $ log '-1|-10'
2978 9
2979 0
2980
2981 $ log '-10|-11'
2982 abort: unknown revision '-11'!
2983 [255]
2984
2985 $ log '9|10'
2986 abort: unknown revision '10'!
2987 [255]
2988
2989 test '0000' != '0' in `_list`
2990
2991 $ log '0|0000'
2992 0
2993 -1
2994
2995 test ',' in `_list`
2996 $ log '0,1'
2997 hg: parse error: can't use a list in this context
2998 (see hg help "revsets.x or y")
2999 [255]
3000 $ try '0,1,2'
3001 (list
3002 (symbol '0')
3003 (symbol '1')
3004 (symbol '2'))
3005 hg: parse error: can't use a list in this context
3006 (see hg help "revsets.x or y")
3007 [255]
3008
3009 test that chained `or` operations make balanced addsets
3010
3011 $ try '0:1|1:2|2:3|3:4|4:5'
3012 (or
3013 (list
3014 (range
3015 (symbol '0')
3016 (symbol '1'))
3017 (range
3018 (symbol '1')
3019 (symbol '2'))
3020 (range
3021 (symbol '2')
3022 (symbol '3'))
3023 (range
3024 (symbol '3')
3025 (symbol '4'))
3026 (range
3027 (symbol '4')
3028 (symbol '5'))))
3029 * set:
3030 <addset
3031 <addset
3032 <spanset+ 0:2>,
3033 <spanset+ 1:3>>,
3034 <addset
3035 <spanset+ 2:4>,
3036 <addset
3037 <spanset+ 3:5>,
3038 <spanset+ 4:6>>>>
3039 0
3040 1
3041 2
3042 3
3043 4
3044 5
3045
3046 no crash by empty group "()" while optimizing `or` operations
3047
3048 $ try --optimize '0|()'
3049 (or
3050 (list
3051 (symbol '0')
3052 (group
3053 None)))
3054 * optimized:
3055 (or
3056 (list
3057 (symbol '0')
3058 None))
3059 hg: parse error: missing argument
3060 [255]
3061
3062 test that chained `or` operations never eat up stack (issue4624)
3063 (uses `0:1` instead of `0` to avoid future optimization of trivial revisions)
3064
3065 $ hg log -T '{rev}\n' -r `$PYTHON -c "print '+'.join(['0:1'] * 500)"`
3066 0
3067 1
3068
3069 test that repeated `-r` options never eat up stack (issue4565)
3070 (uses `-r 0::1` to avoid possible optimization at old-style parser)
3071
3072 $ hg log -T '{rev}\n' `$PYTHON -c "for i in xrange(500): print '-r 0::1 ',"`
3073 0
3074 1
3075
3076 check that conversion to only works
3077 $ try --optimize '::3 - ::1'
3078 (minus
3079 (dagrangepre
3080 (symbol '3'))
3081 (dagrangepre
3082 (symbol '1')))
3083 * optimized:
3084 (func
3085 (symbol 'only')
3086 (list
3087 (symbol '3')
3088 (symbol '1')))
3089 * set:
3090 <baseset+ [3]>
3091 3
3092 $ try --optimize 'ancestors(1) - ancestors(3)'
3093 (minus
3094 (func
3095 (symbol 'ancestors')
3096 (symbol '1'))
3097 (func
3098 (symbol 'ancestors')
3099 (symbol '3')))
3100 * optimized:
3101 (func
3102 (symbol 'only')
3103 (list
3104 (symbol '1')
3105 (symbol '3')))
3106 * set:
3107 <baseset+ []>
3108 $ try --optimize 'not ::2 and ::6'
3109 (and
3110 (not
3111 (dagrangepre
3112 (symbol '2')))
3113 (dagrangepre
3114 (symbol '6')))
3115 * optimized:
3116 (func
3117 (symbol 'only')
3118 (list
3119 (symbol '6')
3120 (symbol '2')))
3121 * set:
3122 <baseset+ [3, 4, 5, 6]>
3123 3
3124 4
3125 5
3126 6
3127 $ try --optimize 'ancestors(6) and not ancestors(4)'
3128 (and
3129 (func
3130 (symbol 'ancestors')
3131 (symbol '6'))
3132 (not
3133 (func
3134 (symbol 'ancestors')
3135 (symbol '4'))))
3136 * optimized:
3137 (func
3138 (symbol 'only')
3139 (list
3140 (symbol '6')
3141 (symbol '4')))
3142 * set:
3143 <baseset+ [3, 5, 6]>
3144 3
3145 5
3146 6
3147
3148 no crash by empty group "()" while optimizing to "only()"
3149
3150 $ try --optimize '::1 and ()'
3151 (and
3152 (dagrangepre
3153 (symbol '1'))
3154 (group
3155 None))
3156 * optimized:
3157 (andsmally
3158 (func
3159 (symbol 'ancestors')
3160 (symbol '1'))
3161 None)
3162 hg: parse error: missing argument
3163 [255]
3164
3165 optimization to only() works only if ancestors() takes only one argument
3166
3167 $ hg debugrevspec -p optimized 'ancestors(6) - ancestors(4, 1)'
3168 * optimized:
3169 (difference
3170 (func
3171 (symbol 'ancestors')
3172 (symbol '6'))
3173 (func
3174 (symbol 'ancestors')
3175 (list
3176 (symbol '4')
3177 (symbol '1'))))
3178 0
3179 1
3180 3
3181 5
3182 6
3183 $ hg debugrevspec -p optimized 'ancestors(6, 1) - ancestors(4)'
3184 * optimized:
3185 (difference
3186 (func
3187 (symbol 'ancestors')
3188 (list
3189 (symbol '6')
3190 (symbol '1')))
3191 (func
3192 (symbol 'ancestors')
3193 (symbol '4')))
3194 5
3195 6
3196
3197 optimization disabled if keyword arguments passed (because we're too lazy
3198 to support it)
3199
3200 $ hg debugrevspec -p optimized 'ancestors(set=6) - ancestors(set=4)'
3201 * optimized:
3202 (difference
3203 (func
3204 (symbol 'ancestors')
3205 (keyvalue
3206 (symbol 'set')
3207 (symbol '6')))
3208 (func
3209 (symbol 'ancestors')
3210 (keyvalue
3211 (symbol 'set')
3212 (symbol '4'))))
3213 3
3214 5
3215 6
3216
3217 invalid function call should not be optimized to only()
3218
3219 $ log '"ancestors"(6) and not ancestors(4)'
3220 hg: parse error: not a symbol
3221 [255]
3222
3223 $ log 'ancestors(6) and not "ancestors"(4)'
3224 hg: parse error: not a symbol
3225 [255]
3226
3227 we can use patterns when searching for tags
3228
3229 $ log 'tag("1..*")'
3230 abort: tag '1..*' does not exist!
3231 [255]
3232 $ log 'tag("re:1..*")'
3233 6
3234 $ log 'tag("re:[0-9].[0-9]")'
3235 6
3236 $ log 'tag("literal:1.0")'
3237 6
3238 $ log 'tag("re:0..*")'
3239
3240 $ log 'tag(unknown)'
3241 abort: tag 'unknown' does not exist!
3242 [255]
3243 $ log 'tag("re:unknown")'
3244 $ log 'present(tag("unknown"))'
3245 $ log 'present(tag("re:unknown"))'
3246 $ log 'branch(unknown)'
3247 abort: unknown revision 'unknown'!
3248 [255]
3249 $ log 'branch("literal:unknown")'
3250 abort: branch 'unknown' does not exist!
3251 [255]
3252 $ log 'branch("re:unknown")'
3253 $ log 'present(branch("unknown"))'
3254 $ log 'present(branch("re:unknown"))'
3255 $ log 'user(bob)'
3256 2
3257
3258 $ log '4::8'
3259 4
3260 8
3261 $ log '4:8'
3262 4
3263 5
3264 6
3265 7
3266 8
3267
3268 $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
3269 4
3270 2
3271 5
3272
3273 $ log 'not 0 and 0:2'
3274 1
3275 2
3276 $ log 'not 1 and 0:2'
3277 0
3278 2
3279 $ log 'not 2 and 0:2'
3280 0
3281 1
3282 $ log '(1 and 2)::'
3283 $ log '(1 and 2):'
3284 $ log '(1 and 2):3'
3285 $ log 'sort(head(), -rev)'
3286 9
3287 7
3288 6
3289 5
3290 4
3291 3
3292 2
3293 1
3294 0
3295 $ log '4::8 - 8'
3296 4
3297
3298 matching() should preserve the order of the input set:
3299
3300 $ log '(2 or 3 or 1) and matching(1 or 2 or 3)'
3301 2
3302 3
3303 1
3304
3305 $ log 'named("unknown")'
3306 abort: namespace 'unknown' does not exist!
3307 [255]
3308 $ log 'named("re:unknown")'
3309 abort: no namespace exists that match 'unknown'!
3310 [255]
3311 $ log 'present(named("unknown"))'
3312 $ log 'present(named("re:unknown"))'
3313
3314 $ log 'tag()'
3315 6
3316 $ log 'named("tags")'
3317 6
3318
3319 issue2437
3320
3321 $ log '3 and p1(5)'
3322 3
3323 $ log '4 and p2(6)'
3324 4
3325 $ log '1 and parents(:2)'
3326 1
3327 $ log '2 and children(1:)'
3328 2
3329 $ log 'roots(all()) or roots(all())'
3330 0
3331 $ hg debugrevspec 'roots(all()) or roots(all())'
3332 0
3333 $ log 'heads(branch(Γ©)) or heads(branch(Γ©))'
3334 9
3335 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))'
3336 4
3337
3338 issue2654: report a parse error if the revset was not completely parsed
3339
3340 $ log '1 OR 2'
3341 hg: parse error at 2: invalid token
3342 [255]
3343
3344 or operator should preserve ordering:
3345 $ log 'reverse(2::4) or tip'
3346 4
3347 2
3348 9
3349
3350 parentrevspec
3351
3352 $ log 'merge()^0'
3353 6
3354 $ log 'merge()^'
3355 5
3356 $ log 'merge()^1'
3357 5
3358 $ log 'merge()^2'
3359 4
3360 $ log '(not merge())^2'
3361 $ log 'merge()^^'
3362 3
3363 $ log 'merge()^1^'
3364 3
3365 $ log 'merge()^^^'
3366 1
3367
3368 $ hg debugrevspec -s '(merge() | 0)~-1'
3369 * set:
3370 <baseset+ [1, 7]>
3371 1
3372 7
3373 $ log 'merge()~-1'
3374 7
3375 $ log 'tip~-1'
3376 $ log '(tip | merge())~-1'
3377 7
3378 $ log 'merge()~0'
3379 6
3380 $ log 'merge()~1'
3381 5
3382 $ log 'merge()~2'
3383 3
3384 $ log 'merge()~2^1'
3385 1
3386 $ log 'merge()~3'
3387 1
3388
3389 $ log '(-3:tip)^'
3390 4
3391 6
3392 8
3393
3394 $ log 'tip^foo'
3395 hg: parse error: ^ expects a number 0, 1, or 2
3396 [255]
3397
3398 $ log 'branchpoint()~-1'
3399 abort: revision in set has more than one child!
3400 [255]
3401
3402 Bogus function gets suggestions
3403 $ log 'add()'
3404 hg: parse error: unknown identifier: add
3405 (did you mean adds?)
3406 [255]
3407 $ log 'added()'
3408 hg: parse error: unknown identifier: added
3409 (did you mean adds?)
3410 [255]
3411 $ log 'remo()'
3412 hg: parse error: unknown identifier: remo
3413 (did you mean one of remote, removes?)
3414 [255]
3415 $ log 'babar()'
3416 hg: parse error: unknown identifier: babar
3417 [255]
3418
3419 Bogus function with a similar internal name doesn't suggest the internal name
3420 $ log 'matches()'
3421 hg: parse error: unknown identifier: matches
3422 (did you mean matching?)
3423 [255]
3424
3425 Undocumented functions aren't suggested as similar either
3426 $ log 'tagged2()'
3427 hg: parse error: unknown identifier: tagged2
3428 [255]
3429
3430 multiple revspecs
3431
3432 $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
3433 8
3434 9
3435 4
3436 5
3437 6
3438 7
3439
3440 test usage in revpair (with "+")
3441
3442 (real pair)
3443
3444 $ hg diff -r 'tip^^' -r 'tip'
3445 diff -r 2326846efdab -r 24286f4ae135 .hgtags
3446 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3447 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
3448 @@ -0,0 +1,1 @@
3449 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3450 $ hg diff -r 'tip^^::tip'
3451 diff -r 2326846efdab -r 24286f4ae135 .hgtags
3452 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3453 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
3454 @@ -0,0 +1,1 @@
3455 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3456
3457 (single rev)
3458
3459 $ hg diff -r 'tip^' -r 'tip^'
3460 $ hg diff -r 'tip^:tip^'
3461
3462 (single rev that does not looks like a range)
3463
3464 $ hg diff -r 'tip^::tip^ or tip^'
3465 diff -r d5d0dcbdc4d9 .hgtags
3466 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3467 +++ b/.hgtags * (glob)
3468 @@ -0,0 +1,1 @@
3469 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3470 $ hg diff -r 'tip^ or tip^'
3471 diff -r d5d0dcbdc4d9 .hgtags
3472 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3473 +++ b/.hgtags * (glob)
3474 @@ -0,0 +1,1 @@
3475 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3476
3477 (no rev)
3478
3479 $ hg diff -r 'author("babar") or author("celeste")'
3480 abort: empty revision range
3481 [255]
3482
3483 aliases:
3484
3485 $ echo '[revsetalias]' >> .hg/hgrc
3486 $ echo 'm = merge()' >> .hg/hgrc
3487 (revset aliases can override builtin revsets)
3488 $ echo 'p2($1) = p1($1)' >> .hg/hgrc
3489 $ echo 'sincem = descendants(m)' >> .hg/hgrc
3490 $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
3491 $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
3492 $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
3493
3494 $ try m
3495 (symbol 'm')
3496 * expanded:
3497 (func
3498 (symbol 'merge')
3499 None)
3500 * set:
3501 <filteredset
3502 <fullreposet+ 0:10>,
3503 <merge>>
3504 6
3505
3506 $ HGPLAIN=1
3507 $ export HGPLAIN
3508 $ try m
3509 (symbol 'm')
3510 abort: unknown revision 'm'!
3511 [255]
3512
3513 $ HGPLAINEXCEPT=revsetalias
3514 $ export HGPLAINEXCEPT
3515 $ try m
3516 (symbol 'm')
3517 * expanded:
3518 (func
3519 (symbol 'merge')
3520 None)
3521 * set:
3522 <filteredset
3523 <fullreposet+ 0:10>,
3524 <merge>>
3525 6
3526
3527 $ unset HGPLAIN
3528 $ unset HGPLAINEXCEPT
3529
3530 $ try 'p2(.)'
3531 (func
3532 (symbol 'p2')
3533 (symbol '.'))
3534 * expanded:
3535 (func
3536 (symbol 'p1')
3537 (symbol '.'))
3538 * set:
3539 <baseset+ [8]>
3540 8
3541
3542 $ HGPLAIN=1
3543 $ export HGPLAIN
3544 $ try 'p2(.)'
3545 (func
3546 (symbol 'p2')
3547 (symbol '.'))
3548 * set:
3549 <baseset+ []>
3550
3551 $ HGPLAINEXCEPT=revsetalias
3552 $ export HGPLAINEXCEPT
3553 $ try 'p2(.)'
3554 (func
3555 (symbol 'p2')
3556 (symbol '.'))
3557 * expanded:
3558 (func
3559 (symbol 'p1')
3560 (symbol '.'))
3561 * set:
3562 <baseset+ [8]>
3563 8
3564
3565 $ unset HGPLAIN
3566 $ unset HGPLAINEXCEPT
3567
3568 test alias recursion
3569
3570 $ try sincem
3571 (symbol 'sincem')
3572 * expanded:
3573 (func
3574 (symbol 'descendants')
3575 (func
3576 (symbol 'merge')
3577 None))
3578 * set:
3579 <generatorset+>
3580 6
3581 7
3582
3583 test infinite recursion
3584
3585 $ echo 'recurse1 = recurse2' >> .hg/hgrc
3586 $ echo 'recurse2 = recurse1' >> .hg/hgrc
3587 $ try recurse1
3588 (symbol 'recurse1')
3589 hg: parse error: infinite expansion of revset alias "recurse1" detected
3590 [255]
3591
3592 $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc
3593 $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc
3594 $ try "level2(level1(1, 2), 3)"
3595 (func
3596 (symbol 'level2')
3597 (list
3598 (func
3599 (symbol 'level1')
3600 (list
3601 (symbol '1')
3602 (symbol '2')))
3603 (symbol '3')))
3604 * expanded:
3605 (or
3606 (list
3607 (symbol '3')
3608 (or
3609 (list
3610 (symbol '1')
3611 (symbol '2')))))
3612 * set:
3613 <addset
3614 <baseset [3]>,
3615 <baseset [1, 2]>>
3616 3
3617 1
3618 2
3619
3620 test nesting and variable passing
3621
3622 $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
3623 $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
3624 $ echo 'nested3($1) = max($1)' >> .hg/hgrc
3625 $ try 'nested(2:5)'
3626 (func
3627 (symbol 'nested')
3628 (range
3629 (symbol '2')
3630 (symbol '5')))
3631 * expanded:
3632 (func
3633 (symbol 'max')
3634 (range
3635 (symbol '2')
3636 (symbol '5')))
3637 * set:
3638 <baseset
3639 <max
3640 <fullreposet+ 0:10>,
3641 <spanset+ 2:6>>>
3642 5
3643
3644 test chained `or` operations are flattened at parsing phase
3645
3646 $ echo 'chainedorops($1, $2, $3) = $1|$2|$3' >> .hg/hgrc
3647 $ try 'chainedorops(0:1, 1:2, 2:3)'
3648 (func
3649 (symbol 'chainedorops')
3650 (list
3651 (range
3652 (symbol '0')
3653 (symbol '1'))
3654 (range
3655 (symbol '1')
3656 (symbol '2'))
3657 (range
3658 (symbol '2')
3659 (symbol '3'))))
3660 * expanded:
3661 (or
3662 (list
3663 (range
3664 (symbol '0')
3665 (symbol '1'))
3666 (range
3667 (symbol '1')
3668 (symbol '2'))
3669 (range
3670 (symbol '2')
3671 (symbol '3'))))
3672 * set:
3673 <addset
3674 <spanset+ 0:2>,
3675 <addset
3676 <spanset+ 1:3>,
3677 <spanset+ 2:4>>>
3678 0
3679 1
3680 2
3681 3
3682
3683 test variable isolation, variable placeholders are rewritten as string
3684 then parsed and matched again as string. Check they do not leak too
3685 far away.
3686
3687 $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
3688 $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
3689 $ try 'callinjection(2:5)'
3690 (func
3691 (symbol 'callinjection')
3692 (range
3693 (symbol '2')
3694 (symbol '5')))
3695 * expanded:
3696 (func
3697 (symbol 'descendants')
3698 (func
3699 (symbol 'max')
3700 (string '$1')))
3701 abort: unknown revision '$1'!
3702 [255]
3703
3704 test scope of alias expansion: 'universe' is expanded prior to 'shadowall(0)',
3705 but 'all()' should never be substituted to '0()'.
3706
3707 $ echo 'universe = all()' >> .hg/hgrc
3708 $ echo 'shadowall(all) = all and universe' >> .hg/hgrc
3709 $ try 'shadowall(0)'
3710 (func
3711 (symbol 'shadowall')
3712 (symbol '0'))
3713 * expanded:
3714 (and
3715 (symbol '0')
3716 (func
3717 (symbol 'all')
3718 None))
3719 * set:
3720 <filteredset
3721 <baseset [0]>,
3722 <spanset+ 0:10>>
3723 0
3724
3725 test unknown reference:
3726
3727 $ try "unknownref(0)" --config 'revsetalias.unknownref($1)=$1:$2'
3728 (func
3729 (symbol 'unknownref')
3730 (symbol '0'))
3731 abort: bad definition of revset alias "unknownref": invalid symbol '$2'
3732 [255]
3733
3734 $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
3735 (symbol 'tip')
3736 warning: bad definition of revset alias "anotherbadone": at 7: not a prefix: end
3737 * set:
3738 <baseset [9]>
3739 9
3740
3741 $ try 'tip'
3742 (symbol 'tip')
3743 * set:
3744 <baseset [9]>
3745 9
3746
3747 $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
3748 (symbol 'tip')
3749 warning: bad declaration of revset alias "bad name": at 4: invalid token
3750 * set:
3751 <baseset [9]>
3752 9
3753 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
3754 $ try 'strictreplacing("foo", tip)'
3755 (func
3756 (symbol 'strictreplacing')
3757 (list
3758 (string 'foo')
3759 (symbol 'tip')))
3760 * expanded:
3761 (or
3762 (list
3763 (symbol 'tip')
3764 (func
3765 (symbol 'desc')
3766 (string '$1'))))
3767 * set:
3768 <addset
3769 <baseset [9]>,
3770 <filteredset
3771 <fullreposet+ 0:10>,
3772 <desc '$1'>>>
3773 9
3774
3775 $ try 'd(2:5)'
3776 (func
3777 (symbol 'd')
3778 (range
3779 (symbol '2')
3780 (symbol '5')))
3781 * expanded:
3782 (func
3783 (symbol 'reverse')
3784 (func
3785 (symbol 'sort')
3786 (list
3787 (range
3788 (symbol '2')
3789 (symbol '5'))
3790 (symbol 'date'))))
3791 * set:
3792 <baseset [4, 5, 3, 2]>
3793 4
3794 5
3795 3
3796 2
3797 $ try 'rs(2 or 3, date)'
3798 (func
3799 (symbol 'rs')
3800 (list
3801 (or
3802 (list
3803 (symbol '2')
3804 (symbol '3')))
3805 (symbol 'date')))
3806 * expanded:
3807 (func
3808 (symbol 'reverse')
3809 (func
3810 (symbol 'sort')
3811 (list
3812 (or
3813 (list
3814 (symbol '2')
3815 (symbol '3')))
3816 (symbol 'date'))))
3817 * set:
3818 <baseset [3, 2]>
3819 3
3820 2
3821 $ try 'rs()'
3822 (func
3823 (symbol 'rs')
3824 None)
3825 hg: parse error: invalid number of arguments: 0
3826 [255]
3827 $ try 'rs(2)'
3828 (func
3829 (symbol 'rs')
3830 (symbol '2'))
3831 hg: parse error: invalid number of arguments: 1
3832 [255]
3833 $ try 'rs(2, data, 7)'
3834 (func
3835 (symbol 'rs')
3836 (list
3837 (symbol '2')
3838 (symbol 'data')
3839 (symbol '7')))
3840 hg: parse error: invalid number of arguments: 3
3841 [255]
3842 $ try 'rs4(2 or 3, x, x, date)'
3843 (func
3844 (symbol 'rs4')
3845 (list
3846 (or
3847 (list
3848 (symbol '2')
3849 (symbol '3')))
3850 (symbol 'x')
3851 (symbol 'x')
3852 (symbol 'date')))
3853 * expanded:
3854 (func
3855 (symbol 'reverse')
3856 (func
3857 (symbol 'sort')
3858 (list
3859 (or
3860 (list
3861 (symbol '2')
3862 (symbol '3')))
3863 (symbol 'date'))))
3864 * set:
3865 <baseset [3, 2]>
3866 3
3867 2
3868
3869 issue4553: check that revset aliases override existing hash prefix
3870
3871 $ hg log -qr e
3872 6:e0cc66ef77e8
3873
3874 $ hg log -qr e --config revsetalias.e="all()"
3875 0:2785f51eece5
3876 1:d75937da8da0
3877 2:5ed5505e9f1c
3878 3:8528aa5637f2
3879 4:2326846efdab
3880 5:904fa392b941
3881 6:e0cc66ef77e8
3882 7:013af1973af4
3883 8:d5d0dcbdc4d9
3884 9:24286f4ae135
3885
3886 $ hg log -qr e: --config revsetalias.e="0"
3887 0:2785f51eece5
3888 1:d75937da8da0
3889 2:5ed5505e9f1c
3890 3:8528aa5637f2
3891 4:2326846efdab
3892 5:904fa392b941
3893 6:e0cc66ef77e8
3894 7:013af1973af4
3895 8:d5d0dcbdc4d9
3896 9:24286f4ae135
3897
3898 $ hg log -qr :e --config revsetalias.e="9"
3899 0:2785f51eece5
3900 1:d75937da8da0
3901 2:5ed5505e9f1c
3902 3:8528aa5637f2
3903 4:2326846efdab
3904 5:904fa392b941
3905 6:e0cc66ef77e8
3906 7:013af1973af4
3907 8:d5d0dcbdc4d9
3908 9:24286f4ae135
3909
3910 $ hg log -qr e:
3911 6:e0cc66ef77e8
3912 7:013af1973af4
3913 8:d5d0dcbdc4d9
3914 9:24286f4ae135
3915
3916 $ hg log -qr :e
3917 0:2785f51eece5
3918 1:d75937da8da0
3919 2:5ed5505e9f1c
3920 3:8528aa5637f2
3921 4:2326846efdab
3922 5:904fa392b941
3923 6:e0cc66ef77e8
3924
3925 issue2549 - correct optimizations
3926
3927 $ try 'limit(1 or 2 or 3, 2) and not 2'
3928 (and
3929 (func
3930 (symbol 'limit')
3931 (list
3932 (or
3933 (list
3934 (symbol '1')
3935 (symbol '2')
3936 (symbol '3')))
3937 (symbol '2')))
3938 (not
3939 (symbol '2')))
3940 * set:
3941 <filteredset
3942 <baseset [1, 2]>,
3943 <not
3944 <baseset [2]>>>
3945 1
3946 $ try 'max(1 or 2) and not 2'
3947 (and
3948 (func
3949 (symbol 'max')
3950 (or
3951 (list
3952 (symbol '1')
3953 (symbol '2'))))
3954 (not
3955 (symbol '2')))
3956 * set:
3957 <filteredset
3958 <baseset
3959 <max
3960 <fullreposet+ 0:10>,
3961 <baseset [1, 2]>>>,
3962 <not
3963 <baseset [2]>>>
3964 $ try 'min(1 or 2) and not 1'
3965 (and
3966 (func
3967 (symbol 'min')
3968 (or
3969 (list
3970 (symbol '1')
3971 (symbol '2'))))
3972 (not
3973 (symbol '1')))
3974 * set:
3975 <filteredset
3976 <baseset
3977 <min
3978 <fullreposet+ 0:10>,
3979 <baseset [1, 2]>>>,
3980 <not
3981 <baseset [1]>>>
3982 $ try 'last(1 or 2, 1) and not 2'
3983 (and
3984 (func
3985 (symbol 'last')
3986 (list
3987 (or
3988 (list
3989 (symbol '1')
3990 (symbol '2')))
3991 (symbol '1')))
3992 (not
3993 (symbol '2')))
3994 * set:
3995 <filteredset
3996 <baseset [2]>,
3997 <not
3998 <baseset [2]>>>
3999
4000 issue4289 - ordering of built-ins
4001 $ hg log -M -q -r 3:2
4002 3:8528aa5637f2
4003 2:5ed5505e9f1c
4004
4005 test revsets started with 40-chars hash (issue3669)
4006
4007 $ ISSUE3669_TIP=`hg tip --template '{node}'`
4008 $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n'
4009 9
4010 $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n'
4011 8
4012
4013 test or-ed indirect predicates (issue3775)
4014
4015 $ log '6 or 6^1' | sort
4016 5
4017 6
4018 $ log '6^1 or 6' | sort
4019 5
4020 6
4021 $ log '4 or 4~1' | sort
4022 2
4023 4
4024 $ log '4~1 or 4' | sort
4025 2
4026 4
4027 $ log '(0 or 2):(4 or 6) or 0 or 6' | sort
4028 0
4029 1
4030 2
4031 3
4032 4
4033 5
4034 6
4035 $ log '0 or 6 or (0 or 2):(4 or 6)' | sort
4036 0
4037 1
4038 2
4039 3
4040 4
4041 5
4042 6
4043
4044 tests for 'remote()' predicate:
4045 #. (csets in remote) (id) (remote)
4046 1. less than local current branch "default"
4047 2. same with local specified "default"
4048 3. more than local specified specified
4049
4050 $ hg clone --quiet -U . ../remote3
4051 $ cd ../remote3
4052 $ hg update -q 7
4053 $ echo r > r
4054 $ hg ci -Aqm 10
4055 $ log 'remote()'
4056 7
4057 $ log 'remote("a-b-c-")'
4058 2
4059 $ cd ../repo
4060 $ log 'remote(".a.b.c.", "../remote3")'
4061
4062 tests for concatenation of strings/symbols by "##"
4063
4064 $ try "278 ## '5f5' ## 1ee ## 'ce5'"
4065 (_concat
4066 (_concat
4067 (_concat
4068 (symbol '278')
4069 (string '5f5'))
4070 (symbol '1ee'))
4071 (string 'ce5'))
4072 * concatenated:
4073 (string '2785f51eece5')
4074 * set:
4075 <baseset [0]>
4076 0
4077
4078 $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc
4079 $ try "cat4(278, '5f5', 1ee, 'ce5')"
4080 (func
4081 (symbol 'cat4')
4082 (list
4083 (symbol '278')
4084 (string '5f5')
4085 (symbol '1ee')
4086 (string 'ce5')))
4087 * expanded:
4088 (_concat
4089 (_concat
4090 (_concat
4091 (symbol '278')
4092 (string '5f5'))
4093 (symbol '1ee'))
4094 (string 'ce5'))
4095 * concatenated:
4096 (string '2785f51eece5')
4097 * set:
4098 <baseset [0]>
4099 0
4100
4101 (check concatenation in alias nesting)
4102
4103 $ echo 'cat2($1, $2) = $1 ## $2' >> .hg/hgrc
4104 $ echo 'cat2x2($1, $2, $3, $4) = cat2($1 ## $2, $3 ## $4)' >> .hg/hgrc
4105 $ log "cat2x2(278, '5f5', 1ee, 'ce5')"
4106 0
4107
4108 (check operator priority)
4109
4110 $ echo 'cat2n2($1, $2, $3, $4) = $1 ## $2 or $3 ## $4~2' >> .hg/hgrc
4111 $ log "cat2n2(2785f5, 1eece5, 24286f, 4ae135)"
4112 0
4113 4
4114
4115 $ cd ..
4116
4117 prepare repository that has "default" branches of multiple roots
4118
4119 $ hg init namedbranch
4120 $ cd namedbranch
4121
4122 $ echo default0 >> a
4123 $ hg ci -Aqm0
4124 $ echo default1 >> a
4125 $ hg ci -m1
4126
4127 $ hg branch -q stable
4128 $ echo stable2 >> a
4129 $ hg ci -m2
4130 $ echo stable3 >> a
4131 $ hg ci -m3
4132
4133 $ hg update -q null
4134 $ echo default4 >> a
4135 $ hg ci -Aqm4
4136 $ echo default5 >> a
4137 $ hg ci -m5
4138
4139 "null" revision belongs to "default" branch (issue4683)
4140
4141 $ log 'branch(null)'
4142 0
4143 1
4144 4
4145 5
4146
4147 "null" revision belongs to "default" branch, but it shouldn't appear in set
4148 unless explicitly specified (issue4682)
4149
4150 $ log 'children(branch(default))'
4151 1
4152 2
4153 5
4154
4155 $ cd ..
4156
4157 test author/desc/keyword in problematic encoding
4158 # unicode: cp932:
4159 # u30A2 0x83 0x41(= 'A')
4160 # u30C2 0x83 0x61(= 'a')
4161
4162 $ hg init problematicencoding
4163 $ cd problematicencoding
4164
4165 $ $PYTHON > setup.sh <<EOF
4166 > print u'''
4167 > echo a > text
4168 > hg add text
4169 > hg --encoding utf-8 commit -u '\u30A2' -m none
4170 > echo b > text
4171 > hg --encoding utf-8 commit -u '\u30C2' -m none
4172 > echo c > text
4173 > hg --encoding utf-8 commit -u none -m '\u30A2'
4174 > echo d > text
4175 > hg --encoding utf-8 commit -u none -m '\u30C2'
4176 > '''.encode('utf-8')
4177 > EOF
4178 $ sh < setup.sh
4179
4180 test in problematic encoding
4181 $ $PYTHON > test.sh <<EOF
4182 > print u'''
4183 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
4184 > echo ====
4185 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
4186 > echo ====
4187 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
4188 > echo ====
4189 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
4190 > echo ====
4191 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
4192 > echo ====
4193 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
4194 > '''.encode('cp932')
4195 > EOF
4196 $ sh < test.sh
4197 0
4198 ====
4199 1
4200 ====
4201 2
4202 ====
4203 3
4204 ====
4205 0
4206 2
4207 ====
4208 1
4209 3
4210
4211 test error message of bad revset
4212 $ hg log -r 'foo\\'
4213 hg: parse error at 3: syntax error in revset 'foo\\'
4214 [255]
4215
4216 $ cd ..
4217
4218 Test that revset predicate of extension isn't loaded at failure of
4219 loading it
4220
4221 $ cd repo
4222
4223 $ cat <<EOF > $TESTTMP/custompredicate.py
4224 > from mercurial import error, registrar, revset
4225 >
4226 > revsetpredicate = registrar.revsetpredicate()
4227 >
4228 > @revsetpredicate('custom1()')
4229 > def custom1(repo, subset, x):
4230 > return revset.baseset([1])
4231 >
4232 > raise error.Abort('intentional failure of loading extension')
4233 > EOF
4234 $ cat <<EOF > .hg/hgrc
4235 > [extensions]
4236 > custompredicate = $TESTTMP/custompredicate.py
4237 > EOF
4238
4239 $ hg debugrevspec "custom1()"
4240 *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
4241 hg: parse error: unknown identifier: custom1
4242 [255]
4243
4244 Test repo.anyrevs with customized revset overrides
4245
4246 $ cat > $TESTTMP/printprevset.py <<EOF
4247 > from mercurial import encoding, registrar
4248 > cmdtable = {}
4249 > command = registrar.command(cmdtable)
4250 > @command('printprevset')
4251 > def printprevset(ui, repo):
4252 > alias = {}
4253 > p = encoding.environ.get('P')
4254 > if p:
4255 > alias['P'] = p
4256 > revs = repo.anyrevs(['P'], user=True, localalias=alias)
4257 > ui.write('P=%r\n' % list(revs))
4258 > EOF
4259
4260 $ cat >> .hg/hgrc <<EOF
4261 > custompredicate = !
4262 > printprevset = $TESTTMP/printprevset.py
4263 > EOF
4264
4265 $ hg --config revsetalias.P=1 printprevset
4266 P=[1]
4267 $ P=3 hg --config revsetalias.P=2 printprevset
4268 P=[3]
4269
4270 $ cd ..
4271
4272 Test obsstore related revsets
4273
4274 $ hg init repo1
4275 $ cd repo1
4276 $ cat <<EOF >> .hg/hgrc
4277 > [experimental]
4278 > stabilization = createmarkers
4279 > EOF
4280
4281 $ hg debugdrawdag <<'EOS'
4282 > F G
4283 > |/ # split: B -> E, F
4284 > B C D E # amend: B -> C -> D
4285 > \|/ | # amend: F -> G
4286 > A A Z # amend: A -> Z
4287 > EOS
4288
4289 $ hg log -r 'successors(Z)' -T '{desc}\n'
4290 Z
4291
4292 $ hg log -r 'successors(F)' -T '{desc}\n'
4293 F
4294 G
4295
4296 $ hg tag --remove --local C D E F G
4297
4298 $ hg log -r 'successors(B)' -T '{desc}\n'
4299 B
4300 D
4301 E
4302 G
4303
4304 $ hg log -r 'successors(B)' -T '{desc}\n' --hidden
4305 B
4306 C
4307 D
4308 E
4309 F
4310 G
4311
4312 $ hg log -r 'successors(B)-obsolete()' -T '{desc}\n' --hidden
4313 D
4314 E
4315 G
4316
4317 $ hg log -r 'successors(B+A)-contentdivergent()' -T '{desc}\n'
4318 A
4319 Z
4320 B
4321
4322 $ hg log -r 'successors(B+A)-contentdivergent()-obsolete()' -T '{desc}\n'
4323 Z
4324
4325 Test `draft() & ::x` optimization
4326
4327 $ hg init $TESTTMP/repo2
4328 $ cd $TESTTMP/repo2
4329 $ hg debugdrawdag <<'EOS'
4330 > P5 S1
4331 > | |
4332 > S2 | D3
4333 > \|/
4334 > P4
4335 > |
4336 > P3 D2
4337 > | |
4338 > P2 D1
4339 > |/
4340 > P1
4341 > |
4342 > P0
4343 > EOS
4344 $ hg phase --public -r P5
4345 $ hg phase --force --secret -r S1+S2
4346 $ hg log -G -T '{rev} {desc} {phase}' -r 'sort(all(), topo, topo.firstbranch=P5)'
4347 o 8 P5 public
4348 |
4349 | o 10 S1 secret
4350 | |
4351 | o 7 D3 draft
4352 |/
4353 | o 9 S2 secret
4354 |/
4355 o 6 P4 public
4356 |
4357 o 5 P3 public
4358 |
4359 o 3 P2 public
4360 |
4361 | o 4 D2 draft
4362 | |
4363 | o 2 D1 draft
4364 |/
4365 o 1 P1 public
4366 |
4367 o 0 P0 public
4368
4369 $ hg debugrevspec --verify -p analyzed -p optimized 'draft() & ::(((S1+D1+P5)-D3)+S2)'
4370 * analyzed:
4371 (and
4372 (func
4373 (symbol 'draft')
4374 None)
4375 (func
4376 (symbol 'ancestors')
4377 (or
4378 (list
4379 (and
4380 (or
4381 (list
4382 (symbol 'S1')
4383 (symbol 'D1')
4384 (symbol 'P5')))
4385 (not
4386 (symbol 'D3')))
4387 (symbol 'S2')))))
4388 * optimized:
4389 (func
4390 (symbol '_phaseandancestors')
4391 (list
4392 (symbol 'draft')
4393 (or
4394 (list
4395 (difference
4396 (func
4397 (symbol '_list')
4398 (string 'S1\x00D1\x00P5'))
4399 (symbol 'D3'))
4400 (symbol 'S2')))))
4401 $ hg debugrevspec --verify -p analyzed -p optimized 'secret() & ::9'
4402 * analyzed:
4403 (and
4404 (func
4405 (symbol 'secret')
4406 None)
4407 (func
4408 (symbol 'ancestors')
4409 (symbol '9')))
4410 * optimized:
4411 (func
4412 (symbol '_phaseandancestors')
4413 (list
4414 (symbol 'secret')
4415 (symbol '9')))
4416 $ hg debugrevspec --verify -p analyzed -p optimized '7 & ( (not public()) & ::(tag()) )'
4417 * analyzed:
4418 (and
4419 (symbol '7')
4420 (and
4421 (not
4422 (func
4423 (symbol 'public')
4424 None))
4425 (func
4426 (symbol 'ancestors')
4427 (func
4428 (symbol 'tag')
4429 None))))
4430 * optimized:
4431 (and
4432 (symbol '7')
4433 (func
4434 (symbol '_phaseandancestors')
4435 (list
4436 (symbol '_notpublic')
4437 (func
4438 (symbol 'tag')
4439 None))))
4440 $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, 1)'
4441 * optimized:
4442 (and
4443 (func
4444 (symbol '_notpublic')
4445 None)
4446 (func
4447 (symbol 'ancestors')
4448 (list
4449 (func
4450 (symbol '_list')
4451 (string 'S1\x00D2\x00P5'))
4452 (symbol '1'))))
4453 $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, depth=1)'
4454 * optimized:
4455 (and
4456 (func
4457 (symbol '_notpublic')
4458 None)
4459 (func
4460 (symbol 'ancestors')
4461 (list
4462 (func
4463 (symbol '_list')
4464 (string 'S1\x00D2\x00P5'))
4465 (keyvalue
4466 (symbol 'depth')
4467 (symbol '1')))))
This diff has been collapsed as it changes many lines, (2649 lines changed) Show them Hide them
@@ -1,4467 +1,1818
1 1 $ HGENCODING=utf-8
2 2 $ export HGENCODING
3 $ cat > testrevset.py << EOF
4 > import mercurial.revset
5 >
6 > baseset = mercurial.revset.baseset
7 >
8 > def r3232(repo, subset, x):
9 > """"simple revset that return [3,2,3,2]
10 >
11 > revisions duplicated on purpose.
12 > """
13 > if 3 not in subset:
14 > if 2 in subset:
15 > return baseset([2,2])
16 > return baseset()
17 > return baseset([3,3,2,2])
18 >
19 > mercurial.revset.symbols['r3232'] = r3232
20 > EOF
21 3 $ cat >> $HGRCPATH << EOF
22 4 > [extensions]
23 5 > drawdag=$TESTDIR/drawdag.py
24 > testrevset=$TESTTMP/testrevset.py
25 6 > EOF
26 7
27 8 $ try() {
28 9 > hg debugrevspec --debug "$@"
29 10 > }
30 11
31 12 $ log() {
32 13 > hg log --template '{rev}\n' -r "$1"
33 14 > }
34 15
35 extension to build '_intlist()' and '_hexlist()', which is necessary because
36 these predicates use '\0' as a separator:
37
38 $ cat <<EOF > debugrevlistspec.py
39 > from __future__ import absolute_import
40 > from mercurial import (
41 > node as nodemod,
42 > registrar,
43 > revset,
44 > revsetlang,
45 > smartset,
46 > )
47 > cmdtable = {}
48 > command = registrar.command(cmdtable)
49 > @command(b'debugrevlistspec',
50 > [('', 'optimize', None, 'print parsed tree after optimizing'),
51 > ('', 'bin', None, 'unhexlify arguments')])
52 > def debugrevlistspec(ui, repo, fmt, *args, **opts):
53 > if opts['bin']:
54 > args = map(nodemod.bin, args)
55 > expr = revsetlang.formatspec(fmt, list(args))
56 > if ui.verbose:
57 > tree = revsetlang.parse(expr, lookup=repo.__contains__)
58 > ui.note(revsetlang.prettyformat(tree), "\n")
59 > if opts["optimize"]:
60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 > ui.note("* optimized:\n", revsetlang.prettyformat(opttree),
62 > "\n")
63 > func = revset.match(ui, expr, repo)
64 > revs = func(repo)
65 > if ui.verbose:
66 > ui.note("* set:\n", smartset.prettyformat(revs), "\n")
67 > for c in revs:
68 > ui.write("%s\n" % c)
69 > EOF
70 $ cat <<EOF >> $HGRCPATH
71 > [extensions]
72 > debugrevlistspec = $TESTTMP/debugrevlistspec.py
73 > EOF
74 $ trylist() {
75 > hg debugrevlistspec --debug "$@"
76 > }
77
78 16 $ hg init repo
79 17 $ cd repo
80 18
81 19 $ echo a > a
82 20 $ hg branch a
83 21 marked working directory as branch a
84 22 (branches are permanent and global, did you want a bookmark?)
85 23 $ hg ci -Aqm0
86 24
87 25 $ echo b > b
88 26 $ hg branch b
89 27 marked working directory as branch b
90 28 $ hg ci -Aqm1
91 29
92 30 $ rm a
93 31 $ hg branch a-b-c-
94 32 marked working directory as branch a-b-c-
95 33 $ hg ci -Aqm2 -u Bob
96 34
97 35 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
98 36 2
99 37 $ hg log -r "extra('branch')" --template '{rev}\n'
100 38 0
101 39 1
102 40 2
103 41 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
104 42 0 a
105 43 2 a-b-c-
106 44
107 45 $ hg co 1
108 46 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 47 $ hg branch +a+b+c+
110 48 marked working directory as branch +a+b+c+
111 49 $ hg ci -Aqm3
112 50
113 51 $ hg co 2 # interleave
114 52 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 53 $ echo bb > b
116 54 $ hg branch -- -a-b-c-
117 55 marked working directory as branch -a-b-c-
118 56 $ hg ci -Aqm4 -d "May 12 2005"
119 57
120 58 $ hg co 3
121 59 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 60 $ hg branch !a/b/c/
123 61 marked working directory as branch !a/b/c/
124 62 $ hg ci -Aqm"5 bug"
125 63
126 64 $ hg merge 4
127 65 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
128 66 (branch merge, don't forget to commit)
129 67 $ hg branch _a_b_c_
130 68 marked working directory as branch _a_b_c_
131 69 $ hg ci -Aqm"6 issue619"
132 70
133 71 $ hg branch .a.b.c.
134 72 marked working directory as branch .a.b.c.
135 73 $ hg ci -Aqm7
136 74
137 75 $ hg branch all
138 76 marked working directory as branch all
139 77
140 78 $ hg co 4
141 79 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 80 $ hg branch Γ©
143 81 marked working directory as branch \xc3\xa9 (esc)
144 82 $ hg ci -Aqm9
145 83
146 84 $ hg tag -r6 1.0
147 85 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
148 86
149 87 $ hg clone --quiet -U -r 7 . ../remote1
150 88 $ hg clone --quiet -U -r 8 . ../remote2
151 89 $ echo "[paths]" >> .hg/hgrc
152 90 $ echo "default = ../remote1" >> .hg/hgrc
153 91
154 trivial
155
156 $ try 0:1
157 (range
158 (symbol '0')
159 (symbol '1'))
160 * set:
161 <spanset+ 0:2>
162 0
163 1
164 $ try --optimize :
165 (rangeall
166 None)
167 * optimized:
168 (rangeall
169 None)
170 * set:
171 <spanset+ 0:10>
172 0
173 1
174 2
175 3
176 4
177 5
178 6
179 7
180 8
181 9
182 $ try 3::6
183 (dagrange
184 (symbol '3')
185 (symbol '6'))
186 * set:
187 <baseset+ [3, 5, 6]>
188 3
189 5
190 6
191 $ try '0|1|2'
192 (or
193 (list
194 (symbol '0')
195 (symbol '1')
196 (symbol '2')))
197 * set:
198 <baseset [0, 1, 2]>
199 0
200 1
201 2
202
203 names that should work without quoting
204
205 $ try a
206 (symbol 'a')
207 * set:
208 <baseset [0]>
209 0
210 $ try b-a
211 (minus
212 (symbol 'b')
213 (symbol 'a'))
214 * set:
215 <filteredset
216 <baseset [1]>,
217 <not
218 <baseset [0]>>>
219 1
220 $ try _a_b_c_
221 (symbol '_a_b_c_')
222 * set:
223 <baseset [6]>
224 6
225 $ try _a_b_c_-a
226 (minus
227 (symbol '_a_b_c_')
228 (symbol 'a'))
229 * set:
230 <filteredset
231 <baseset [6]>,
232 <not
233 <baseset [0]>>>
234 6
235 $ try .a.b.c.
236 (symbol '.a.b.c.')
237 * set:
238 <baseset [7]>
239 7
240 $ try .a.b.c.-a
241 (minus
242 (symbol '.a.b.c.')
243 (symbol 'a'))
244 * set:
245 <filteredset
246 <baseset [7]>,
247 <not
248 <baseset [0]>>>
249 7
250
251 names that should be caught by fallback mechanism
252
253 $ try -- '-a-b-c-'
254 (symbol '-a-b-c-')
255 * set:
256 <baseset [4]>
257 4
258 $ log -a-b-c-
259 4
260 $ try '+a+b+c+'
261 (symbol '+a+b+c+')
262 * set:
263 <baseset [3]>
264 3
265 $ try '+a+b+c+:'
266 (rangepost
267 (symbol '+a+b+c+'))
268 * set:
269 <spanset+ 3:10>
270 3
271 4
272 5
273 6
274 7
275 8
276 9
277 $ try ':+a+b+c+'
278 (rangepre
279 (symbol '+a+b+c+'))
280 * set:
281 <spanset+ 0:4>
282 0
283 1
284 2
285 3
286 $ try -- '-a-b-c-:+a+b+c+'
287 (range
288 (symbol '-a-b-c-')
289 (symbol '+a+b+c+'))
290 * set:
291 <spanset- 3:5>
292 4
293 3
294 $ log '-a-b-c-:+a+b+c+'
295 4
296 3
297
298 $ try -- -a-b-c--a # complains
299 (minus
300 (minus
301 (minus
302 (negate
303 (symbol 'a'))
304 (symbol 'b'))
305 (symbol 'c'))
306 (negate
307 (symbol 'a')))
308 abort: unknown revision '-a'!
309 [255]
310 $ try Γ©
311 (symbol '\xc3\xa9')
312 * set:
313 <baseset [9]>
314 9
315
316 no quoting needed
317
318 $ log ::a-b-c-
319 0
320 1
321 2
322
323 quoting needed
324
325 $ try '"-a-b-c-"-a'
326 (minus
327 (string '-a-b-c-')
328 (symbol 'a'))
329 * set:
330 <filteredset
331 <baseset [4]>,
332 <not
333 <baseset [0]>>>
334 4
335
336 $ log '1 or 2'
337 1
338 2
339 $ log '1|2'
340 1
341 2
342 $ log '1 and 2'
343 $ log '1&2'
344 $ try '1&2|3' # precedence - and is higher
345 (or
346 (list
347 (and
348 (symbol '1')
349 (symbol '2'))
350 (symbol '3')))
351 * set:
352 <addset
353 <baseset []>,
354 <baseset [3]>>
355 3
356 $ try '1|2&3'
357 (or
358 (list
359 (symbol '1')
360 (and
361 (symbol '2')
362 (symbol '3'))))
363 * set:
364 <addset
365 <baseset [1]>,
366 <baseset []>>
367 1
368 $ try '1&2&3' # associativity
369 (and
370 (and
371 (symbol '1')
372 (symbol '2'))
373 (symbol '3'))
374 * set:
375 <baseset []>
376 $ try '1|(2|3)'
377 (or
378 (list
379 (symbol '1')
380 (group
381 (or
382 (list
383 (symbol '2')
384 (symbol '3'))))))
385 * set:
386 <addset
387 <baseset [1]>,
388 <baseset [2, 3]>>
389 1
390 2
391 3
392 $ log '1.0' # tag
393 6
394 $ log 'a' # branch
395 0
396 $ log '2785f51ee'
397 0
398 $ log 'date(2005)'
399 4
400 $ log 'date(this is a test)'
401 hg: parse error at 10: unexpected token: symbol
402 [255]
403 $ log 'date()'
404 hg: parse error: date requires a string
405 [255]
406 $ log 'date'
407 abort: unknown revision 'date'!
408 [255]
409 $ log 'date('
410 hg: parse error at 5: not a prefix: end
411 [255]
412 $ log 'date("\xy")'
413 hg: parse error: invalid \x escape
414 [255]
415 $ log 'date(tip)'
416 hg: parse error: invalid date: 'tip'
417 [255]
418 $ log '0:date'
419 abort: unknown revision 'date'!
420 [255]
421 $ log '::"date"'
422 abort: unknown revision 'date'!
423 [255]
424 $ hg book date -r 4
425 $ log '0:date'
426 0
427 1
428 2
429 3
430 4
431 $ log '::date'
432 0
433 1
434 2
435 4
436 $ log '::"date"'
437 0
438 1
439 2
440 4
441 $ log 'date(2005) and 1::'
442 4
443 $ hg book -d date
444
445 function name should be a symbol
446
447 $ log '"date"(2005)'
448 hg: parse error: not a symbol
449 [255]
450
451 keyword arguments
452
453 $ log 'extra(branch, value=a)'
454 0
455
456 $ log 'extra(branch, a, b)'
457 hg: parse error: extra takes at most 2 positional arguments
458 [255]
459 $ log 'extra(a, label=b)'
460 hg: parse error: extra got multiple values for keyword argument 'label'
461 [255]
462 $ log 'extra(label=branch, default)'
463 hg: parse error: extra got an invalid argument
464 [255]
465 $ log 'extra(branch, foo+bar=baz)'
466 hg: parse error: extra got an invalid argument
467 [255]
468 $ log 'extra(unknown=branch)'
469 hg: parse error: extra got an unexpected keyword argument 'unknown'
470 [255]
471
472 $ try 'foo=bar|baz'
473 (keyvalue
474 (symbol 'foo')
475 (or
476 (list
477 (symbol 'bar')
478 (symbol 'baz'))))
479 hg: parse error: can't use a key-value pair in this context
480 [255]
481
482 right-hand side should be optimized recursively
483
484 $ try --optimize 'foo=(not public())'
485 (keyvalue
486 (symbol 'foo')
487 (group
488 (not
489 (func
490 (symbol 'public')
491 None))))
492 * optimized:
493 (keyvalue
494 (symbol 'foo')
495 (func
496 (symbol '_notpublic')
497 None))
498 hg: parse error: can't use a key-value pair in this context
499 [255]
500
501 relation-subscript operator has the highest binding strength (as function call):
502
503 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
504 * parsed:
505 (range
506 (symbol 'tip')
507 (relsubscript
508 (parentpost
509 (symbol 'tip'))
510 (symbol 'generations')
511 (negate
512 (symbol '1'))))
513 9
514 8
515 7
516 6
517 5
518 4
519
520 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
521 * parsed:
522 (not
523 (relsubscript
524 (func
525 (symbol 'public')
526 None)
527 (symbol 'generations')
528 (symbol '0')))
529
530 left-hand side of relation-subscript operator should be optimized recursively:
531
532 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
533 > '(not public())#generations[0]'
534 * analyzed:
535 (relsubscript
536 (not
537 (func
538 (symbol 'public')
539 None))
540 (symbol 'generations')
541 (symbol '0'))
542 * optimized:
543 (relsubscript
544 (func
545 (symbol '_notpublic')
546 None)
547 (symbol 'generations')
548 (symbol '0'))
549
550 resolution of subscript and relation-subscript ternary operators:
551
552 $ hg debugrevspec -p analyzed 'tip[0]'
553 * analyzed:
554 (subscript
555 (symbol 'tip')
556 (symbol '0'))
557 hg: parse error: can't use a subscript in this context
558 [255]
559
560 $ hg debugrevspec -p analyzed 'tip#rel[0]'
561 * analyzed:
562 (relsubscript
563 (symbol 'tip')
564 (symbol 'rel')
565 (symbol '0'))
566 hg: parse error: unknown identifier: rel
567 [255]
568
569 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
570 * analyzed:
571 (subscript
572 (relation
573 (symbol 'tip')
574 (symbol 'rel'))
575 (symbol '0'))
576 hg: parse error: can't use a subscript in this context
577 [255]
578
579 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
580 * analyzed:
581 (subscript
582 (relsubscript
583 (symbol 'tip')
584 (symbol 'rel')
585 (symbol '0'))
586 (symbol '1'))
587 hg: parse error: can't use a subscript in this context
588 [255]
589
590 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
591 * analyzed:
592 (relsubscript
593 (relation
594 (symbol 'tip')
595 (symbol 'rel0'))
596 (symbol 'rel1')
597 (symbol '1'))
598 hg: parse error: unknown identifier: rel1
599 [255]
600
601 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
602 * analyzed:
603 (relsubscript
604 (relsubscript
605 (symbol 'tip')
606 (symbol 'rel0')
607 (symbol '0'))
608 (symbol 'rel1')
609 (symbol '1'))
610 hg: parse error: unknown identifier: rel1
611 [255]
612
613 parse errors of relation, subscript and relation-subscript operators:
614
615 $ hg debugrevspec '[0]'
616 hg: parse error at 0: not a prefix: [
617 [255]
618 $ hg debugrevspec '.#'
619 hg: parse error at 2: not a prefix: end
620 [255]
621 $ hg debugrevspec '#rel'
622 hg: parse error at 0: not a prefix: #
623 [255]
624 $ hg debugrevspec '.#rel[0'
625 hg: parse error at 7: unexpected token: end
626 [255]
627 $ hg debugrevspec '.]'
628 hg: parse error at 1: invalid token
629 [255]
630
631 $ hg debugrevspec '.#generations[a]'
632 hg: parse error: relation subscript must be an integer
633 [255]
634 $ hg debugrevspec '.#generations[1-2]'
635 hg: parse error: relation subscript must be an integer
636 [255]
637
638 parsed tree at stages:
639
640 $ hg debugrevspec -p all '()'
641 * parsed:
642 (group
643 None)
644 * expanded:
645 (group
646 None)
647 * concatenated:
648 (group
649 None)
650 * analyzed:
651 None
652 * optimized:
653 None
654 hg: parse error: missing argument
655 [255]
656
657 $ hg debugrevspec --no-optimized -p all '()'
658 * parsed:
659 (group
660 None)
661 * expanded:
662 (group
663 None)
664 * concatenated:
665 (group
666 None)
667 * analyzed:
668 None
669 hg: parse error: missing argument
670 [255]
671
672 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
673 * parsed:
674 (minus
675 (group
676 (or
677 (list
678 (symbol '0')
679 (symbol '1'))))
680 (symbol '1'))
681 * analyzed:
682 (and
683 (or
684 (list
685 (symbol '0')
686 (symbol '1')))
687 (not
688 (symbol '1')))
689 * optimized:
690 (difference
691 (func
692 (symbol '_list')
693 (string '0\x001'))
694 (symbol '1'))
695 0
696
697 $ hg debugrevspec -p unknown '0'
698 abort: invalid stage name: unknown
699 [255]
700
701 $ hg debugrevspec -p all --optimize '0'
702 abort: cannot use --optimize with --show-stage
703 [255]
704
705 verify optimized tree:
706
707 $ hg debugrevspec --verify '0|1'
708
709 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
710 * analyzed:
711 (and
712 (func
713 (symbol 'r3232')
714 None)
715 (symbol '2'))
716 * optimized:
717 (andsmally
718 (func
719 (symbol 'r3232')
720 None)
721 (symbol '2'))
722 * analyzed set:
723 <baseset [2]>
724 * optimized set:
725 <baseset [2, 2]>
726 --- analyzed
727 +++ optimized
728 2
729 +2
730 [1]
731
732 $ hg debugrevspec --no-optimized --verify-optimized '0'
733 abort: cannot use --verify-optimized with --no-optimized
734 [255]
735
736 Test that symbols only get parsed as functions if there's an opening
737 parenthesis.
738
739 $ hg book only -r 9
740 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
741 8
742 9
743
744 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
745 may be hidden (issue5385)
746
747 $ try -p parsed -p analyzed ':'
748 * parsed:
749 (rangeall
750 None)
751 * analyzed:
752 (rangeall
753 None)
754 * set:
755 <spanset+ 0:10>
756 0
757 1
758 2
759 3
760 4
761 5
762 6
763 7
764 8
765 9
766 $ try -p analyzed ':1'
767 * analyzed:
768 (rangepre
769 (symbol '1'))
770 * set:
771 <spanset+ 0:2>
772 0
773 1
774 $ try -p analyzed ':(1|2)'
775 * analyzed:
776 (rangepre
777 (or
778 (list
779 (symbol '1')
780 (symbol '2'))))
781 * set:
782 <spanset+ 0:3>
783 0
784 1
785 2
786 $ try -p analyzed ':(1&2)'
787 * analyzed:
788 (rangepre
789 (and
790 (symbol '1')
791 (symbol '2')))
792 * set:
793 <baseset []>
794
795 infix/suffix resolution of ^ operator (issue2884):
796
797 x^:y means (x^):y
798
799 $ try '1^:2'
800 (range
801 (parentpost
802 (symbol '1'))
803 (symbol '2'))
804 * set:
805 <spanset+ 0:3>
806 0
807 1
808 2
809
810 $ try '1^::2'
811 (dagrange
812 (parentpost
813 (symbol '1'))
814 (symbol '2'))
815 * set:
816 <baseset+ [0, 1, 2]>
817 0
818 1
819 2
820
821 $ try '9^:'
822 (rangepost
823 (parentpost
824 (symbol '9')))
825 * set:
826 <spanset+ 8:10>
827 8
828 9
829
830 x^:y should be resolved before omitting group operators
831
832 $ try '1^(:2)'
833 (parent
834 (symbol '1')
835 (group
836 (rangepre
837 (symbol '2'))))
838 hg: parse error: ^ expects a number 0, 1, or 2
839 [255]
840
841 x^:y should be resolved recursively
842
843 $ try 'sort(1^:2)'
844 (func
845 (symbol 'sort')
846 (range
847 (parentpost
848 (symbol '1'))
849 (symbol '2')))
850 * set:
851 <spanset+ 0:3>
852 0
853 1
854 2
855
856 $ try '(3^:4)^:2'
857 (range
858 (parentpost
859 (group
860 (range
861 (parentpost
862 (symbol '3'))
863 (symbol '4'))))
864 (symbol '2'))
865 * set:
866 <spanset+ 0:3>
867 0
868 1
869 2
870
871 $ try '(3^::4)^::2'
872 (dagrange
873 (parentpost
874 (group
875 (dagrange
876 (parentpost
877 (symbol '3'))
878 (symbol '4'))))
879 (symbol '2'))
880 * set:
881 <baseset+ [0, 1, 2]>
882 0
883 1
884 2
885
886 $ try '(9^:)^:'
887 (rangepost
888 (parentpost
889 (group
890 (rangepost
891 (parentpost
892 (symbol '9'))))))
893 * set:
894 <spanset+ 4:10>
895 4
896 5
897 6
898 7
899 8
900 9
901
902 x^ in alias should also be resolved
903
904 $ try 'A' --config 'revsetalias.A=1^:2'
905 (symbol 'A')
906 * expanded:
907 (range
908 (parentpost
909 (symbol '1'))
910 (symbol '2'))
911 * set:
912 <spanset+ 0:3>
913 0
914 1
915 2
916
917 $ try 'A:2' --config 'revsetalias.A=1^'
918 (range
919 (symbol 'A')
920 (symbol '2'))
921 * expanded:
922 (range
923 (parentpost
924 (symbol '1'))
925 (symbol '2'))
926 * set:
927 <spanset+ 0:3>
928 0
929 1
930 2
931
932 but not beyond the boundary of alias expansion, because the resolution should
933 be made at the parsing stage
934
935 $ try '1^A' --config 'revsetalias.A=:2'
936 (parent
937 (symbol '1')
938 (symbol 'A'))
939 * expanded:
940 (parent
941 (symbol '1')
942 (rangepre
943 (symbol '2')))
944 hg: parse error: ^ expects a number 0, 1, or 2
945 [255]
946
947 ancestor can accept 0 or more arguments
948
949 $ log 'ancestor()'
950 $ log 'ancestor(1)'
951 1
952 $ log 'ancestor(4,5)'
953 1
954 $ log 'ancestor(4,5) and 4'
955 $ log 'ancestor(0,0,1,3)'
956 0
957 $ log 'ancestor(3,1,5,3,5,1)'
958 1
959 $ log 'ancestor(0,1,3,5)'
960 0
961 $ log 'ancestor(1,2,3,4,5)'
962 1
963
964 test ancestors
965
966 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
967 @ 9
968 o 8
969 | o 7
970 | o 6
971 |/|
972 | o 5
973 o | 4
974 | o 3
975 o | 2
976 |/
977 o 1
978 o 0
979
980 $ log 'ancestors(5)'
981 0
982 1
983 3
984 5
985 $ log 'ancestor(ancestors(5))'
986 0
987 $ log '::r3232()'
988 0
989 1
990 2
991 3
992
993 test ancestors with depth limit
994
995 (depth=0 selects the node itself)
996
997 $ log 'reverse(ancestors(9, depth=0))'
998 9
999
1000 (interleaved: '4' would be missing if heap queue were higher depth first)
1001
1002 $ log 'reverse(ancestors(8:9, depth=1))'
1003 9
1004 8
1005 4
1006
1007 (interleaved: '2' would be missing if heap queue were higher depth first)
1008
1009 $ log 'reverse(ancestors(7+8, depth=2))'
1010 8
1011 7
1012 6
1013 5
1014 4
1015 2
1016
1017 (walk example above by separate queries)
1018
1019 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1020 8
1021 4
1022 2
1023 7
1024 6
1025 5
1026
1027 (walk 2nd and 3rd ancestors)
1028
1029 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1030 5
1031 4
1032 3
1033 2
1034
1035 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1036
1037 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1038 5
1039 4
1040 2
1041
1042 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1043 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1044 multiple depths)
1045
1046 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1047 5
1048 2
1049
1050 test bad arguments passed to ancestors()
1051
1052 $ log 'ancestors(., depth=-1)'
1053 hg: parse error: negative depth
1054 [255]
1055 $ log 'ancestors(., depth=foo)'
1056 hg: parse error: ancestors expects an integer depth
1057 [255]
1058
1059 test descendants
1060
1061 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1062 @ 9
1063 o 8
1064 | o 7
1065 | o 6
1066 |/|
1067 | o 5
1068 o | 4
1069 | o 3
1070 o | 2
1071 |/
1072 o 1
1073 o 0
1074
1075 (null is ultimate root and has optimized path)
1076
1077 $ log 'null:4 & descendants(null)'
1078 -1
1079 0
1080 1
1081 2
1082 3
1083 4
1084
1085 (including merge)
1086
1087 $ log ':8 & descendants(2)'
1088 2
1089 4
1090 6
1091 7
1092 8
1093
1094 (multiple roots)
1095
1096 $ log ':8 & descendants(2+5)'
1097 2
1098 4
1099 5
1100 6
1101 7
1102 8
1103
1104 test descendants with depth limit
1105
1106 (depth=0 selects the node itself)
1107
1108 $ log 'descendants(0, depth=0)'
1109 0
1110 $ log 'null: & descendants(null, depth=0)'
1111 -1
1112
1113 (p2 = null should be ignored)
1114
1115 $ log 'null: & descendants(null, depth=2)'
1116 -1
1117 0
1118 1
1119
1120 (multiple paths: depth(6) = (2, 3))
1121
1122 $ log 'descendants(1+3, depth=2)'
1123 1
1124 2
1125 3
1126 4
1127 5
1128 6
1129
1130 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1131
1132 $ log 'descendants(3+1, depth=2, startdepth=2)'
1133 4
1134 5
1135 6
1136
1137 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1138
1139 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1140 1
1141 2
1142 3
1143 4
1144 5
1145 6
1146 7
1147
1148 (multiple depths: depth(6) = (0, 4), no match)
1149
1150 $ log 'descendants(0+6, depth=3, startdepth=1)'
1151 1
1152 2
1153 3
1154 4
1155 5
1156 7
1157
1158 test ancestors/descendants relation subscript:
1159
1160 $ log 'tip#generations[0]'
1161 9
1162 $ log '.#generations[-1]'
1163 8
1164 $ log '.#g[(-1)]'
1165 8
1166
1167 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1168 * parsed:
1169 (relsubscript
1170 (func
1171 (symbol 'roots')
1172 (rangeall
1173 None))
1174 (symbol 'g')
1175 (symbol '2'))
1176 2
1177 3
1178
1179 test author
1180
1181 $ log 'author(bob)'
1182 2
1183 $ log 'author("re:bob|test")'
1184 0
1185 1
1186 2
1187 3
1188 4
1189 5
1190 6
1191 7
1192 8
1193 9
1194 $ log 'author(r"re:\S")'
1195 0
1196 1
1197 2
1198 3
1199 4
1200 5
1201 6
1202 7
1203 8
1204 9
1205 $ log 'branch(Γ©)'
1206 8
1207 9
1208 $ log 'branch(a)'
1209 0
1210 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1211 0 a
1212 2 a-b-c-
1213 3 +a+b+c+
1214 4 -a-b-c-
1215 5 !a/b/c/
1216 6 _a_b_c_
1217 7 .a.b.c.
1218 $ log 'children(ancestor(4,5))'
1219 2
1220 3
1221
1222 $ log 'children(4)'
1223 6
1224 8
1225 $ log 'children(null)'
1226 0
1227
1228 $ log 'closed()'
1229 $ log 'contains(a)'
1230 0
1231 1
1232 3
1233 5
1234 $ log 'contains("../repo/a")'
1235 0
1236 1
1237 3
1238 5
1239 $ log 'desc(B)'
1240 5
1241 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1242 5 5 bug
1243 6 6 issue619
1244 $ log 'descendants(2 or 3)'
1245 2
1246 3
1247 4
1248 5
1249 6
1250 7
1251 8
1252 9
1253 $ log 'file("b*")'
1254 1
1255 4
1256 $ log 'filelog("b")'
1257 1
1258 4
1259 $ log 'filelog("../repo/b")'
1260 1
1261 4
1262 $ log 'follow()'
1263 0
1264 1
1265 2
1266 4
1267 8
1268 9
1269 $ log 'grep("issue\d+")'
1270 6
1271 $ try 'grep("(")' # invalid regular expression
1272 (func
1273 (symbol 'grep')
1274 (string '('))
1275 hg: parse error: invalid match pattern: unbalanced parenthesis
1276 [255]
1277 $ try 'grep("\bissue\d+")'
1278 (func
1279 (symbol 'grep')
1280 (string '\x08issue\\d+'))
1281 * set:
1282 <filteredset
1283 <fullreposet+ 0:10>,
1284 <grep '\x08issue\\d+'>>
1285 $ try 'grep(r"\bissue\d+")'
1286 (func
1287 (symbol 'grep')
1288 (string '\\bissue\\d+'))
1289 * set:
1290 <filteredset
1291 <fullreposet+ 0:10>,
1292 <grep '\\bissue\\d+'>>
1293 6
1294 $ try 'grep(r"\")'
1295 hg: parse error at 7: unterminated string
1296 [255]
1297 $ log 'head()'
1298 0
1299 1
1300 2
1301 3
1302 4
1303 5
1304 6
1305 7
1306 9
1307 $ log 'heads(6::)'
1308 7
1309 $ log 'keyword(issue)'
1310 6
1311 $ log 'keyword("test a")'
1312
1313 Test first (=limit) and last
1314
1315 $ log 'limit(head(), 1)'
1316 0
1317 $ log 'limit(author("re:bob|test"), 3, 5)'
1318 5
1319 6
1320 7
1321 $ log 'limit(author("re:bob|test"), offset=6)'
1322 6
1323 $ log 'limit(author("re:bob|test"), offset=10)'
1324 $ log 'limit(all(), 1, -1)'
1325 hg: parse error: negative offset
1326 [255]
1327 $ log 'limit(all(), -1)'
1328 hg: parse error: negative number to select
1329 [255]
1330 $ log 'limit(all(), 0)'
1331
1332 $ log 'last(all(), -1)'
1333 hg: parse error: negative number to select
1334 [255]
1335 $ log 'last(all(), 0)'
1336 $ log 'last(all(), 1)'
1337 9
1338 $ log 'last(all(), 2)'
1339 8
1340 9
1341
1342 Test smartset.slice() by first/last()
1343
1344 (using unoptimized set, filteredset as example)
1345
1346 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1347 * set:
1348 <filteredset
1349 <spanset+ 0:8>,
1350 <branch 're:'>>
1351 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1352 4
1353 5
1354 6
1355 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1356 3
1357 2
1358 1
1359 $ log 'last(0:7 & branch("re:"), 2)'
1360 6
1361 7
1362
1363 (using baseset)
1364
1365 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1366 * set:
1367 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1368 $ hg debugrevspec --no-show-revs -s 0::7
1369 * set:
1370 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1371 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1372 4
1373 5
1374 6
1375 $ log 'limit(sort(0::7, rev), 3, 4)'
1376 4
1377 5
1378 6
1379 $ log 'limit(sort(0::7, -rev), 3, 4)'
1380 3
1381 2
1382 1
1383 $ log 'last(sort(0::7, rev), 2)'
1384 6
1385 7
1386 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1387 * set:
1388 <baseset+ [6, 7]>
1389 6
1390 7
1391 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1392 * set:
1393 <baseset+ []>
1394 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1395 * set:
1396 <baseset- [0, 1]>
1397 1
1398 0
1399 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1400 * set:
1401 <baseset- []>
1402 $ hg debugrevspec -s 'limit(0::7, 0)'
1403 * set:
1404 <baseset+ []>
1405
1406 (using spanset)
1407
1408 $ hg debugrevspec --no-show-revs -s 0:7
1409 * set:
1410 <spanset+ 0:8>
1411 $ log 'limit(0:7, 3, 4)'
1412 4
1413 5
1414 6
1415 $ log 'limit(7:0, 3, 4)'
1416 3
1417 2
1418 1
1419 $ log 'limit(0:7, 3, 6)'
1420 6
1421 7
1422 $ log 'limit(7:0, 3, 6)'
1423 1
1424 0
1425 $ log 'last(0:7, 2)'
1426 6
1427 7
1428 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1429 * set:
1430 <spanset+ 6:8>
1431 6
1432 7
1433 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1434 * set:
1435 <spanset+ 8:8>
1436 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1437 * set:
1438 <spanset- 0:2>
1439 1
1440 0
1441 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1442 * set:
1443 <spanset- 0:0>
1444 $ hg debugrevspec -s 'limit(0:7, 0)'
1445 * set:
1446 <spanset+ 0:0>
1447
1448 Test order of first/last revisions
1449
1450 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1451 * set:
1452 <filteredset
1453 <spanset- 2:5>,
1454 <spanset+ 3:10>>
1455 4
1456 3
1457
1458 $ hg debugrevspec -s '3: & first(4:0, 3)'
1459 * set:
1460 <filteredset
1461 <spanset+ 3:10>,
1462 <spanset- 2:5>>
1463 3
1464 4
1465
1466 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1467 * set:
1468 <filteredset
1469 <spanset- 0:3>,
1470 <spanset+ 0:2>>
1471 1
1472 0
1473
1474 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1475 * set:
1476 <filteredset
1477 <spanset+ 0:2>,
1478 <spanset+ 0:3>>
1479 0
1480 1
1481
1482 Test scmutil.revsingle() should return the last revision
1483
1484 $ hg debugrevspec -s 'last(0::)'
1485 * set:
1486 <baseset slice=0:1
1487 <generatorset->>
1488 9
1489 $ hg identify -r '0::' --num
1490 9
1491
1492 Test matching
1493
1494 $ log 'matching(6)'
1495 6
1496 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1497 6
1498 7
1499
1500 Testing min and max
1501
1502 max: simple
1503
1504 $ log 'max(contains(a))'
1505 5
1506
1507 max: simple on unordered set)
1508
1509 $ log 'max((4+0+2+5+7) and contains(a))'
1510 5
1511
1512 max: no result
1513
1514 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1515
1516 max: no result on unordered set
1517
1518 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1519
1520 min: simple
1521
1522 $ log 'min(contains(a))'
1523 0
1524
1525 min: simple on unordered set
1526
1527 $ log 'min((4+0+2+5+7) and contains(a))'
1528 0
1529
1530 min: empty
1531
1532 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1533
1534 min: empty on unordered set
1535
1536 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1537
1538
1539 $ log 'merge()'
1540 6
1541 $ log 'branchpoint()'
1542 1
1543 4
1544 $ log 'modifies(b)'
1545 4
1546 $ log 'modifies("path:b")'
1547 4
1548 $ log 'modifies("*")'
1549 4
1550 6
1551 $ log 'modifies("set:modified()")'
1552 4
1553 $ log 'id(5)'
1554 2
1555 $ log 'only(9)'
1556 8
1557 9
1558 $ log 'only(8)'
1559 8
1560 $ log 'only(9, 5)'
1561 2
1562 4
1563 8
1564 9
1565 $ log 'only(7 + 9, 5 + 2)'
1566 4
1567 6
1568 7
1569 8
1570 9
1571
1572 Test empty set input
1573 $ log 'only(p2())'
1574 $ log 'only(p1(), p2())'
1575 0
1576 1
1577 2
1578 4
1579 8
1580 9
1581
1582 Test '%' operator
1583
1584 $ log '9%'
1585 8
1586 9
1587 $ log '9%5'
1588 2
1589 4
1590 8
1591 9
1592 $ log '(7 + 9)%(5 + 2)'
1593 4
1594 6
1595 7
1596 8
1597 9
1598
1599 Test operand of '%' is optimized recursively (issue4670)
1600
1601 $ try --optimize '8:9-8%'
1602 (onlypost
1603 (minus
1604 (range
1605 (symbol '8')
1606 (symbol '9'))
1607 (symbol '8')))
1608 * optimized:
1609 (func
1610 (symbol 'only')
1611 (difference
1612 (range
1613 (symbol '8')
1614 (symbol '9'))
1615 (symbol '8')))
1616 * set:
1617 <baseset+ [8, 9]>
1618 8
1619 9
1620 $ try --optimize '(9)%(5)'
1621 (only
1622 (group
1623 (symbol '9'))
1624 (group
1625 (symbol '5')))
1626 * optimized:
1627 (func
1628 (symbol 'only')
1629 (list
1630 (symbol '9')
1631 (symbol '5')))
1632 * set:
1633 <baseset+ [2, 4, 8, 9]>
1634 2
1635 4
1636 8
1637 9
1638
1639 Test the order of operations
1640
1641 $ log '7 + 9%5 + 2'
1642 7
1643 2
1644 4
1645 8
1646 9
1647
1648 Test explicit numeric revision
1649 $ log 'rev(-2)'
1650 $ log 'rev(-1)'
1651 -1
1652 $ log 'rev(0)'
1653 0
1654 $ log 'rev(9)'
1655 9
1656 $ log 'rev(10)'
1657 $ log 'rev(tip)'
1658 hg: parse error: rev expects a number
1659 [255]
1660
1661 Test hexadecimal revision
1662 $ log 'id(2)'
1663 abort: 00changelog.i@2: ambiguous identifier!
1664 [255]
1665 $ log 'id(23268)'
1666 4
1667 $ log 'id(2785f51eece)'
1668 0
1669 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1670 8
1671 $ log 'id(d5d0dcbdc4a)'
1672 $ log 'id(d5d0dcbdc4w)'
1673 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1674 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1675 $ log 'id(1.0)'
1676 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1677
1678 Test null revision
1679 $ log '(null)'
1680 -1
1681 $ log '(null:0)'
1682 -1
1683 0
1684 $ log '(0:null)'
1685 0
1686 -1
1687 $ log 'null::0'
1688 -1
1689 0
1690 $ log 'null:tip - 0:'
1691 -1
1692 $ log 'null: and null::' | head -1
1693 -1
1694 $ log 'null: or 0:' | head -2
1695 -1
1696 0
1697 $ log 'ancestors(null)'
1698 -1
1699 $ log 'reverse(null:)' | tail -2
1700 0
1701 -1
1702 $ log 'first(null:)'
1703 -1
1704 $ log 'min(null:)'
1705 BROKEN: should be '-1'
1706 $ log 'tip:null and all()' | tail -2
1707 1
1708 0
1709
1710 Test working-directory revision
1711 $ hg debugrevspec 'wdir()'
1712 2147483647
1713 $ hg debugrevspec 'wdir()^'
1714 9
1715 $ hg up 7
1716 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1717 $ hg debugrevspec 'wdir()^'
1718 7
1719 $ hg debugrevspec 'wdir()^0'
1720 2147483647
1721 $ hg debugrevspec 'wdir()~3'
1722 5
1723 $ hg debugrevspec 'ancestors(wdir())'
1724 0
1725 1
1726 2
1727 3
1728 4
1729 5
1730 6
1731 7
1732 2147483647
1733 $ hg debugrevspec 'wdir()~0'
1734 2147483647
1735 $ hg debugrevspec 'p1(wdir())'
1736 7
1737 $ hg debugrevspec 'p2(wdir())'
1738 $ hg debugrevspec 'parents(wdir())'
1739 7
1740 $ hg debugrevspec 'wdir()^1'
1741 7
1742 $ hg debugrevspec 'wdir()^2'
1743 $ hg debugrevspec 'wdir()^3'
1744 hg: parse error: ^ expects a number 0, 1, or 2
1745 [255]
1746 For tests consistency
1747 $ hg up 9
1748 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1749 $ hg debugrevspec 'tip or wdir()'
1750 9
1751 2147483647
1752 $ hg debugrevspec '0:tip and wdir()'
1753 $ log '0:wdir()' | tail -3
1754 8
1755 9
1756 2147483647
1757 $ log 'wdir():0' | head -3
1758 2147483647
1759 9
1760 8
1761 $ log 'wdir():wdir()'
1762 2147483647
1763 $ log '(all() + wdir()) & min(. + wdir())'
1764 9
1765 $ log '(all() + wdir()) & max(. + wdir())'
1766 2147483647
1767 $ log 'first(wdir() + .)'
1768 2147483647
1769 $ log 'last(. + wdir())'
1770 2147483647
1771
1772 Test working-directory integer revision and node id
1773 (BUG: '0:wdir()' is still needed to populate wdir revision)
1774
1775 $ hg debugrevspec '0:wdir() & 2147483647'
1776 2147483647
1777 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1778 2147483647
1779 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1780 2147483647
1781 $ hg debugrevspec '0:wdir() & ffffffffffff'
1782 2147483647
1783 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1784 2147483647
1785 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1786 2147483647
1787
1788 $ cd ..
1789
1790 Test short 'ff...' hash collision
1791 (BUG: '0:wdir()' is still needed to populate wdir revision)
1792
1793 $ hg init wdir-hashcollision
1794 $ cd wdir-hashcollision
1795 $ cat <<EOF >> .hg/hgrc
1796 > [experimental]
1797 > stabilization = createmarkers
1798 > EOF
1799 $ echo 0 > a
1800 $ hg ci -qAm 0
1801 $ for i in 2463 2961 6726 78127; do
1802 > hg up -q 0
1803 > echo $i > a
1804 > hg ci -qm $i
1805 > done
1806 $ hg up -q null
1807 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1808 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1809 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1810 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1811 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1812 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1813 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
1814 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
1815 obsoleted 1 changesets
1816
1817 $ hg debugrevspec '0:wdir() & fff'
1818 abort: 00changelog.i@fff: ambiguous identifier!
1819 [255]
1820 $ hg debugrevspec '0:wdir() & ffff'
1821 abort: 00changelog.i@ffff: ambiguous identifier!
1822 [255]
1823 $ hg debugrevspec '0:wdir() & fffb'
1824 abort: 00changelog.i@fffb: ambiguous identifier!
1825 [255]
1826 BROKEN should be '2' (node lookup uses unfiltered repo since dc25ed84bee8)
1827 $ hg debugrevspec '0:wdir() & id(fffb)'
1828 2
1829 $ hg debugrevspec '0:wdir() & ffff8'
1830 4
1831 $ hg debugrevspec '0:wdir() & fffff'
1832 2147483647
1833
1834 $ cd ..
1835
1836 Test branch() with wdir()
1837
1838 $ cd repo
1839
1840 $ log '0:wdir() & branch("literal:Γ©")'
1841 8
1842 9
1843 2147483647
1844 $ log '0:wdir() & branch("re:Γ©")'
1845 8
1846 9
1847 2147483647
1848 $ log '0:wdir() & branch("re:^a")'
1849 0
1850 2
1851 $ log '0:wdir() & branch(8)'
1852 8
1853 9
1854 2147483647
1855
1856 branch(wdir()) returns all revisions belonging to the working branch. The wdir
1857 itself isn't returned unless it is explicitly populated.
1858
1859 $ log 'branch(wdir())'
1860 8
1861 9
1862 $ log '0:wdir() & branch(wdir())'
1863 8
1864 9
1865 2147483647
1866
1867 $ log 'outgoing()'
1868 8
1869 9
1870 $ log 'outgoing("../remote1")'
1871 8
1872 9
1873 $ log 'outgoing("../remote2")'
1874 3
1875 5
1876 6
1877 7
1878 9
1879 $ log 'p1(merge())'
1880 5
1881 $ log 'p2(merge())'
1882 4
1883 $ log 'parents(merge())'
1884 4
1885 5
1886 $ log 'p1(branchpoint())'
1887 0
1888 2
1889 $ log 'p2(branchpoint())'
1890 $ log 'parents(branchpoint())'
1891 0
1892 2
1893 $ log 'removes(a)'
1894 2
1895 6
1896 $ log 'roots(all())'
1897 0
1898 $ log 'reverse(2 or 3 or 4 or 5)'
1899 5
1900 4
1901 3
1902 2
1903 $ log 'reverse(all())'
1904 9
1905 8
1906 7
1907 6
1908 5
1909 4
1910 3
1911 2
1912 1
1913 0
1914 $ log 'reverse(all()) & filelog(b)'
1915 4
1916 1
1917 $ log 'rev(5)'
1918 5
1919 $ log 'sort(limit(reverse(all()), 3))'
1920 7
1921 8
1922 9
1923 $ log 'sort(2 or 3 or 4 or 5, date)'
1924 2
1925 3
1926 5
1927 4
1928 $ log 'tagged()'
1929 6
1930 $ log 'tag()'
1931 6
1932 $ log 'tag(1.0)'
1933 6
1934 $ log 'tag(tip)'
1935 9
1936
1937 Test order of revisions in compound expression
1938 ----------------------------------------------
1939
1940 The general rule is that only the outermost (= leftmost) predicate can
1941 enforce its ordering requirement. The other predicates should take the
1942 ordering defined by it.
1943
1944 'A & B' should follow the order of 'A':
1945
1946 $ log '2:0 & 0::2'
1947 2
1948 1
1949 0
1950
1951 'head()' combines sets in right order:
1952
1953 $ log '2:0 & head()'
1954 2
1955 1
1956 0
1957
1958 'x:y' takes ordering parameter into account:
1959
1960 $ try -p optimized '3:0 & 0:3 & not 2:1'
1961 * optimized:
1962 (difference
1963 (and
1964 (range
1965 (symbol '3')
1966 (symbol '0'))
1967 (range
1968 (symbol '0')
1969 (symbol '3')))
1970 (range
1971 (symbol '2')
1972 (symbol '1')))
1973 * set:
1974 <filteredset
1975 <filteredset
1976 <spanset- 0:4>,
1977 <spanset+ 0:4>>,
1978 <not
1979 <spanset+ 1:3>>>
1980 3
1981 0
1982
1983 'a + b', which is optimized to '_list(a b)', should take the ordering of
1984 the left expression:
1985
1986 $ try --optimize '2:0 & (0 + 1 + 2)'
1987 (and
1988 (range
1989 (symbol '2')
1990 (symbol '0'))
1991 (group
1992 (or
1993 (list
1994 (symbol '0')
1995 (symbol '1')
1996 (symbol '2')))))
1997 * optimized:
1998 (and
1999 (range
2000 (symbol '2')
2001 (symbol '0'))
2002 (func
2003 (symbol '_list')
2004 (string '0\x001\x002')))
2005 * set:
2006 <filteredset
2007 <spanset- 0:3>,
2008 <baseset [0, 1, 2]>>
2009 2
2010 1
2011 0
2012
2013 'A + B' should take the ordering of the left expression:
2014
2015 $ try --optimize '2:0 & (0:1 + 2)'
2016 (and
2017 (range
2018 (symbol '2')
2019 (symbol '0'))
2020 (group
2021 (or
2022 (list
2023 (range
2024 (symbol '0')
2025 (symbol '1'))
2026 (symbol '2')))))
2027 * optimized:
2028 (and
2029 (range
2030 (symbol '2')
2031 (symbol '0'))
2032 (or
2033 (list
2034 (range
2035 (symbol '0')
2036 (symbol '1'))
2037 (symbol '2'))))
2038 * set:
2039 <filteredset
2040 <spanset- 0:3>,
2041 <addset
2042 <spanset+ 0:2>,
2043 <baseset [2]>>>
2044 2
2045 1
2046 0
2047
2048 '_intlist(a b)' should behave like 'a + b':
2049
2050 $ trylist --optimize '2:0 & %ld' 0 1 2
2051 (and
2052 (range
2053 (symbol '2')
2054 (symbol '0'))
2055 (func
2056 (symbol '_intlist')
2057 (string '0\x001\x002')))
2058 * optimized:
2059 (andsmally
2060 (range
2061 (symbol '2')
2062 (symbol '0'))
2063 (func
2064 (symbol '_intlist')
2065 (string '0\x001\x002')))
2066 * set:
2067 <filteredset
2068 <spanset- 0:3>,
2069 <baseset+ [0, 1, 2]>>
2070 2
2071 1
2072 0
2073
2074 $ trylist --optimize '%ld & 2:0' 0 2 1
2075 (and
2076 (func
2077 (symbol '_intlist')
2078 (string '0\x002\x001'))
2079 (range
2080 (symbol '2')
2081 (symbol '0')))
2082 * optimized:
2083 (and
2084 (func
2085 (symbol '_intlist')
2086 (string '0\x002\x001'))
2087 (range
2088 (symbol '2')
2089 (symbol '0')))
2090 * set:
2091 <filteredset
2092 <baseset [0, 2, 1]>,
2093 <spanset- 0:3>>
2094 0
2095 2
2096 1
2097
2098 '_hexlist(a b)' should behave like 'a + b':
2099
2100 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2101 (and
2102 (range
2103 (symbol '2')
2104 (symbol '0'))
2105 (func
2106 (symbol '_hexlist')
2107 (string '*'))) (glob)
2108 * optimized:
2109 (and
2110 (range
2111 (symbol '2')
2112 (symbol '0'))
2113 (func
2114 (symbol '_hexlist')
2115 (string '*'))) (glob)
2116 * set:
2117 <filteredset
2118 <spanset- 0:3>,
2119 <baseset [0, 1, 2]>>
2120 2
2121 1
2122 0
2123
2124 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2125 (and
2126 (func
2127 (symbol '_hexlist')
2128 (string '*')) (glob)
2129 (range
2130 (symbol '2')
2131 (symbol '0')))
2132 * optimized:
2133 (andsmally
2134 (func
2135 (symbol '_hexlist')
2136 (string '*')) (glob)
2137 (range
2138 (symbol '2')
2139 (symbol '0')))
2140 * set:
2141 <baseset [0, 2, 1]>
2142 0
2143 2
2144 1
2145
2146 '_list' should not go through the slow follow-order path if order doesn't
2147 matter:
2148
2149 $ try -p optimized '2:0 & not (0 + 1)'
2150 * optimized:
2151 (difference
2152 (range
2153 (symbol '2')
2154 (symbol '0'))
2155 (func
2156 (symbol '_list')
2157 (string '0\x001')))
2158 * set:
2159 <filteredset
2160 <spanset- 0:3>,
2161 <not
2162 <baseset [0, 1]>>>
2163 2
2164
2165 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2166 * optimized:
2167 (difference
2168 (range
2169 (symbol '2')
2170 (symbol '0'))
2171 (and
2172 (range
2173 (symbol '0')
2174 (symbol '2'))
2175 (func
2176 (symbol '_list')
2177 (string '0\x001'))))
2178 * set:
2179 <filteredset
2180 <spanset- 0:3>,
2181 <not
2182 <baseset [0, 1]>>>
2183 2
2184
2185 because 'present()' does nothing other than suppressing an error, the
2186 ordering requirement should be forwarded to the nested expression
2187
2188 $ try -p optimized 'present(2 + 0 + 1)'
2189 * optimized:
2190 (func
2191 (symbol 'present')
2192 (func
2193 (symbol '_list')
2194 (string '2\x000\x001')))
2195 * set:
2196 <baseset [2, 0, 1]>
2197 2
2198 0
2199 1
2200
2201 $ try --optimize '2:0 & present(0 + 1 + 2)'
2202 (and
2203 (range
2204 (symbol '2')
2205 (symbol '0'))
2206 (func
2207 (symbol 'present')
2208 (or
2209 (list
2210 (symbol '0')
2211 (symbol '1')
2212 (symbol '2')))))
2213 * optimized:
2214 (and
2215 (range
2216 (symbol '2')
2217 (symbol '0'))
2218 (func
2219 (symbol 'present')
2220 (func
2221 (symbol '_list')
2222 (string '0\x001\x002'))))
2223 * set:
2224 <filteredset
2225 <spanset- 0:3>,
2226 <baseset [0, 1, 2]>>
2227 2
2228 1
2229 0
2230
2231 'reverse()' should take effect only if it is the outermost expression:
2232
2233 $ try --optimize '0:2 & reverse(all())'
2234 (and
2235 (range
2236 (symbol '0')
2237 (symbol '2'))
2238 (func
2239 (symbol 'reverse')
2240 (func
2241 (symbol 'all')
2242 None)))
2243 * optimized:
2244 (and
2245 (range
2246 (symbol '0')
2247 (symbol '2'))
2248 (func
2249 (symbol 'reverse')
2250 (func
2251 (symbol 'all')
2252 None)))
2253 * set:
2254 <filteredset
2255 <spanset+ 0:3>,
2256 <spanset+ 0:10>>
2257 0
2258 1
2259 2
2260
2261 'sort()' should take effect only if it is the outermost expression:
2262
2263 $ try --optimize '0:2 & sort(all(), -rev)'
2264 (and
2265 (range
2266 (symbol '0')
2267 (symbol '2'))
2268 (func
2269 (symbol 'sort')
2270 (list
2271 (func
2272 (symbol 'all')
2273 None)
2274 (negate
2275 (symbol 'rev')))))
2276 * optimized:
2277 (and
2278 (range
2279 (symbol '0')
2280 (symbol '2'))
2281 (func
2282 (symbol 'sort')
2283 (list
2284 (func
2285 (symbol 'all')
2286 None)
2287 (string '-rev'))))
2288 * set:
2289 <filteredset
2290 <spanset+ 0:3>,
2291 <spanset+ 0:10>>
2292 0
2293 1
2294 2
2295
2296 invalid argument passed to noop sort():
2297
2298 $ log '0:2 & sort()'
2299 hg: parse error: sort requires one or two arguments
2300 [255]
2301 $ log '0:2 & sort(all(), -invalid)'
2302 hg: parse error: unknown sort key '-invalid'
2303 [255]
2304
2305 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2306
2307 $ try --optimize '2:0 & first(1 + 0 + 2)'
2308 (and
2309 (range
2310 (symbol '2')
2311 (symbol '0'))
2312 (func
2313 (symbol 'first')
2314 (or
2315 (list
2316 (symbol '1')
2317 (symbol '0')
2318 (symbol '2')))))
2319 * optimized:
2320 (and
2321 (range
2322 (symbol '2')
2323 (symbol '0'))
2324 (func
2325 (symbol 'first')
2326 (func
2327 (symbol '_list')
2328 (string '1\x000\x002'))))
2329 * set:
2330 <filteredset
2331 <baseset [1]>,
2332 <spanset- 0:3>>
2333 1
2334
2335 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2336 (and
2337 (range
2338 (symbol '2')
2339 (symbol '0'))
2340 (not
2341 (func
2342 (symbol 'last')
2343 (or
2344 (list
2345 (symbol '0')
2346 (symbol '2')
2347 (symbol '1'))))))
2348 * optimized:
2349 (difference
2350 (range
2351 (symbol '2')
2352 (symbol '0'))
2353 (func
2354 (symbol 'last')
2355 (func
2356 (symbol '_list')
2357 (string '0\x002\x001'))))
2358 * set:
2359 <filteredset
2360 <spanset- 0:3>,
2361 <not
2362 <baseset [1]>>>
2363 2
2364 0
2365
2366 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2367
2368 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2369 (and
2370 (range
2371 (symbol '2')
2372 (symbol '0'))
2373 (range
2374 (group
2375 (or
2376 (list
2377 (symbol '1')
2378 (symbol '0')
2379 (symbol '2'))))
2380 (group
2381 (or
2382 (list
2383 (symbol '0')
2384 (symbol '2')
2385 (symbol '1'))))))
2386 * optimized:
2387 (and
2388 (range
2389 (symbol '2')
2390 (symbol '0'))
2391 (range
2392 (func
2393 (symbol '_list')
2394 (string '1\x000\x002'))
2395 (func
2396 (symbol '_list')
2397 (string '0\x002\x001'))))
2398 * set:
2399 <filteredset
2400 <spanset- 0:3>,
2401 <baseset [1]>>
2402 1
2403
2404 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2405
2406 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2407 (and
2408 (func
2409 (symbol 'contains')
2410 (string 'glob:*'))
2411 (group
2412 (or
2413 (list
2414 (symbol '2')
2415 (symbol '0')
2416 (symbol '1')))))
2417 * optimized:
2418 (andsmally
2419 (func
2420 (symbol 'contains')
2421 (string 'glob:*'))
2422 (func
2423 (symbol '_list')
2424 (string '2\x000\x001')))
2425 * set:
2426 <filteredset
2427 <baseset+ [0, 1, 2]>,
2428 <contains 'glob:*'>>
2429 0
2430 1
2431 2
2432
2433 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2434 the order appropriately:
2435
2436 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2437 (and
2438 (func
2439 (symbol 'reverse')
2440 (func
2441 (symbol 'contains')
2442 (string 'glob:*')))
2443 (group
2444 (or
2445 (list
2446 (symbol '0')
2447 (symbol '2')
2448 (symbol '1')))))
2449 * optimized:
2450 (andsmally
2451 (func
2452 (symbol 'reverse')
2453 (func
2454 (symbol 'contains')
2455 (string 'glob:*')))
2456 (func
2457 (symbol '_list')
2458 (string '0\x002\x001')))
2459 * set:
2460 <filteredset
2461 <baseset- [0, 1, 2]>,
2462 <contains 'glob:*'>>
2463 2
2464 1
2465 0
2466
2467 test sort revset
2468 --------------------------------------------
2469
2470 test when adding two unordered revsets
2471
2472 $ log 'sort(keyword(issue) or modifies(b))'
2473 4
2474 6
2475
2476 test when sorting a reversed collection in the same way it is
2477
2478 $ log 'sort(reverse(all()), -rev)'
2479 9
2480 8
2481 7
2482 6
2483 5
2484 4
2485 3
2486 2
2487 1
2488 0
2489
2490 test when sorting a reversed collection
2491
2492 $ log 'sort(reverse(all()), rev)'
2493 0
2494 1
2495 2
2496 3
2497 4
2498 5
2499 6
2500 7
2501 8
2502 9
2503
2504
2505 test sorting two sorted collections in different orders
2506
2507 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2508 2
2509 6
2510 8
2511 9
2512
2513 test sorting two sorted collections in different orders backwards
2514
2515 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2516 9
2517 8
2518 6
2519 2
2520
2521 test empty sort key which is noop
2522
2523 $ log 'sort(0 + 2 + 1, "")'
2524 0
2525 2
2526 1
2527
2528 test invalid sort keys
2529
2530 $ log 'sort(all(), -invalid)'
2531 hg: parse error: unknown sort key '-invalid'
2532 [255]
2533
2534 $ cd ..
2535
2536 test sorting by multiple keys including variable-length strings
2537
2538 $ hg init sorting
2539 $ cd sorting
2540 $ cat <<EOF >> .hg/hgrc
2541 > [ui]
2542 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2543 > [templatealias]
2544 > p5(s) = pad(s, 5)
2545 > EOF
2546 $ hg branch -qf b12
2547 $ hg ci -m m111 -u u112 -d '111 10800'
2548 $ hg branch -qf b11
2549 $ hg ci -m m12 -u u111 -d '112 7200'
2550 $ hg branch -qf b111
2551 $ hg ci -m m11 -u u12 -d '111 3600'
2552 $ hg branch -qf b112
2553 $ hg ci -m m111 -u u11 -d '120 0'
2554 $ hg branch -qf b111
2555 $ hg ci -m m112 -u u111 -d '110 14400'
2556 created new head
2557
2558 compare revisions (has fast path):
2559
2560 $ hg log -r 'sort(all(), rev)'
2561 0 b12 m111 u112 111 10800
2562 1 b11 m12 u111 112 7200
2563 2 b111 m11 u12 111 3600
2564 3 b112 m111 u11 120 0
2565 4 b111 m112 u111 110 14400
2566
2567 $ hg log -r 'sort(all(), -rev)'
2568 4 b111 m112 u111 110 14400
2569 3 b112 m111 u11 120 0
2570 2 b111 m11 u12 111 3600
2571 1 b11 m12 u111 112 7200
2572 0 b12 m111 u112 111 10800
2573
2574 compare variable-length strings (issue5218):
2575
2576 $ hg log -r 'sort(all(), branch)'
2577 1 b11 m12 u111 112 7200
2578 2 b111 m11 u12 111 3600
2579 4 b111 m112 u111 110 14400
2580 3 b112 m111 u11 120 0
2581 0 b12 m111 u112 111 10800
2582
2583 $ hg log -r 'sort(all(), -branch)'
2584 0 b12 m111 u112 111 10800
2585 3 b112 m111 u11 120 0
2586 2 b111 m11 u12 111 3600
2587 4 b111 m112 u111 110 14400
2588 1 b11 m12 u111 112 7200
2589
2590 $ hg log -r 'sort(all(), desc)'
2591 2 b111 m11 u12 111 3600
2592 0 b12 m111 u112 111 10800
2593 3 b112 m111 u11 120 0
2594 4 b111 m112 u111 110 14400
2595 1 b11 m12 u111 112 7200
2596
2597 $ hg log -r 'sort(all(), -desc)'
2598 1 b11 m12 u111 112 7200
2599 4 b111 m112 u111 110 14400
2600 0 b12 m111 u112 111 10800
2601 3 b112 m111 u11 120 0
2602 2 b111 m11 u12 111 3600
2603
2604 $ hg log -r 'sort(all(), user)'
2605 3 b112 m111 u11 120 0
2606 1 b11 m12 u111 112 7200
2607 4 b111 m112 u111 110 14400
2608 0 b12 m111 u112 111 10800
2609 2 b111 m11 u12 111 3600
2610
2611 $ hg log -r 'sort(all(), -user)'
2612 2 b111 m11 u12 111 3600
2613 0 b12 m111 u112 111 10800
2614 1 b11 m12 u111 112 7200
2615 4 b111 m112 u111 110 14400
2616 3 b112 m111 u11 120 0
2617
2618 compare dates (tz offset should have no effect):
2619
2620 $ hg log -r 'sort(all(), date)'
2621 4 b111 m112 u111 110 14400
2622 0 b12 m111 u112 111 10800
2623 2 b111 m11 u12 111 3600
2624 1 b11 m12 u111 112 7200
2625 3 b112 m111 u11 120 0
2626
2627 $ hg log -r 'sort(all(), -date)'
2628 3 b112 m111 u11 120 0
2629 1 b11 m12 u111 112 7200
2630 0 b12 m111 u112 111 10800
2631 2 b111 m11 u12 111 3600
2632 4 b111 m112 u111 110 14400
2633
2634 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2635 because '-k' reverses the comparison, not the list itself:
2636
2637 $ hg log -r 'sort(0 + 2, date)'
2638 0 b12 m111 u112 111 10800
2639 2 b111 m11 u12 111 3600
2640
2641 $ hg log -r 'sort(0 + 2, -date)'
2642 0 b12 m111 u112 111 10800
2643 2 b111 m11 u12 111 3600
2644
2645 $ hg log -r 'reverse(sort(0 + 2, date))'
2646 2 b111 m11 u12 111 3600
2647 0 b12 m111 u112 111 10800
2648
2649 sort by multiple keys:
2650
2651 $ hg log -r 'sort(all(), "branch -rev")'
2652 1 b11 m12 u111 112 7200
2653 4 b111 m112 u111 110 14400
2654 2 b111 m11 u12 111 3600
2655 3 b112 m111 u11 120 0
2656 0 b12 m111 u112 111 10800
2657
2658 $ hg log -r 'sort(all(), "-desc -date")'
2659 1 b11 m12 u111 112 7200
2660 4 b111 m112 u111 110 14400
2661 3 b112 m111 u11 120 0
2662 0 b12 m111 u112 111 10800
2663 2 b111 m11 u12 111 3600
2664
2665 $ hg log -r 'sort(all(), "user -branch date rev")'
2666 3 b112 m111 u11 120 0
2667 4 b111 m112 u111 110 14400
2668 1 b11 m12 u111 112 7200
2669 0 b12 m111 u112 111 10800
2670 2 b111 m11 u12 111 3600
2671
2672 toposort prioritises graph branches
2673
2674 $ hg up 2
2675 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2676 $ touch a
2677 $ hg addremove
2678 adding a
2679 $ hg ci -m 't1' -u 'tu' -d '130 0'
2680 created new head
2681 $ echo 'a' >> a
2682 $ hg ci -m 't2' -u 'tu' -d '130 0'
2683 $ hg book book1
2684 $ hg up 4
2685 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2686 (leaving bookmark book1)
2687 $ touch a
2688 $ hg addremove
2689 adding a
2690 $ hg ci -m 't3' -u 'tu' -d '130 0'
2691
2692 $ hg log -r 'sort(all(), topo)'
2693 7 b111 t3 tu 130 0
2694 4 b111 m112 u111 110 14400
2695 3 b112 m111 u11 120 0
2696 6 b111 t2 tu 130 0
2697 5 b111 t1 tu 130 0
2698 2 b111 m11 u12 111 3600
2699 1 b11 m12 u111 112 7200
2700 0 b12 m111 u112 111 10800
2701
2702 $ hg log -r 'sort(all(), -topo)'
2703 0 b12 m111 u112 111 10800
2704 1 b11 m12 u111 112 7200
2705 2 b111 m11 u12 111 3600
2706 5 b111 t1 tu 130 0
2707 6 b111 t2 tu 130 0
2708 3 b112 m111 u11 120 0
2709 4 b111 m112 u111 110 14400
2710 7 b111 t3 tu 130 0
2711
2712 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2713 6 b111 t2 tu 130 0
2714 5 b111 t1 tu 130 0
2715 7 b111 t3 tu 130 0
2716 4 b111 m112 u111 110 14400
2717 3 b112 m111 u11 120 0
2718 2 b111 m11 u12 111 3600
2719 1 b11 m12 u111 112 7200
2720 0 b12 m111 u112 111 10800
2721
2722 topographical sorting can't be combined with other sort keys, and you can't
2723 use the topo.firstbranch option when topo sort is not active:
2724
2725 $ hg log -r 'sort(all(), "topo user")'
2726 hg: parse error: topo sort order cannot be combined with other sort keys
2727 [255]
2728
2729 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2730 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2731 [255]
2732
2733 topo.firstbranch should accept any kind of expressions:
2734
2735 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2736 0 b12 m111 u112 111 10800
2737
2738 $ cd ..
2739 $ cd repo
2740
2741 92 test subtracting something from an addset
2742 93
2743 94 $ log '(outgoing() or removes(a)) - removes(a)'
2744 95 8
2745 96 9
2746 97
2747 98 test intersecting something with an addset
2748 99
2749 100 $ log 'parents(outgoing() or removes(a))'
2750 101 1
2751 102 4
2752 103 5
2753 104 8
2754 105
2755 106 test that `or` operation combines elements in the right order:
2756 107
2757 108 $ log '3:4 or 2:5'
2758 109 3
2759 110 4
2760 111 2
2761 112 5
2762 113 $ log '3:4 or 5:2'
2763 114 3
2764 115 4
2765 116 5
2766 117 2
2767 118 $ log 'sort(3:4 or 2:5)'
2768 119 2
2769 120 3
2770 121 4
2771 122 5
2772 123 $ log 'sort(3:4 or 5:2)'
2773 124 2
2774 125 3
2775 126 4
2776 127 5
2777 128
2778 129 test that more than one `-r`s are combined in the right order and deduplicated:
2779 130
2780 131 $ hg log -T '{rev}\n' -r 3 -r 3 -r 4 -r 5:2 -r 'ancestors(4)'
2781 132 3
2782 133 4
2783 134 5
2784 135 2
2785 136 0
2786 137 1
2787 138
2788 139 test that `or` operation skips duplicated revisions from right-hand side
2789 140
2790 141 $ try 'reverse(1::5) or ancestors(4)'
2791 142 (or
2792 143 (list
2793 144 (func
2794 145 (symbol 'reverse')
2795 146 (dagrange
2796 147 (symbol '1')
2797 148 (symbol '5')))
2798 149 (func
2799 150 (symbol 'ancestors')
2800 151 (symbol '4'))))
2801 152 * set:
2802 153 <addset
2803 154 <baseset- [1, 3, 5]>,
2804 155 <generatorset+>>
2805 156 5
2806 157 3
2807 158 1
2808 159 0
2809 160 2
2810 161 4
2811 162 $ try 'sort(ancestors(4) or reverse(1::5))'
2812 163 (func
2813 164 (symbol 'sort')
2814 165 (or
2815 166 (list
2816 167 (func
2817 168 (symbol 'ancestors')
2818 169 (symbol '4'))
2819 170 (func
2820 171 (symbol 'reverse')
2821 172 (dagrange
2822 173 (symbol '1')
2823 174 (symbol '5'))))))
2824 175 * set:
2825 176 <addset+
2826 177 <generatorset+>,
2827 178 <baseset- [1, 3, 5]>>
2828 179 0
2829 180 1
2830 181 2
2831 182 3
2832 183 4
2833 184 5
2834 185
2835 186 test optimization of trivial `or` operation
2836 187
2837 188 $ try --optimize '0|(1)|"2"|-2|tip|null'
2838 189 (or
2839 190 (list
2840 191 (symbol '0')
2841 192 (group
2842 193 (symbol '1'))
2843 194 (string '2')
2844 195 (negate
2845 196 (symbol '2'))
2846 197 (symbol 'tip')
2847 198 (symbol 'null')))
2848 199 * optimized:
2849 200 (func
2850 201 (symbol '_list')
2851 202 (string '0\x001\x002\x00-2\x00tip\x00null'))
2852 203 * set:
2853 204 <baseset [0, 1, 2, 8, 9, -1]>
2854 205 0
2855 206 1
2856 207 2
2857 208 8
2858 209 9
2859 210 -1
2860 211
2861 212 $ try --optimize '0|1|2:3'
2862 213 (or
2863 214 (list
2864 215 (symbol '0')
2865 216 (symbol '1')
2866 217 (range
2867 218 (symbol '2')
2868 219 (symbol '3'))))
2869 220 * optimized:
2870 221 (or
2871 222 (list
2872 223 (func
2873 224 (symbol '_list')
2874 225 (string '0\x001'))
2875 226 (range
2876 227 (symbol '2')
2877 228 (symbol '3'))))
2878 229 * set:
2879 230 <addset
2880 231 <baseset [0, 1]>,
2881 232 <spanset+ 2:4>>
2882 233 0
2883 234 1
2884 235 2
2885 236 3
2886 237
2887 238 $ try --optimize '0:1|2|3:4|5|6'
2888 239 (or
2889 240 (list
2890 241 (range
2891 242 (symbol '0')
2892 243 (symbol '1'))
2893 244 (symbol '2')
2894 245 (range
2895 246 (symbol '3')
2896 247 (symbol '4'))
2897 248 (symbol '5')
2898 249 (symbol '6')))
2899 250 * optimized:
2900 251 (or
2901 252 (list
2902 253 (range
2903 254 (symbol '0')
2904 255 (symbol '1'))
2905 256 (symbol '2')
2906 257 (range
2907 258 (symbol '3')
2908 259 (symbol '4'))
2909 260 (func
2910 261 (symbol '_list')
2911 262 (string '5\x006'))))
2912 263 * set:
2913 264 <addset
2914 265 <addset
2915 266 <spanset+ 0:2>,
2916 267 <baseset [2]>>,
2917 268 <addset
2918 269 <spanset+ 3:5>,
2919 270 <baseset [5, 6]>>>
2920 271 0
2921 272 1
2922 273 2
2923 274 3
2924 275 4
2925 276 5
2926 277 6
2927 278
2928 279 unoptimized `or` looks like this
2929 280
2930 281 $ try --no-optimized -p analyzed '0|1|2|3|4'
2931 282 * analyzed:
2932 283 (or
2933 284 (list
2934 285 (symbol '0')
2935 286 (symbol '1')
2936 287 (symbol '2')
2937 288 (symbol '3')
2938 289 (symbol '4')))
2939 290 * set:
2940 291 <addset
2941 292 <addset
2942 293 <baseset [0]>,
2943 294 <baseset [1]>>,
2944 295 <addset
2945 296 <baseset [2]>,
2946 297 <addset
2947 298 <baseset [3]>,
2948 299 <baseset [4]>>>>
2949 300 0
2950 301 1
2951 302 2
2952 303 3
2953 304 4
2954 305
2955 306 test that `_list` should be narrowed by provided `subset`
2956 307
2957 308 $ log '0:2 and (null|1|2|3)'
2958 309 1
2959 310 2
2960 311
2961 312 test that `_list` should remove duplicates
2962 313
2963 314 $ log '0|1|2|1|2|-1|tip'
2964 315 0
2965 316 1
2966 317 2
2967 318 9
2968 319
2969 320 test unknown revision in `_list`
2970 321
2971 322 $ log '0|unknown'
2972 323 abort: unknown revision 'unknown'!
2973 324 [255]
2974 325
2975 326 test integer range in `_list`
2976 327
2977 328 $ log '-1|-10'
2978 329 9
2979 330 0
2980 331
2981 332 $ log '-10|-11'
2982 333 abort: unknown revision '-11'!
2983 334 [255]
2984 335
2985 336 $ log '9|10'
2986 337 abort: unknown revision '10'!
2987 338 [255]
2988 339
2989 340 test '0000' != '0' in `_list`
2990 341
2991 342 $ log '0|0000'
2992 343 0
2993 344 -1
2994 345
2995 346 test ',' in `_list`
2996 347 $ log '0,1'
2997 348 hg: parse error: can't use a list in this context
2998 349 (see hg help "revsets.x or y")
2999 350 [255]
3000 351 $ try '0,1,2'
3001 352 (list
3002 353 (symbol '0')
3003 354 (symbol '1')
3004 355 (symbol '2'))
3005 356 hg: parse error: can't use a list in this context
3006 357 (see hg help "revsets.x or y")
3007 358 [255]
3008 359
3009 360 test that chained `or` operations make balanced addsets
3010 361
3011 362 $ try '0:1|1:2|2:3|3:4|4:5'
3012 363 (or
3013 364 (list
3014 365 (range
3015 366 (symbol '0')
3016 367 (symbol '1'))
3017 368 (range
3018 369 (symbol '1')
3019 370 (symbol '2'))
3020 371 (range
3021 372 (symbol '2')
3022 373 (symbol '3'))
3023 374 (range
3024 375 (symbol '3')
3025 376 (symbol '4'))
3026 377 (range
3027 378 (symbol '4')
3028 379 (symbol '5'))))
3029 380 * set:
3030 381 <addset
3031 382 <addset
3032 383 <spanset+ 0:2>,
3033 384 <spanset+ 1:3>>,
3034 385 <addset
3035 386 <spanset+ 2:4>,
3036 387 <addset
3037 388 <spanset+ 3:5>,
3038 389 <spanset+ 4:6>>>>
3039 390 0
3040 391 1
3041 392 2
3042 393 3
3043 394 4
3044 395 5
3045 396
3046 397 no crash by empty group "()" while optimizing `or` operations
3047 398
3048 399 $ try --optimize '0|()'
3049 400 (or
3050 401 (list
3051 402 (symbol '0')
3052 403 (group
3053 404 None)))
3054 405 * optimized:
3055 406 (or
3056 407 (list
3057 408 (symbol '0')
3058 409 None))
3059 410 hg: parse error: missing argument
3060 411 [255]
3061 412
3062 413 test that chained `or` operations never eat up stack (issue4624)
3063 414 (uses `0:1` instead of `0` to avoid future optimization of trivial revisions)
3064 415
3065 416 $ hg log -T '{rev}\n' -r `$PYTHON -c "print '+'.join(['0:1'] * 500)"`
3066 417 0
3067 418 1
3068 419
3069 420 test that repeated `-r` options never eat up stack (issue4565)
3070 421 (uses `-r 0::1` to avoid possible optimization at old-style parser)
3071 422
3072 423 $ hg log -T '{rev}\n' `$PYTHON -c "for i in xrange(500): print '-r 0::1 ',"`
3073 424 0
3074 425 1
3075 426
3076 427 check that conversion to only works
3077 428 $ try --optimize '::3 - ::1'
3078 429 (minus
3079 430 (dagrangepre
3080 431 (symbol '3'))
3081 432 (dagrangepre
3082 433 (symbol '1')))
3083 434 * optimized:
3084 435 (func
3085 436 (symbol 'only')
3086 437 (list
3087 438 (symbol '3')
3088 439 (symbol '1')))
3089 440 * set:
3090 441 <baseset+ [3]>
3091 442 3
3092 443 $ try --optimize 'ancestors(1) - ancestors(3)'
3093 444 (minus
3094 445 (func
3095 446 (symbol 'ancestors')
3096 447 (symbol '1'))
3097 448 (func
3098 449 (symbol 'ancestors')
3099 450 (symbol '3')))
3100 451 * optimized:
3101 452 (func
3102 453 (symbol 'only')
3103 454 (list
3104 455 (symbol '1')
3105 456 (symbol '3')))
3106 457 * set:
3107 458 <baseset+ []>
3108 459 $ try --optimize 'not ::2 and ::6'
3109 460 (and
3110 461 (not
3111 462 (dagrangepre
3112 463 (symbol '2')))
3113 464 (dagrangepre
3114 465 (symbol '6')))
3115 466 * optimized:
3116 467 (func
3117 468 (symbol 'only')
3118 469 (list
3119 470 (symbol '6')
3120 471 (symbol '2')))
3121 472 * set:
3122 473 <baseset+ [3, 4, 5, 6]>
3123 474 3
3124 475 4
3125 476 5
3126 477 6
3127 478 $ try --optimize 'ancestors(6) and not ancestors(4)'
3128 479 (and
3129 480 (func
3130 481 (symbol 'ancestors')
3131 482 (symbol '6'))
3132 483 (not
3133 484 (func
3134 485 (symbol 'ancestors')
3135 486 (symbol '4'))))
3136 487 * optimized:
3137 488 (func
3138 489 (symbol 'only')
3139 490 (list
3140 491 (symbol '6')
3141 492 (symbol '4')))
3142 493 * set:
3143 494 <baseset+ [3, 5, 6]>
3144 495 3
3145 496 5
3146 497 6
3147 498
3148 499 no crash by empty group "()" while optimizing to "only()"
3149 500
3150 501 $ try --optimize '::1 and ()'
3151 502 (and
3152 503 (dagrangepre
3153 504 (symbol '1'))
3154 505 (group
3155 506 None))
3156 507 * optimized:
3157 508 (andsmally
3158 509 (func
3159 510 (symbol 'ancestors')
3160 511 (symbol '1'))
3161 512 None)
3162 513 hg: parse error: missing argument
3163 514 [255]
3164 515
3165 516 optimization to only() works only if ancestors() takes only one argument
3166 517
3167 518 $ hg debugrevspec -p optimized 'ancestors(6) - ancestors(4, 1)'
3168 519 * optimized:
3169 520 (difference
3170 521 (func
3171 522 (symbol 'ancestors')
3172 523 (symbol '6'))
3173 524 (func
3174 525 (symbol 'ancestors')
3175 526 (list
3176 527 (symbol '4')
3177 528 (symbol '1'))))
3178 529 0
3179 530 1
3180 531 3
3181 532 5
3182 533 6
3183 534 $ hg debugrevspec -p optimized 'ancestors(6, 1) - ancestors(4)'
3184 535 * optimized:
3185 536 (difference
3186 537 (func
3187 538 (symbol 'ancestors')
3188 539 (list
3189 540 (symbol '6')
3190 541 (symbol '1')))
3191 542 (func
3192 543 (symbol 'ancestors')
3193 544 (symbol '4')))
3194 545 5
3195 546 6
3196 547
3197 548 optimization disabled if keyword arguments passed (because we're too lazy
3198 549 to support it)
3199 550
3200 551 $ hg debugrevspec -p optimized 'ancestors(set=6) - ancestors(set=4)'
3201 552 * optimized:
3202 553 (difference
3203 554 (func
3204 555 (symbol 'ancestors')
3205 556 (keyvalue
3206 557 (symbol 'set')
3207 558 (symbol '6')))
3208 559 (func
3209 560 (symbol 'ancestors')
3210 561 (keyvalue
3211 562 (symbol 'set')
3212 563 (symbol '4'))))
3213 564 3
3214 565 5
3215 566 6
3216 567
3217 568 invalid function call should not be optimized to only()
3218 569
3219 570 $ log '"ancestors"(6) and not ancestors(4)'
3220 571 hg: parse error: not a symbol
3221 572 [255]
3222 573
3223 574 $ log 'ancestors(6) and not "ancestors"(4)'
3224 575 hg: parse error: not a symbol
3225 576 [255]
3226 577
3227 578 we can use patterns when searching for tags
3228 579
3229 580 $ log 'tag("1..*")'
3230 581 abort: tag '1..*' does not exist!
3231 582 [255]
3232 583 $ log 'tag("re:1..*")'
3233 584 6
3234 585 $ log 'tag("re:[0-9].[0-9]")'
3235 586 6
3236 587 $ log 'tag("literal:1.0")'
3237 588 6
3238 589 $ log 'tag("re:0..*")'
3239 590
3240 591 $ log 'tag(unknown)'
3241 592 abort: tag 'unknown' does not exist!
3242 593 [255]
3243 594 $ log 'tag("re:unknown")'
3244 595 $ log 'present(tag("unknown"))'
3245 596 $ log 'present(tag("re:unknown"))'
3246 597 $ log 'branch(unknown)'
3247 598 abort: unknown revision 'unknown'!
3248 599 [255]
3249 600 $ log 'branch("literal:unknown")'
3250 601 abort: branch 'unknown' does not exist!
3251 602 [255]
3252 603 $ log 'branch("re:unknown")'
3253 604 $ log 'present(branch("unknown"))'
3254 605 $ log 'present(branch("re:unknown"))'
3255 606 $ log 'user(bob)'
3256 607 2
3257 608
3258 609 $ log '4::8'
3259 610 4
3260 611 8
3261 612 $ log '4:8'
3262 613 4
3263 614 5
3264 615 6
3265 616 7
3266 617 8
3267 618
3268 619 $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
3269 620 4
3270 621 2
3271 622 5
3272 623
3273 624 $ log 'not 0 and 0:2'
3274 625 1
3275 626 2
3276 627 $ log 'not 1 and 0:2'
3277 628 0
3278 629 2
3279 630 $ log 'not 2 and 0:2'
3280 631 0
3281 632 1
3282 633 $ log '(1 and 2)::'
3283 634 $ log '(1 and 2):'
3284 635 $ log '(1 and 2):3'
3285 636 $ log 'sort(head(), -rev)'
3286 637 9
3287 638 7
3288 639 6
3289 640 5
3290 641 4
3291 642 3
3292 643 2
3293 644 1
3294 645 0
3295 646 $ log '4::8 - 8'
3296 647 4
3297 648
3298 649 matching() should preserve the order of the input set:
3299 650
3300 651 $ log '(2 or 3 or 1) and matching(1 or 2 or 3)'
3301 652 2
3302 653 3
3303 654 1
3304 655
3305 656 $ log 'named("unknown")'
3306 657 abort: namespace 'unknown' does not exist!
3307 658 [255]
3308 659 $ log 'named("re:unknown")'
3309 660 abort: no namespace exists that match 'unknown'!
3310 661 [255]
3311 662 $ log 'present(named("unknown"))'
3312 663 $ log 'present(named("re:unknown"))'
3313 664
3314 665 $ log 'tag()'
3315 666 6
3316 667 $ log 'named("tags")'
3317 668 6
3318 669
3319 670 issue2437
3320 671
3321 672 $ log '3 and p1(5)'
3322 673 3
3323 674 $ log '4 and p2(6)'
3324 675 4
3325 676 $ log '1 and parents(:2)'
3326 677 1
3327 678 $ log '2 and children(1:)'
3328 679 2
3329 680 $ log 'roots(all()) or roots(all())'
3330 681 0
3331 682 $ hg debugrevspec 'roots(all()) or roots(all())'
3332 683 0
3333 684 $ log 'heads(branch(Γ©)) or heads(branch(Γ©))'
3334 685 9
3335 686 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))'
3336 687 4
3337 688
3338 689 issue2654: report a parse error if the revset was not completely parsed
3339 690
3340 691 $ log '1 OR 2'
3341 692 hg: parse error at 2: invalid token
3342 693 [255]
3343 694
3344 695 or operator should preserve ordering:
3345 696 $ log 'reverse(2::4) or tip'
3346 697 4
3347 698 2
3348 699 9
3349 700
3350 701 parentrevspec
3351 702
3352 703 $ log 'merge()^0'
3353 704 6
3354 705 $ log 'merge()^'
3355 706 5
3356 707 $ log 'merge()^1'
3357 708 5
3358 709 $ log 'merge()^2'
3359 710 4
3360 711 $ log '(not merge())^2'
3361 712 $ log 'merge()^^'
3362 713 3
3363 714 $ log 'merge()^1^'
3364 715 3
3365 716 $ log 'merge()^^^'
3366 717 1
3367 718
3368 719 $ hg debugrevspec -s '(merge() | 0)~-1'
3369 720 * set:
3370 721 <baseset+ [1, 7]>
3371 722 1
3372 723 7
3373 724 $ log 'merge()~-1'
3374 725 7
3375 726 $ log 'tip~-1'
3376 727 $ log '(tip | merge())~-1'
3377 728 7
3378 729 $ log 'merge()~0'
3379 730 6
3380 731 $ log 'merge()~1'
3381 732 5
3382 733 $ log 'merge()~2'
3383 734 3
3384 735 $ log 'merge()~2^1'
3385 736 1
3386 737 $ log 'merge()~3'
3387 738 1
3388 739
3389 740 $ log '(-3:tip)^'
3390 741 4
3391 742 6
3392 743 8
3393 744
3394 745 $ log 'tip^foo'
3395 746 hg: parse error: ^ expects a number 0, 1, or 2
3396 747 [255]
3397 748
3398 749 $ log 'branchpoint()~-1'
3399 750 abort: revision in set has more than one child!
3400 751 [255]
3401 752
3402 753 Bogus function gets suggestions
3403 754 $ log 'add()'
3404 755 hg: parse error: unknown identifier: add
3405 756 (did you mean adds?)
3406 757 [255]
3407 758 $ log 'added()'
3408 759 hg: parse error: unknown identifier: added
3409 760 (did you mean adds?)
3410 761 [255]
3411 762 $ log 'remo()'
3412 763 hg: parse error: unknown identifier: remo
3413 764 (did you mean one of remote, removes?)
3414 765 [255]
3415 766 $ log 'babar()'
3416 767 hg: parse error: unknown identifier: babar
3417 768 [255]
3418 769
3419 770 Bogus function with a similar internal name doesn't suggest the internal name
3420 771 $ log 'matches()'
3421 772 hg: parse error: unknown identifier: matches
3422 773 (did you mean matching?)
3423 774 [255]
3424 775
3425 776 Undocumented functions aren't suggested as similar either
3426 777 $ log 'tagged2()'
3427 778 hg: parse error: unknown identifier: tagged2
3428 779 [255]
3429 780
3430 781 multiple revspecs
3431 782
3432 783 $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
3433 784 8
3434 785 9
3435 786 4
3436 787 5
3437 788 6
3438 789 7
3439 790
3440 791 test usage in revpair (with "+")
3441 792
3442 793 (real pair)
3443 794
3444 795 $ hg diff -r 'tip^^' -r 'tip'
3445 796 diff -r 2326846efdab -r 24286f4ae135 .hgtags
3446 797 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3447 798 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
3448 799 @@ -0,0 +1,1 @@
3449 800 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3450 801 $ hg diff -r 'tip^^::tip'
3451 802 diff -r 2326846efdab -r 24286f4ae135 .hgtags
3452 803 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3453 804 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
3454 805 @@ -0,0 +1,1 @@
3455 806 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3456 807
3457 808 (single rev)
3458 809
3459 810 $ hg diff -r 'tip^' -r 'tip^'
3460 811 $ hg diff -r 'tip^:tip^'
3461 812
3462 813 (single rev that does not looks like a range)
3463 814
3464 815 $ hg diff -r 'tip^::tip^ or tip^'
3465 816 diff -r d5d0dcbdc4d9 .hgtags
3466 817 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3467 818 +++ b/.hgtags * (glob)
3468 819 @@ -0,0 +1,1 @@
3469 820 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3470 821 $ hg diff -r 'tip^ or tip^'
3471 822 diff -r d5d0dcbdc4d9 .hgtags
3472 823 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3473 824 +++ b/.hgtags * (glob)
3474 825 @@ -0,0 +1,1 @@
3475 826 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
3476 827
3477 828 (no rev)
3478 829
3479 830 $ hg diff -r 'author("babar") or author("celeste")'
3480 831 abort: empty revision range
3481 832 [255]
3482 833
3483 834 aliases:
3484 835
3485 836 $ echo '[revsetalias]' >> .hg/hgrc
3486 837 $ echo 'm = merge()' >> .hg/hgrc
3487 838 (revset aliases can override builtin revsets)
3488 839 $ echo 'p2($1) = p1($1)' >> .hg/hgrc
3489 840 $ echo 'sincem = descendants(m)' >> .hg/hgrc
3490 841 $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
3491 842 $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
3492 843 $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
3493 844
3494 845 $ try m
3495 846 (symbol 'm')
3496 847 * expanded:
3497 848 (func
3498 849 (symbol 'merge')
3499 850 None)
3500 851 * set:
3501 852 <filteredset
3502 853 <fullreposet+ 0:10>,
3503 854 <merge>>
3504 855 6
3505 856
3506 857 $ HGPLAIN=1
3507 858 $ export HGPLAIN
3508 859 $ try m
3509 860 (symbol 'm')
3510 861 abort: unknown revision 'm'!
3511 862 [255]
3512 863
3513 864 $ HGPLAINEXCEPT=revsetalias
3514 865 $ export HGPLAINEXCEPT
3515 866 $ try m
3516 867 (symbol 'm')
3517 868 * expanded:
3518 869 (func
3519 870 (symbol 'merge')
3520 871 None)
3521 872 * set:
3522 873 <filteredset
3523 874 <fullreposet+ 0:10>,
3524 875 <merge>>
3525 876 6
3526 877
3527 878 $ unset HGPLAIN
3528 879 $ unset HGPLAINEXCEPT
3529 880
3530 881 $ try 'p2(.)'
3531 882 (func
3532 883 (symbol 'p2')
3533 884 (symbol '.'))
3534 885 * expanded:
3535 886 (func
3536 887 (symbol 'p1')
3537 888 (symbol '.'))
3538 889 * set:
3539 890 <baseset+ [8]>
3540 891 8
3541 892
3542 893 $ HGPLAIN=1
3543 894 $ export HGPLAIN
3544 895 $ try 'p2(.)'
3545 896 (func
3546 897 (symbol 'p2')
3547 898 (symbol '.'))
3548 899 * set:
3549 900 <baseset+ []>
3550 901
3551 902 $ HGPLAINEXCEPT=revsetalias
3552 903 $ export HGPLAINEXCEPT
3553 904 $ try 'p2(.)'
3554 905 (func
3555 906 (symbol 'p2')
3556 907 (symbol '.'))
3557 908 * expanded:
3558 909 (func
3559 910 (symbol 'p1')
3560 911 (symbol '.'))
3561 912 * set:
3562 913 <baseset+ [8]>
3563 914 8
3564 915
3565 916 $ unset HGPLAIN
3566 917 $ unset HGPLAINEXCEPT
3567 918
3568 919 test alias recursion
3569 920
3570 921 $ try sincem
3571 922 (symbol 'sincem')
3572 923 * expanded:
3573 924 (func
3574 925 (symbol 'descendants')
3575 926 (func
3576 927 (symbol 'merge')
3577 928 None))
3578 929 * set:
3579 930 <generatorset+>
3580 931 6
3581 932 7
3582 933
3583 934 test infinite recursion
3584 935
3585 936 $ echo 'recurse1 = recurse2' >> .hg/hgrc
3586 937 $ echo 'recurse2 = recurse1' >> .hg/hgrc
3587 938 $ try recurse1
3588 939 (symbol 'recurse1')
3589 940 hg: parse error: infinite expansion of revset alias "recurse1" detected
3590 941 [255]
3591 942
3592 943 $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc
3593 944 $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc
3594 945 $ try "level2(level1(1, 2), 3)"
3595 946 (func
3596 947 (symbol 'level2')
3597 948 (list
3598 949 (func
3599 950 (symbol 'level1')
3600 951 (list
3601 952 (symbol '1')
3602 953 (symbol '2')))
3603 954 (symbol '3')))
3604 955 * expanded:
3605 956 (or
3606 957 (list
3607 958 (symbol '3')
3608 959 (or
3609 960 (list
3610 961 (symbol '1')
3611 962 (symbol '2')))))
3612 963 * set:
3613 964 <addset
3614 965 <baseset [3]>,
3615 966 <baseset [1, 2]>>
3616 967 3
3617 968 1
3618 969 2
3619 970
3620 971 test nesting and variable passing
3621 972
3622 973 $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
3623 974 $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
3624 975 $ echo 'nested3($1) = max($1)' >> .hg/hgrc
3625 976 $ try 'nested(2:5)'
3626 977 (func
3627 978 (symbol 'nested')
3628 979 (range
3629 980 (symbol '2')
3630 981 (symbol '5')))
3631 982 * expanded:
3632 983 (func
3633 984 (symbol 'max')
3634 985 (range
3635 986 (symbol '2')
3636 987 (symbol '5')))
3637 988 * set:
3638 989 <baseset
3639 990 <max
3640 991 <fullreposet+ 0:10>,
3641 992 <spanset+ 2:6>>>
3642 993 5
3643 994
3644 995 test chained `or` operations are flattened at parsing phase
3645 996
3646 997 $ echo 'chainedorops($1, $2, $3) = $1|$2|$3' >> .hg/hgrc
3647 998 $ try 'chainedorops(0:1, 1:2, 2:3)'
3648 999 (func
3649 1000 (symbol 'chainedorops')
3650 1001 (list
3651 1002 (range
3652 1003 (symbol '0')
3653 1004 (symbol '1'))
3654 1005 (range
3655 1006 (symbol '1')
3656 1007 (symbol '2'))
3657 1008 (range
3658 1009 (symbol '2')
3659 1010 (symbol '3'))))
3660 1011 * expanded:
3661 1012 (or
3662 1013 (list
3663 1014 (range
3664 1015 (symbol '0')
3665 1016 (symbol '1'))
3666 1017 (range
3667 1018 (symbol '1')
3668 1019 (symbol '2'))
3669 1020 (range
3670 1021 (symbol '2')
3671 1022 (symbol '3'))))
3672 1023 * set:
3673 1024 <addset
3674 1025 <spanset+ 0:2>,
3675 1026 <addset
3676 1027 <spanset+ 1:3>,
3677 1028 <spanset+ 2:4>>>
3678 1029 0
3679 1030 1
3680 1031 2
3681 1032 3
3682 1033
3683 1034 test variable isolation, variable placeholders are rewritten as string
3684 1035 then parsed and matched again as string. Check they do not leak too
3685 1036 far away.
3686 1037
3687 1038 $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
3688 1039 $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
3689 1040 $ try 'callinjection(2:5)'
3690 1041 (func
3691 1042 (symbol 'callinjection')
3692 1043 (range
3693 1044 (symbol '2')
3694 1045 (symbol '5')))
3695 1046 * expanded:
3696 1047 (func
3697 1048 (symbol 'descendants')
3698 1049 (func
3699 1050 (symbol 'max')
3700 1051 (string '$1')))
3701 1052 abort: unknown revision '$1'!
3702 1053 [255]
3703 1054
3704 1055 test scope of alias expansion: 'universe' is expanded prior to 'shadowall(0)',
3705 1056 but 'all()' should never be substituted to '0()'.
3706 1057
3707 1058 $ echo 'universe = all()' >> .hg/hgrc
3708 1059 $ echo 'shadowall(all) = all and universe' >> .hg/hgrc
3709 1060 $ try 'shadowall(0)'
3710 1061 (func
3711 1062 (symbol 'shadowall')
3712 1063 (symbol '0'))
3713 1064 * expanded:
3714 1065 (and
3715 1066 (symbol '0')
3716 1067 (func
3717 1068 (symbol 'all')
3718 1069 None))
3719 1070 * set:
3720 1071 <filteredset
3721 1072 <baseset [0]>,
3722 1073 <spanset+ 0:10>>
3723 1074 0
3724 1075
3725 1076 test unknown reference:
3726 1077
3727 1078 $ try "unknownref(0)" --config 'revsetalias.unknownref($1)=$1:$2'
3728 1079 (func
3729 1080 (symbol 'unknownref')
3730 1081 (symbol '0'))
3731 1082 abort: bad definition of revset alias "unknownref": invalid symbol '$2'
3732 1083 [255]
3733 1084
3734 1085 $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
3735 1086 (symbol 'tip')
3736 1087 warning: bad definition of revset alias "anotherbadone": at 7: not a prefix: end
3737 1088 * set:
3738 1089 <baseset [9]>
3739 1090 9
3740 1091
3741 1092 $ try 'tip'
3742 1093 (symbol 'tip')
3743 1094 * set:
3744 1095 <baseset [9]>
3745 1096 9
3746 1097
3747 1098 $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
3748 1099 (symbol 'tip')
3749 1100 warning: bad declaration of revset alias "bad name": at 4: invalid token
3750 1101 * set:
3751 1102 <baseset [9]>
3752 1103 9
3753 1104 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
3754 1105 $ try 'strictreplacing("foo", tip)'
3755 1106 (func
3756 1107 (symbol 'strictreplacing')
3757 1108 (list
3758 1109 (string 'foo')
3759 1110 (symbol 'tip')))
3760 1111 * expanded:
3761 1112 (or
3762 1113 (list
3763 1114 (symbol 'tip')
3764 1115 (func
3765 1116 (symbol 'desc')
3766 1117 (string '$1'))))
3767 1118 * set:
3768 1119 <addset
3769 1120 <baseset [9]>,
3770 1121 <filteredset
3771 1122 <fullreposet+ 0:10>,
3772 1123 <desc '$1'>>>
3773 1124 9
3774 1125
3775 1126 $ try 'd(2:5)'
3776 1127 (func
3777 1128 (symbol 'd')
3778 1129 (range
3779 1130 (symbol '2')
3780 1131 (symbol '5')))
3781 1132 * expanded:
3782 1133 (func
3783 1134 (symbol 'reverse')
3784 1135 (func
3785 1136 (symbol 'sort')
3786 1137 (list
3787 1138 (range
3788 1139 (symbol '2')
3789 1140 (symbol '5'))
3790 1141 (symbol 'date'))))
3791 1142 * set:
3792 1143 <baseset [4, 5, 3, 2]>
3793 1144 4
3794 1145 5
3795 1146 3
3796 1147 2
3797 1148 $ try 'rs(2 or 3, date)'
3798 1149 (func
3799 1150 (symbol 'rs')
3800 1151 (list
3801 1152 (or
3802 1153 (list
3803 1154 (symbol '2')
3804 1155 (symbol '3')))
3805 1156 (symbol 'date')))
3806 1157 * expanded:
3807 1158 (func
3808 1159 (symbol 'reverse')
3809 1160 (func
3810 1161 (symbol 'sort')
3811 1162 (list
3812 1163 (or
3813 1164 (list
3814 1165 (symbol '2')
3815 1166 (symbol '3')))
3816 1167 (symbol 'date'))))
3817 1168 * set:
3818 1169 <baseset [3, 2]>
3819 1170 3
3820 1171 2
3821 1172 $ try 'rs()'
3822 1173 (func
3823 1174 (symbol 'rs')
3824 1175 None)
3825 1176 hg: parse error: invalid number of arguments: 0
3826 1177 [255]
3827 1178 $ try 'rs(2)'
3828 1179 (func
3829 1180 (symbol 'rs')
3830 1181 (symbol '2'))
3831 1182 hg: parse error: invalid number of arguments: 1
3832 1183 [255]
3833 1184 $ try 'rs(2, data, 7)'
3834 1185 (func
3835 1186 (symbol 'rs')
3836 1187 (list
3837 1188 (symbol '2')
3838 1189 (symbol 'data')
3839 1190 (symbol '7')))
3840 1191 hg: parse error: invalid number of arguments: 3
3841 1192 [255]
3842 1193 $ try 'rs4(2 or 3, x, x, date)'
3843 1194 (func
3844 1195 (symbol 'rs4')
3845 1196 (list
3846 1197 (or
3847 1198 (list
3848 1199 (symbol '2')
3849 1200 (symbol '3')))
3850 1201 (symbol 'x')
3851 1202 (symbol 'x')
3852 1203 (symbol 'date')))
3853 1204 * expanded:
3854 1205 (func
3855 1206 (symbol 'reverse')
3856 1207 (func
3857 1208 (symbol 'sort')
3858 1209 (list
3859 1210 (or
3860 1211 (list
3861 1212 (symbol '2')
3862 1213 (symbol '3')))
3863 1214 (symbol 'date'))))
3864 1215 * set:
3865 1216 <baseset [3, 2]>
3866 1217 3
3867 1218 2
3868 1219
3869 1220 issue4553: check that revset aliases override existing hash prefix
3870 1221
3871 1222 $ hg log -qr e
3872 1223 6:e0cc66ef77e8
3873 1224
3874 1225 $ hg log -qr e --config revsetalias.e="all()"
3875 1226 0:2785f51eece5
3876 1227 1:d75937da8da0
3877 1228 2:5ed5505e9f1c
3878 1229 3:8528aa5637f2
3879 1230 4:2326846efdab
3880 1231 5:904fa392b941
3881 1232 6:e0cc66ef77e8
3882 1233 7:013af1973af4
3883 1234 8:d5d0dcbdc4d9
3884 1235 9:24286f4ae135
3885 1236
3886 1237 $ hg log -qr e: --config revsetalias.e="0"
3887 1238 0:2785f51eece5
3888 1239 1:d75937da8da0
3889 1240 2:5ed5505e9f1c
3890 1241 3:8528aa5637f2
3891 1242 4:2326846efdab
3892 1243 5:904fa392b941
3893 1244 6:e0cc66ef77e8
3894 1245 7:013af1973af4
3895 1246 8:d5d0dcbdc4d9
3896 1247 9:24286f4ae135
3897 1248
3898 1249 $ hg log -qr :e --config revsetalias.e="9"
3899 1250 0:2785f51eece5
3900 1251 1:d75937da8da0
3901 1252 2:5ed5505e9f1c
3902 1253 3:8528aa5637f2
3903 1254 4:2326846efdab
3904 1255 5:904fa392b941
3905 1256 6:e0cc66ef77e8
3906 1257 7:013af1973af4
3907 1258 8:d5d0dcbdc4d9
3908 1259 9:24286f4ae135
3909 1260
3910 1261 $ hg log -qr e:
3911 1262 6:e0cc66ef77e8
3912 1263 7:013af1973af4
3913 1264 8:d5d0dcbdc4d9
3914 1265 9:24286f4ae135
3915 1266
3916 1267 $ hg log -qr :e
3917 1268 0:2785f51eece5
3918 1269 1:d75937da8da0
3919 1270 2:5ed5505e9f1c
3920 1271 3:8528aa5637f2
3921 1272 4:2326846efdab
3922 1273 5:904fa392b941
3923 1274 6:e0cc66ef77e8
3924 1275
3925 1276 issue2549 - correct optimizations
3926 1277
3927 1278 $ try 'limit(1 or 2 or 3, 2) and not 2'
3928 1279 (and
3929 1280 (func
3930 1281 (symbol 'limit')
3931 1282 (list
3932 1283 (or
3933 1284 (list
3934 1285 (symbol '1')
3935 1286 (symbol '2')
3936 1287 (symbol '3')))
3937 1288 (symbol '2')))
3938 1289 (not
3939 1290 (symbol '2')))
3940 1291 * set:
3941 1292 <filteredset
3942 1293 <baseset [1, 2]>,
3943 1294 <not
3944 1295 <baseset [2]>>>
3945 1296 1
3946 1297 $ try 'max(1 or 2) and not 2'
3947 1298 (and
3948 1299 (func
3949 1300 (symbol 'max')
3950 1301 (or
3951 1302 (list
3952 1303 (symbol '1')
3953 1304 (symbol '2'))))
3954 1305 (not
3955 1306 (symbol '2')))
3956 1307 * set:
3957 1308 <filteredset
3958 1309 <baseset
3959 1310 <max
3960 1311 <fullreposet+ 0:10>,
3961 1312 <baseset [1, 2]>>>,
3962 1313 <not
3963 1314 <baseset [2]>>>
3964 1315 $ try 'min(1 or 2) and not 1'
3965 1316 (and
3966 1317 (func
3967 1318 (symbol 'min')
3968 1319 (or
3969 1320 (list
3970 1321 (symbol '1')
3971 1322 (symbol '2'))))
3972 1323 (not
3973 1324 (symbol '1')))
3974 1325 * set:
3975 1326 <filteredset
3976 1327 <baseset
3977 1328 <min
3978 1329 <fullreposet+ 0:10>,
3979 1330 <baseset [1, 2]>>>,
3980 1331 <not
3981 1332 <baseset [1]>>>
3982 1333 $ try 'last(1 or 2, 1) and not 2'
3983 1334 (and
3984 1335 (func
3985 1336 (symbol 'last')
3986 1337 (list
3987 1338 (or
3988 1339 (list
3989 1340 (symbol '1')
3990 1341 (symbol '2')))
3991 1342 (symbol '1')))
3992 1343 (not
3993 1344 (symbol '2')))
3994 1345 * set:
3995 1346 <filteredset
3996 1347 <baseset [2]>,
3997 1348 <not
3998 1349 <baseset [2]>>>
3999 1350
4000 1351 issue4289 - ordering of built-ins
4001 1352 $ hg log -M -q -r 3:2
4002 1353 3:8528aa5637f2
4003 1354 2:5ed5505e9f1c
4004 1355
4005 1356 test revsets started with 40-chars hash (issue3669)
4006 1357
4007 1358 $ ISSUE3669_TIP=`hg tip --template '{node}'`
4008 1359 $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n'
4009 1360 9
4010 1361 $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n'
4011 1362 8
4012 1363
4013 1364 test or-ed indirect predicates (issue3775)
4014 1365
4015 1366 $ log '6 or 6^1' | sort
4016 1367 5
4017 1368 6
4018 1369 $ log '6^1 or 6' | sort
4019 1370 5
4020 1371 6
4021 1372 $ log '4 or 4~1' | sort
4022 1373 2
4023 1374 4
4024 1375 $ log '4~1 or 4' | sort
4025 1376 2
4026 1377 4
4027 1378 $ log '(0 or 2):(4 or 6) or 0 or 6' | sort
4028 1379 0
4029 1380 1
4030 1381 2
4031 1382 3
4032 1383 4
4033 1384 5
4034 1385 6
4035 1386 $ log '0 or 6 or (0 or 2):(4 or 6)' | sort
4036 1387 0
4037 1388 1
4038 1389 2
4039 1390 3
4040 1391 4
4041 1392 5
4042 1393 6
4043 1394
4044 1395 tests for 'remote()' predicate:
4045 1396 #. (csets in remote) (id) (remote)
4046 1397 1. less than local current branch "default"
4047 1398 2. same with local specified "default"
4048 1399 3. more than local specified specified
4049 1400
4050 1401 $ hg clone --quiet -U . ../remote3
4051 1402 $ cd ../remote3
4052 1403 $ hg update -q 7
4053 1404 $ echo r > r
4054 1405 $ hg ci -Aqm 10
4055 1406 $ log 'remote()'
4056 1407 7
4057 1408 $ log 'remote("a-b-c-")'
4058 1409 2
4059 1410 $ cd ../repo
4060 1411 $ log 'remote(".a.b.c.", "../remote3")'
4061 1412
4062 1413 tests for concatenation of strings/symbols by "##"
4063 1414
4064 1415 $ try "278 ## '5f5' ## 1ee ## 'ce5'"
4065 1416 (_concat
4066 1417 (_concat
4067 1418 (_concat
4068 1419 (symbol '278')
4069 1420 (string '5f5'))
4070 1421 (symbol '1ee'))
4071 1422 (string 'ce5'))
4072 1423 * concatenated:
4073 1424 (string '2785f51eece5')
4074 1425 * set:
4075 1426 <baseset [0]>
4076 1427 0
4077 1428
4078 1429 $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc
4079 1430 $ try "cat4(278, '5f5', 1ee, 'ce5')"
4080 1431 (func
4081 1432 (symbol 'cat4')
4082 1433 (list
4083 1434 (symbol '278')
4084 1435 (string '5f5')
4085 1436 (symbol '1ee')
4086 1437 (string 'ce5')))
4087 1438 * expanded:
4088 1439 (_concat
4089 1440 (_concat
4090 1441 (_concat
4091 1442 (symbol '278')
4092 1443 (string '5f5'))
4093 1444 (symbol '1ee'))
4094 1445 (string 'ce5'))
4095 1446 * concatenated:
4096 1447 (string '2785f51eece5')
4097 1448 * set:
4098 1449 <baseset [0]>
4099 1450 0
4100 1451
4101 1452 (check concatenation in alias nesting)
4102 1453
4103 1454 $ echo 'cat2($1, $2) = $1 ## $2' >> .hg/hgrc
4104 1455 $ echo 'cat2x2($1, $2, $3, $4) = cat2($1 ## $2, $3 ## $4)' >> .hg/hgrc
4105 1456 $ log "cat2x2(278, '5f5', 1ee, 'ce5')"
4106 1457 0
4107 1458
4108 1459 (check operator priority)
4109 1460
4110 1461 $ echo 'cat2n2($1, $2, $3, $4) = $1 ## $2 or $3 ## $4~2' >> .hg/hgrc
4111 1462 $ log "cat2n2(2785f5, 1eece5, 24286f, 4ae135)"
4112 1463 0
4113 1464 4
4114 1465
4115 1466 $ cd ..
4116 1467
4117 1468 prepare repository that has "default" branches of multiple roots
4118 1469
4119 1470 $ hg init namedbranch
4120 1471 $ cd namedbranch
4121 1472
4122 1473 $ echo default0 >> a
4123 1474 $ hg ci -Aqm0
4124 1475 $ echo default1 >> a
4125 1476 $ hg ci -m1
4126 1477
4127 1478 $ hg branch -q stable
4128 1479 $ echo stable2 >> a
4129 1480 $ hg ci -m2
4130 1481 $ echo stable3 >> a
4131 1482 $ hg ci -m3
4132 1483
4133 1484 $ hg update -q null
4134 1485 $ echo default4 >> a
4135 1486 $ hg ci -Aqm4
4136 1487 $ echo default5 >> a
4137 1488 $ hg ci -m5
4138 1489
4139 1490 "null" revision belongs to "default" branch (issue4683)
4140 1491
4141 1492 $ log 'branch(null)'
4142 1493 0
4143 1494 1
4144 1495 4
4145 1496 5
4146 1497
4147 1498 "null" revision belongs to "default" branch, but it shouldn't appear in set
4148 1499 unless explicitly specified (issue4682)
4149 1500
4150 1501 $ log 'children(branch(default))'
4151 1502 1
4152 1503 2
4153 1504 5
4154 1505
4155 1506 $ cd ..
4156 1507
4157 1508 test author/desc/keyword in problematic encoding
4158 1509 # unicode: cp932:
4159 1510 # u30A2 0x83 0x41(= 'A')
4160 1511 # u30C2 0x83 0x61(= 'a')
4161 1512
4162 1513 $ hg init problematicencoding
4163 1514 $ cd problematicencoding
4164 1515
4165 1516 $ $PYTHON > setup.sh <<EOF
4166 1517 > print u'''
4167 1518 > echo a > text
4168 1519 > hg add text
4169 1520 > hg --encoding utf-8 commit -u '\u30A2' -m none
4170 1521 > echo b > text
4171 1522 > hg --encoding utf-8 commit -u '\u30C2' -m none
4172 1523 > echo c > text
4173 1524 > hg --encoding utf-8 commit -u none -m '\u30A2'
4174 1525 > echo d > text
4175 1526 > hg --encoding utf-8 commit -u none -m '\u30C2'
4176 1527 > '''.encode('utf-8')
4177 1528 > EOF
4178 1529 $ sh < setup.sh
4179 1530
4180 1531 test in problematic encoding
4181 1532 $ $PYTHON > test.sh <<EOF
4182 1533 > print u'''
4183 1534 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
4184 1535 > echo ====
4185 1536 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
4186 1537 > echo ====
4187 1538 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
4188 1539 > echo ====
4189 1540 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
4190 1541 > echo ====
4191 1542 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
4192 1543 > echo ====
4193 1544 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
4194 1545 > '''.encode('cp932')
4195 1546 > EOF
4196 1547 $ sh < test.sh
4197 1548 0
4198 1549 ====
4199 1550 1
4200 1551 ====
4201 1552 2
4202 1553 ====
4203 1554 3
4204 1555 ====
4205 1556 0
4206 1557 2
4207 1558 ====
4208 1559 1
4209 1560 3
4210 1561
4211 1562 test error message of bad revset
4212 1563 $ hg log -r 'foo\\'
4213 1564 hg: parse error at 3: syntax error in revset 'foo\\'
4214 1565 [255]
4215 1566
4216 1567 $ cd ..
4217 1568
4218 1569 Test that revset predicate of extension isn't loaded at failure of
4219 1570 loading it
4220 1571
4221 1572 $ cd repo
4222 1573
4223 1574 $ cat <<EOF > $TESTTMP/custompredicate.py
4224 1575 > from mercurial import error, registrar, revset
4225 1576 >
4226 1577 > revsetpredicate = registrar.revsetpredicate()
4227 1578 >
4228 1579 > @revsetpredicate('custom1()')
4229 1580 > def custom1(repo, subset, x):
4230 1581 > return revset.baseset([1])
4231 1582 >
4232 1583 > raise error.Abort('intentional failure of loading extension')
4233 1584 > EOF
4234 1585 $ cat <<EOF > .hg/hgrc
4235 1586 > [extensions]
4236 1587 > custompredicate = $TESTTMP/custompredicate.py
4237 1588 > EOF
4238 1589
4239 1590 $ hg debugrevspec "custom1()"
4240 1591 *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
4241 1592 hg: parse error: unknown identifier: custom1
4242 1593 [255]
4243 1594
4244 1595 Test repo.anyrevs with customized revset overrides
4245 1596
4246 1597 $ cat > $TESTTMP/printprevset.py <<EOF
4247 1598 > from mercurial import encoding, registrar
4248 1599 > cmdtable = {}
4249 1600 > command = registrar.command(cmdtable)
4250 1601 > @command('printprevset')
4251 1602 > def printprevset(ui, repo):
4252 1603 > alias = {}
4253 1604 > p = encoding.environ.get('P')
4254 1605 > if p:
4255 1606 > alias['P'] = p
4256 1607 > revs = repo.anyrevs(['P'], user=True, localalias=alias)
4257 1608 > ui.write('P=%r\n' % list(revs))
4258 1609 > EOF
4259 1610
4260 1611 $ cat >> .hg/hgrc <<EOF
4261 1612 > custompredicate = !
4262 1613 > printprevset = $TESTTMP/printprevset.py
4263 1614 > EOF
4264 1615
4265 1616 $ hg --config revsetalias.P=1 printprevset
4266 1617 P=[1]
4267 1618 $ P=3 hg --config revsetalias.P=2 printprevset
4268 1619 P=[3]
4269 1620
4270 1621 $ cd ..
4271 1622
4272 1623 Test obsstore related revsets
4273 1624
4274 1625 $ hg init repo1
4275 1626 $ cd repo1
4276 1627 $ cat <<EOF >> .hg/hgrc
4277 1628 > [experimental]
4278 1629 > stabilization = createmarkers
4279 1630 > EOF
4280 1631
4281 1632 $ hg debugdrawdag <<'EOS'
4282 1633 > F G
4283 1634 > |/ # split: B -> E, F
4284 1635 > B C D E # amend: B -> C -> D
4285 1636 > \|/ | # amend: F -> G
4286 1637 > A A Z # amend: A -> Z
4287 1638 > EOS
4288 1639
4289 1640 $ hg log -r 'successors(Z)' -T '{desc}\n'
4290 1641 Z
4291 1642
4292 1643 $ hg log -r 'successors(F)' -T '{desc}\n'
4293 1644 F
4294 1645 G
4295 1646
4296 1647 $ hg tag --remove --local C D E F G
4297 1648
4298 1649 $ hg log -r 'successors(B)' -T '{desc}\n'
4299 1650 B
4300 1651 D
4301 1652 E
4302 1653 G
4303 1654
4304 1655 $ hg log -r 'successors(B)' -T '{desc}\n' --hidden
4305 1656 B
4306 1657 C
4307 1658 D
4308 1659 E
4309 1660 F
4310 1661 G
4311 1662
4312 1663 $ hg log -r 'successors(B)-obsolete()' -T '{desc}\n' --hidden
4313 1664 D
4314 1665 E
4315 1666 G
4316 1667
4317 1668 $ hg log -r 'successors(B+A)-contentdivergent()' -T '{desc}\n'
4318 1669 A
4319 1670 Z
4320 1671 B
4321 1672
4322 1673 $ hg log -r 'successors(B+A)-contentdivergent()-obsolete()' -T '{desc}\n'
4323 1674 Z
4324 1675
4325 1676 Test `draft() & ::x` optimization
4326 1677
4327 1678 $ hg init $TESTTMP/repo2
4328 1679 $ cd $TESTTMP/repo2
4329 1680 $ hg debugdrawdag <<'EOS'
4330 1681 > P5 S1
4331 1682 > | |
4332 1683 > S2 | D3
4333 1684 > \|/
4334 1685 > P4
4335 1686 > |
4336 1687 > P3 D2
4337 1688 > | |
4338 1689 > P2 D1
4339 1690 > |/
4340 1691 > P1
4341 1692 > |
4342 1693 > P0
4343 1694 > EOS
4344 1695 $ hg phase --public -r P5
4345 1696 $ hg phase --force --secret -r S1+S2
4346 1697 $ hg log -G -T '{rev} {desc} {phase}' -r 'sort(all(), topo, topo.firstbranch=P5)'
4347 1698 o 8 P5 public
4348 1699 |
4349 1700 | o 10 S1 secret
4350 1701 | |
4351 1702 | o 7 D3 draft
4352 1703 |/
4353 1704 | o 9 S2 secret
4354 1705 |/
4355 1706 o 6 P4 public
4356 1707 |
4357 1708 o 5 P3 public
4358 1709 |
4359 1710 o 3 P2 public
4360 1711 |
4361 1712 | o 4 D2 draft
4362 1713 | |
4363 1714 | o 2 D1 draft
4364 1715 |/
4365 1716 o 1 P1 public
4366 1717 |
4367 1718 o 0 P0 public
4368 1719
4369 1720 $ hg debugrevspec --verify -p analyzed -p optimized 'draft() & ::(((S1+D1+P5)-D3)+S2)'
4370 1721 * analyzed:
4371 1722 (and
4372 1723 (func
4373 1724 (symbol 'draft')
4374 1725 None)
4375 1726 (func
4376 1727 (symbol 'ancestors')
4377 1728 (or
4378 1729 (list
4379 1730 (and
4380 1731 (or
4381 1732 (list
4382 1733 (symbol 'S1')
4383 1734 (symbol 'D1')
4384 1735 (symbol 'P5')))
4385 1736 (not
4386 1737 (symbol 'D3')))
4387 1738 (symbol 'S2')))))
4388 1739 * optimized:
4389 1740 (func
4390 1741 (symbol '_phaseandancestors')
4391 1742 (list
4392 1743 (symbol 'draft')
4393 1744 (or
4394 1745 (list
4395 1746 (difference
4396 1747 (func
4397 1748 (symbol '_list')
4398 1749 (string 'S1\x00D1\x00P5'))
4399 1750 (symbol 'D3'))
4400 1751 (symbol 'S2')))))
4401 1752 $ hg debugrevspec --verify -p analyzed -p optimized 'secret() & ::9'
4402 1753 * analyzed:
4403 1754 (and
4404 1755 (func
4405 1756 (symbol 'secret')
4406 1757 None)
4407 1758 (func
4408 1759 (symbol 'ancestors')
4409 1760 (symbol '9')))
4410 1761 * optimized:
4411 1762 (func
4412 1763 (symbol '_phaseandancestors')
4413 1764 (list
4414 1765 (symbol 'secret')
4415 1766 (symbol '9')))
4416 1767 $ hg debugrevspec --verify -p analyzed -p optimized '7 & ( (not public()) & ::(tag()) )'
4417 1768 * analyzed:
4418 1769 (and
4419 1770 (symbol '7')
4420 1771 (and
4421 1772 (not
4422 1773 (func
4423 1774 (symbol 'public')
4424 1775 None))
4425 1776 (func
4426 1777 (symbol 'ancestors')
4427 1778 (func
4428 1779 (symbol 'tag')
4429 1780 None))))
4430 1781 * optimized:
4431 1782 (and
4432 1783 (symbol '7')
4433 1784 (func
4434 1785 (symbol '_phaseandancestors')
4435 1786 (list
4436 1787 (symbol '_notpublic')
4437 1788 (func
4438 1789 (symbol 'tag')
4439 1790 None))))
4440 1791 $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, 1)'
4441 1792 * optimized:
4442 1793 (and
4443 1794 (func
4444 1795 (symbol '_notpublic')
4445 1796 None)
4446 1797 (func
4447 1798 (symbol 'ancestors')
4448 1799 (list
4449 1800 (func
4450 1801 (symbol '_list')
4451 1802 (string 'S1\x00D2\x00P5'))
4452 1803 (symbol '1'))))
4453 1804 $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, depth=1)'
4454 1805 * optimized:
4455 1806 (and
4456 1807 (func
4457 1808 (symbol '_notpublic')
4458 1809 None)
4459 1810 (func
4460 1811 (symbol 'ancestors')
4461 1812 (list
4462 1813 (func
4463 1814 (symbol '_list')
4464 1815 (string 'S1\x00D2\x00P5'))
4465 1816 (keyvalue
4466 1817 (symbol 'depth')
4467 1818 (symbol '1')))))
General Comments 0
You need to be logged in to leave comments. Login now