##// END OF EJS Templates
test-revset: show that order of heads() can be wrong
Yuya Nishihara -
r38497:b2d5ad03 default
parent child Browse files
Show More
@@ -1,2841 +1,2873 b''
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[b'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 > )
46 46 > from mercurial.utils import stringutil
47 47 > cmdtable = {}
48 48 > command = registrar.command(cmdtable)
49 49 > @command(b'debugrevlistspec',
50 50 > [(b'', b'optimize', None, b'print parsed tree after optimizing'),
51 51 > (b'', b'bin', None, b'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=revset.lookupfn(repo))
58 58 > ui.note(revsetlang.prettyformat(tree), b"\n")
59 59 > if opts["optimize"]:
60 60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
62 62 > b"\n")
63 63 > func = revset.match(ui, expr, lookup=revset.lookupfn(repo))
64 64 > revs = func(repo)
65 65 > if ui.verbose:
66 66 > ui.note(b"* set:\n", stringutil.prettyrepr(revs), b"\n")
67 67 > for c in revs:
68 68 > ui.write(b"%d\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 (date(this is a test)
403 403 ^ here)
404 404 [255]
405 405 $ log 'date()'
406 406 hg: parse error: date requires a string
407 407 [255]
408 408 $ log 'date'
409 409 abort: unknown revision 'date'!
410 410 [255]
411 411 $ log 'date('
412 412 hg: parse error at 5: not a prefix: end
413 413 (date(
414 414 ^ here)
415 415 [255]
416 416 $ log 'date("\xy")'
417 417 hg: parse error: invalid \x escape* (glob)
418 418 [255]
419 419 $ log 'date(tip)'
420 420 hg: parse error: invalid date: 'tip'
421 421 [255]
422 422 $ log '0:date'
423 423 abort: unknown revision 'date'!
424 424 [255]
425 425 $ log '::"date"'
426 426 abort: unknown revision 'date'!
427 427 [255]
428 428 $ hg book date -r 4
429 429 $ log '0:date'
430 430 0
431 431 1
432 432 2
433 433 3
434 434 4
435 435 $ log '::date'
436 436 0
437 437 1
438 438 2
439 439 4
440 440 $ log '::"date"'
441 441 0
442 442 1
443 443 2
444 444 4
445 445 $ log 'date(2005) and 1::'
446 446 4
447 447 $ hg book -d date
448 448
449 449 function name should be a symbol
450 450
451 451 $ log '"date"(2005)'
452 452 hg: parse error: not a symbol
453 453 [255]
454 454
455 455 keyword arguments
456 456
457 457 $ log 'extra(branch, value=a)'
458 458 0
459 459
460 460 $ log 'extra(branch, a, b)'
461 461 hg: parse error: extra takes at most 2 positional arguments
462 462 [255]
463 463 $ log 'extra(a, label=b)'
464 464 hg: parse error: extra got multiple values for keyword argument 'label'
465 465 [255]
466 466 $ log 'extra(label=branch, default)'
467 467 hg: parse error: extra got an invalid argument
468 468 [255]
469 469 $ log 'extra(branch, foo+bar=baz)'
470 470 hg: parse error: extra got an invalid argument
471 471 [255]
472 472 $ log 'extra(unknown=branch)'
473 473 hg: parse error: extra got an unexpected keyword argument 'unknown'
474 474 [255]
475 475
476 476 $ try 'foo=bar|baz'
477 477 (keyvalue
478 478 (symbol 'foo')
479 479 (or
480 480 (list
481 481 (symbol 'bar')
482 482 (symbol 'baz'))))
483 483 hg: parse error: can't use a key-value pair in this context
484 484 [255]
485 485
486 486 right-hand side should be optimized recursively
487 487
488 488 $ try --optimize 'foo=(not public())'
489 489 (keyvalue
490 490 (symbol 'foo')
491 491 (group
492 492 (not
493 493 (func
494 494 (symbol 'public')
495 495 None))))
496 496 * optimized:
497 497 (keyvalue
498 498 (symbol 'foo')
499 499 (func
500 500 (symbol '_notpublic')
501 501 None))
502 502 hg: parse error: can't use a key-value pair in this context
503 503 [255]
504 504
505 505 relation-subscript operator has the highest binding strength (as function call):
506 506
507 507 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
508 508 * parsed:
509 509 (range
510 510 (symbol 'tip')
511 511 (relsubscript
512 512 (parentpost
513 513 (symbol 'tip'))
514 514 (symbol 'generations')
515 515 (negate
516 516 (symbol '1'))))
517 517 9
518 518 8
519 519 7
520 520 6
521 521 5
522 522 4
523 523
524 524 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
525 525 * parsed:
526 526 (not
527 527 (relsubscript
528 528 (func
529 529 (symbol 'public')
530 530 None)
531 531 (symbol 'generations')
532 532 (symbol '0')))
533 533
534 534 left-hand side of relation-subscript operator should be optimized recursively:
535 535
536 536 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
537 537 > '(not public())#generations[0]'
538 538 * analyzed:
539 539 (relsubscript
540 540 (not
541 541 (func
542 542 (symbol 'public')
543 543 None))
544 544 (symbol 'generations')
545 545 (symbol '0'))
546 546 * optimized:
547 547 (relsubscript
548 548 (func
549 549 (symbol '_notpublic')
550 550 None)
551 551 (symbol 'generations')
552 552 (symbol '0'))
553 553
554 554 resolution of subscript and relation-subscript ternary operators:
555 555
556 556 $ hg debugrevspec -p analyzed 'tip[0]'
557 557 * analyzed:
558 558 (subscript
559 559 (symbol 'tip')
560 560 (symbol '0'))
561 561 hg: parse error: can't use a subscript in this context
562 562 [255]
563 563
564 564 $ hg debugrevspec -p analyzed 'tip#rel[0]'
565 565 * analyzed:
566 566 (relsubscript
567 567 (symbol 'tip')
568 568 (symbol 'rel')
569 569 (symbol '0'))
570 570 hg: parse error: unknown identifier: rel
571 571 [255]
572 572
573 573 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
574 574 * analyzed:
575 575 (subscript
576 576 (relation
577 577 (symbol 'tip')
578 578 (symbol 'rel'))
579 579 (symbol '0'))
580 580 hg: parse error: can't use a subscript in this context
581 581 [255]
582 582
583 583 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
584 584 * analyzed:
585 585 (subscript
586 586 (relsubscript
587 587 (symbol 'tip')
588 588 (symbol 'rel')
589 589 (symbol '0'))
590 590 (symbol '1'))
591 591 hg: parse error: can't use a subscript in this context
592 592 [255]
593 593
594 594 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
595 595 * analyzed:
596 596 (relsubscript
597 597 (relation
598 598 (symbol 'tip')
599 599 (symbol 'rel0'))
600 600 (symbol 'rel1')
601 601 (symbol '1'))
602 602 hg: parse error: unknown identifier: rel1
603 603 [255]
604 604
605 605 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
606 606 * analyzed:
607 607 (relsubscript
608 608 (relsubscript
609 609 (symbol 'tip')
610 610 (symbol 'rel0')
611 611 (symbol '0'))
612 612 (symbol 'rel1')
613 613 (symbol '1'))
614 614 hg: parse error: unknown identifier: rel1
615 615 [255]
616 616
617 617 parse errors of relation, subscript and relation-subscript operators:
618 618
619 619 $ hg debugrevspec '[0]'
620 620 hg: parse error at 0: not a prefix: [
621 621 ([0]
622 622 ^ here)
623 623 [255]
624 624 $ hg debugrevspec '.#'
625 625 hg: parse error at 2: not a prefix: end
626 626 (.#
627 627 ^ here)
628 628 [255]
629 629 $ hg debugrevspec '#rel'
630 630 hg: parse error at 0: not a prefix: #
631 631 (#rel
632 632 ^ here)
633 633 [255]
634 634 $ hg debugrevspec '.#rel[0'
635 635 hg: parse error at 7: unexpected token: end
636 636 (.#rel[0
637 637 ^ here)
638 638 [255]
639 639 $ hg debugrevspec '.]'
640 640 hg: parse error at 1: invalid token
641 641 (.]
642 642 ^ here)
643 643 [255]
644 644
645 645 $ hg debugrevspec '.#generations[a]'
646 646 hg: parse error: relation subscript must be an integer
647 647 [255]
648 648 $ hg debugrevspec '.#generations[1-2]'
649 649 hg: parse error: relation subscript must be an integer
650 650 [255]
651 651
652 652 parsed tree at stages:
653 653
654 654 $ hg debugrevspec -p all '()'
655 655 * parsed:
656 656 (group
657 657 None)
658 658 * expanded:
659 659 (group
660 660 None)
661 661 * concatenated:
662 662 (group
663 663 None)
664 664 * analyzed:
665 665 None
666 666 * optimized:
667 667 None
668 668 hg: parse error: missing argument
669 669 [255]
670 670
671 671 $ hg debugrevspec --no-optimized -p all '()'
672 672 * parsed:
673 673 (group
674 674 None)
675 675 * expanded:
676 676 (group
677 677 None)
678 678 * concatenated:
679 679 (group
680 680 None)
681 681 * analyzed:
682 682 None
683 683 hg: parse error: missing argument
684 684 [255]
685 685
686 686 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
687 687 * parsed:
688 688 (minus
689 689 (group
690 690 (or
691 691 (list
692 692 (symbol '0')
693 693 (symbol '1'))))
694 694 (symbol '1'))
695 695 * analyzed:
696 696 (and
697 697 (or
698 698 (list
699 699 (symbol '0')
700 700 (symbol '1')))
701 701 (not
702 702 (symbol '1')))
703 703 * optimized:
704 704 (difference
705 705 (func
706 706 (symbol '_list')
707 707 (string '0\x001'))
708 708 (symbol '1'))
709 709 0
710 710
711 711 $ hg debugrevspec -p unknown '0'
712 712 abort: invalid stage name: unknown
713 713 [255]
714 714
715 715 $ hg debugrevspec -p all --optimize '0'
716 716 abort: cannot use --optimize with --show-stage
717 717 [255]
718 718
719 719 verify optimized tree:
720 720
721 721 $ hg debugrevspec --verify '0|1'
722 722
723 723 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
724 724 * analyzed:
725 725 (and
726 726 (func
727 727 (symbol 'r3232')
728 728 None)
729 729 (symbol '2'))
730 730 * optimized:
731 731 (andsmally
732 732 (func
733 733 (symbol 'r3232')
734 734 None)
735 735 (symbol '2'))
736 736 * analyzed set:
737 737 <baseset [2]>
738 738 * optimized set:
739 739 <baseset [2, 2]>
740 740 --- analyzed
741 741 +++ optimized
742 742 2
743 743 +2
744 744 [1]
745 745
746 746 $ hg debugrevspec --no-optimized --verify-optimized '0'
747 747 abort: cannot use --verify-optimized with --no-optimized
748 748 [255]
749 749
750 750 Test that symbols only get parsed as functions if there's an opening
751 751 parenthesis.
752 752
753 753 $ hg book only -r 9
754 754 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
755 755 8
756 756 9
757 757
758 758 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
759 759 may be hidden (issue5385)
760 760
761 761 $ try -p parsed -p analyzed ':'
762 762 * parsed:
763 763 (rangeall
764 764 None)
765 765 * analyzed:
766 766 (rangeall
767 767 None)
768 768 * set:
769 769 <spanset+ 0:10>
770 770 0
771 771 1
772 772 2
773 773 3
774 774 4
775 775 5
776 776 6
777 777 7
778 778 8
779 779 9
780 780 $ try -p analyzed ':1'
781 781 * analyzed:
782 782 (rangepre
783 783 (symbol '1'))
784 784 * set:
785 785 <spanset+ 0:2>
786 786 0
787 787 1
788 788 $ try -p analyzed ':(1|2)'
789 789 * analyzed:
790 790 (rangepre
791 791 (or
792 792 (list
793 793 (symbol '1')
794 794 (symbol '2'))))
795 795 * set:
796 796 <spanset+ 0:3>
797 797 0
798 798 1
799 799 2
800 800 $ try -p analyzed ':(1&2)'
801 801 * analyzed:
802 802 (rangepre
803 803 (and
804 804 (symbol '1')
805 805 (symbol '2')))
806 806 * set:
807 807 <baseset []>
808 808
809 809 infix/suffix resolution of ^ operator (issue2884, issue5764):
810 810
811 811 x^:y means (x^):y
812 812
813 813 $ try '1^:2'
814 814 (range
815 815 (parentpost
816 816 (symbol '1'))
817 817 (symbol '2'))
818 818 * set:
819 819 <spanset+ 0:3>
820 820 0
821 821 1
822 822 2
823 823
824 824 $ try '1^::2'
825 825 (dagrange
826 826 (parentpost
827 827 (symbol '1'))
828 828 (symbol '2'))
829 829 * set:
830 830 <baseset+ [0, 1, 2]>
831 831 0
832 832 1
833 833 2
834 834
835 835 $ try '1^..2'
836 836 (dagrange
837 837 (parentpost
838 838 (symbol '1'))
839 839 (symbol '2'))
840 840 * set:
841 841 <baseset+ [0, 1, 2]>
842 842 0
843 843 1
844 844 2
845 845
846 846 $ try '9^:'
847 847 (rangepost
848 848 (parentpost
849 849 (symbol '9')))
850 850 * set:
851 851 <spanset+ 8:10>
852 852 8
853 853 9
854 854
855 855 $ try '9^::'
856 856 (dagrangepost
857 857 (parentpost
858 858 (symbol '9')))
859 859 * set:
860 860 <generatorsetasc+>
861 861 8
862 862 9
863 863
864 864 $ try '9^..'
865 865 (dagrangepost
866 866 (parentpost
867 867 (symbol '9')))
868 868 * set:
869 869 <generatorsetasc+>
870 870 8
871 871 9
872 872
873 873 x^:y should be resolved before omitting group operators
874 874
875 875 $ try '1^(:2)'
876 876 (parent
877 877 (symbol '1')
878 878 (group
879 879 (rangepre
880 880 (symbol '2'))))
881 881 hg: parse error: ^ expects a number 0, 1, or 2
882 882 [255]
883 883
884 884 x^:y should be resolved recursively
885 885
886 886 $ try 'sort(1^:2)'
887 887 (func
888 888 (symbol 'sort')
889 889 (range
890 890 (parentpost
891 891 (symbol '1'))
892 892 (symbol '2')))
893 893 * set:
894 894 <spanset+ 0:3>
895 895 0
896 896 1
897 897 2
898 898
899 899 $ try '(3^:4)^:2'
900 900 (range
901 901 (parentpost
902 902 (group
903 903 (range
904 904 (parentpost
905 905 (symbol '3'))
906 906 (symbol '4'))))
907 907 (symbol '2'))
908 908 * set:
909 909 <spanset+ 0:3>
910 910 0
911 911 1
912 912 2
913 913
914 914 $ try '(3^::4)^::2'
915 915 (dagrange
916 916 (parentpost
917 917 (group
918 918 (dagrange
919 919 (parentpost
920 920 (symbol '3'))
921 921 (symbol '4'))))
922 922 (symbol '2'))
923 923 * set:
924 924 <baseset+ [0, 1, 2]>
925 925 0
926 926 1
927 927 2
928 928
929 929 $ try '(9^:)^:'
930 930 (rangepost
931 931 (parentpost
932 932 (group
933 933 (rangepost
934 934 (parentpost
935 935 (symbol '9'))))))
936 936 * set:
937 937 <spanset+ 4:10>
938 938 4
939 939 5
940 940 6
941 941 7
942 942 8
943 943 9
944 944
945 945 x^ in alias should also be resolved
946 946
947 947 $ try 'A' --config 'revsetalias.A=1^:2'
948 948 (symbol 'A')
949 949 * expanded:
950 950 (range
951 951 (parentpost
952 952 (symbol '1'))
953 953 (symbol '2'))
954 954 * set:
955 955 <spanset+ 0:3>
956 956 0
957 957 1
958 958 2
959 959
960 960 $ try 'A:2' --config 'revsetalias.A=1^'
961 961 (range
962 962 (symbol 'A')
963 963 (symbol '2'))
964 964 * expanded:
965 965 (range
966 966 (parentpost
967 967 (symbol '1'))
968 968 (symbol '2'))
969 969 * set:
970 970 <spanset+ 0:3>
971 971 0
972 972 1
973 973 2
974 974
975 975 but not beyond the boundary of alias expansion, because the resolution should
976 976 be made at the parsing stage
977 977
978 978 $ try '1^A' --config 'revsetalias.A=:2'
979 979 (parent
980 980 (symbol '1')
981 981 (symbol 'A'))
982 982 * expanded:
983 983 (parent
984 984 (symbol '1')
985 985 (rangepre
986 986 (symbol '2')))
987 987 hg: parse error: ^ expects a number 0, 1, or 2
988 988 [255]
989 989
990 990 '::' itself isn't a valid expression
991 991
992 992 $ try '::'
993 993 (dagrangeall
994 994 None)
995 995 hg: parse error: can't use '::' in this context
996 996 [255]
997 997
998 998 ancestor can accept 0 or more arguments
999 999
1000 1000 $ log 'ancestor()'
1001 1001 $ log 'ancestor(1)'
1002 1002 1
1003 1003 $ log 'ancestor(4,5)'
1004 1004 1
1005 1005 $ log 'ancestor(4,5) and 4'
1006 1006 $ log 'ancestor(0,0,1,3)'
1007 1007 0
1008 1008 $ log 'ancestor(3,1,5,3,5,1)'
1009 1009 1
1010 1010 $ log 'ancestor(0,1,3,5)'
1011 1011 0
1012 1012 $ log 'ancestor(1,2,3,4,5)'
1013 1013 1
1014 1014
1015 1015 test ancestors
1016 1016
1017 1017 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1018 1018 @ 9
1019 1019 o 8
1020 1020 | o 7
1021 1021 | o 6
1022 1022 |/|
1023 1023 | o 5
1024 1024 o | 4
1025 1025 | o 3
1026 1026 o | 2
1027 1027 |/
1028 1028 o 1
1029 1029 o 0
1030 1030
1031 1031 $ log 'ancestors(5)'
1032 1032 0
1033 1033 1
1034 1034 3
1035 1035 5
1036 1036 $ log 'ancestor(ancestors(5))'
1037 1037 0
1038 1038 $ log '::r3232()'
1039 1039 0
1040 1040 1
1041 1041 2
1042 1042 3
1043 1043
1044 1044 test ancestors with depth limit
1045 1045
1046 1046 (depth=0 selects the node itself)
1047 1047
1048 1048 $ log 'reverse(ancestors(9, depth=0))'
1049 1049 9
1050 1050
1051 1051 (interleaved: '4' would be missing if heap queue were higher depth first)
1052 1052
1053 1053 $ log 'reverse(ancestors(8:9, depth=1))'
1054 1054 9
1055 1055 8
1056 1056 4
1057 1057
1058 1058 (interleaved: '2' would be missing if heap queue were higher depth first)
1059 1059
1060 1060 $ log 'reverse(ancestors(7+8, depth=2))'
1061 1061 8
1062 1062 7
1063 1063 6
1064 1064 5
1065 1065 4
1066 1066 2
1067 1067
1068 1068 (walk example above by separate queries)
1069 1069
1070 1070 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1071 1071 8
1072 1072 4
1073 1073 2
1074 1074 7
1075 1075 6
1076 1076 5
1077 1077
1078 1078 (walk 2nd and 3rd ancestors)
1079 1079
1080 1080 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1081 1081 5
1082 1082 4
1083 1083 3
1084 1084 2
1085 1085
1086 1086 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1087 1087
1088 1088 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1089 1089 5
1090 1090 4
1091 1091 2
1092 1092
1093 1093 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1094 1094 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1095 1095 multiple depths)
1096 1096
1097 1097 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1098 1098 5
1099 1099 2
1100 1100
1101 1101 test bad arguments passed to ancestors()
1102 1102
1103 1103 $ log 'ancestors(., depth=-1)'
1104 1104 hg: parse error: negative depth
1105 1105 [255]
1106 1106 $ log 'ancestors(., depth=foo)'
1107 1107 hg: parse error: ancestors expects an integer depth
1108 1108 [255]
1109 1109
1110 1110 test descendants
1111 1111
1112 1112 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1113 1113 @ 9
1114 1114 o 8
1115 1115 | o 7
1116 1116 | o 6
1117 1117 |/|
1118 1118 | o 5
1119 1119 o | 4
1120 1120 | o 3
1121 1121 o | 2
1122 1122 |/
1123 1123 o 1
1124 1124 o 0
1125 1125
1126 1126 (null is ultimate root and has optimized path)
1127 1127
1128 1128 $ log 'null:4 & descendants(null)'
1129 1129 -1
1130 1130 0
1131 1131 1
1132 1132 2
1133 1133 3
1134 1134 4
1135 1135
1136 1136 (including merge)
1137 1137
1138 1138 $ log ':8 & descendants(2)'
1139 1139 2
1140 1140 4
1141 1141 6
1142 1142 7
1143 1143 8
1144 1144
1145 1145 (multiple roots)
1146 1146
1147 1147 $ log ':8 & descendants(2+5)'
1148 1148 2
1149 1149 4
1150 1150 5
1151 1151 6
1152 1152 7
1153 1153 8
1154 1154
1155 1155 test descendants with depth limit
1156 1156
1157 1157 (depth=0 selects the node itself)
1158 1158
1159 1159 $ log 'descendants(0, depth=0)'
1160 1160 0
1161 1161 $ log 'null: & descendants(null, depth=0)'
1162 1162 -1
1163 1163
1164 1164 (p2 = null should be ignored)
1165 1165
1166 1166 $ log 'null: & descendants(null, depth=2)'
1167 1167 -1
1168 1168 0
1169 1169 1
1170 1170
1171 1171 (multiple paths: depth(6) = (2, 3))
1172 1172
1173 1173 $ log 'descendants(1+3, depth=2)'
1174 1174 1
1175 1175 2
1176 1176 3
1177 1177 4
1178 1178 5
1179 1179 6
1180 1180
1181 1181 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1182 1182
1183 1183 $ log 'descendants(3+1, depth=2, startdepth=2)'
1184 1184 4
1185 1185 5
1186 1186 6
1187 1187
1188 1188 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1189 1189
1190 1190 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1191 1191 1
1192 1192 2
1193 1193 3
1194 1194 4
1195 1195 5
1196 1196 6
1197 1197 7
1198 1198
1199 1199 (multiple depths: depth(6) = (0, 4), no match)
1200 1200
1201 1201 $ log 'descendants(0+6, depth=3, startdepth=1)'
1202 1202 1
1203 1203 2
1204 1204 3
1205 1205 4
1206 1206 5
1207 1207 7
1208 1208
1209 1209 test ancestors/descendants relation subscript:
1210 1210
1211 1211 $ log 'tip#generations[0]'
1212 1212 9
1213 1213 $ log '.#generations[-1]'
1214 1214 8
1215 1215 $ log '.#g[(-1)]'
1216 1216 8
1217 1217
1218 1218 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1219 1219 * parsed:
1220 1220 (relsubscript
1221 1221 (func
1222 1222 (symbol 'roots')
1223 1223 (rangeall
1224 1224 None))
1225 1225 (symbol 'g')
1226 1226 (symbol '2'))
1227 1227 2
1228 1228 3
1229 1229
1230 1230 test author
1231 1231
1232 1232 $ log 'author(bob)'
1233 1233 2
1234 1234 $ log 'author("re:bob|test")'
1235 1235 0
1236 1236 1
1237 1237 2
1238 1238 3
1239 1239 4
1240 1240 5
1241 1241 6
1242 1242 7
1243 1243 8
1244 1244 9
1245 1245 $ log 'author(r"re:\S")'
1246 1246 0
1247 1247 1
1248 1248 2
1249 1249 3
1250 1250 4
1251 1251 5
1252 1252 6
1253 1253 7
1254 1254 8
1255 1255 9
1256 1256 $ log 'branch(Γ©)'
1257 1257 8
1258 1258 9
1259 1259 $ log 'branch(a)'
1260 1260 0
1261 1261 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1262 1262 0 a
1263 1263 2 a-b-c-
1264 1264 3 +a+b+c+
1265 1265 4 -a-b-c-
1266 1266 5 !a/b/c/
1267 1267 6 _a_b_c_
1268 1268 7 .a.b.c.
1269 1269 $ log 'children(ancestor(4,5))'
1270 1270 2
1271 1271 3
1272 1272
1273 1273 $ log 'children(4)'
1274 1274 6
1275 1275 8
1276 1276 $ log 'children(null)'
1277 1277 0
1278 1278
1279 1279 $ log 'closed()'
1280 1280 $ log 'contains(a)'
1281 1281 0
1282 1282 1
1283 1283 3
1284 1284 5
1285 1285 $ log 'contains("../repo/a")'
1286 1286 0
1287 1287 1
1288 1288 3
1289 1289 5
1290 1290 $ log 'desc(B)'
1291 1291 5
1292 1292 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1293 1293 5 5 bug
1294 1294 6 6 issue619
1295 1295 $ log 'descendants(2 or 3)'
1296 1296 2
1297 1297 3
1298 1298 4
1299 1299 5
1300 1300 6
1301 1301 7
1302 1302 8
1303 1303 9
1304 1304 $ log 'file("b*")'
1305 1305 1
1306 1306 4
1307 1307 $ log 'filelog("b")'
1308 1308 1
1309 1309 4
1310 1310 $ log 'filelog("../repo/b")'
1311 1311 1
1312 1312 4
1313 1313 $ log 'follow()'
1314 1314 0
1315 1315 1
1316 1316 2
1317 1317 4
1318 1318 8
1319 1319 9
1320 1320 $ log 'grep("issue\d+")'
1321 1321 6
1322 1322 $ try 'grep("(")' # invalid regular expression
1323 1323 (func
1324 1324 (symbol 'grep')
1325 1325 (string '('))
1326 1326 hg: parse error: invalid match pattern: (unbalanced parenthesis|missing \),.*) (re)
1327 1327 [255]
1328 1328 $ try 'grep("\bissue\d+")'
1329 1329 (func
1330 1330 (symbol 'grep')
1331 1331 (string '\x08issue\\d+'))
1332 1332 * set:
1333 1333 <filteredset
1334 1334 <fullreposet+ 0:10>,
1335 1335 <grep '\x08issue\\d+'>>
1336 1336 $ try 'grep(r"\bissue\d+")'
1337 1337 (func
1338 1338 (symbol 'grep')
1339 1339 (string '\\bissue\\d+'))
1340 1340 * set:
1341 1341 <filteredset
1342 1342 <fullreposet+ 0:10>,
1343 1343 <grep '\\bissue\\d+'>>
1344 1344 6
1345 1345 $ try 'grep(r"\")'
1346 1346 hg: parse error at 7: unterminated string
1347 1347 (grep(r"\")
1348 1348 ^ here)
1349 1349 [255]
1350 1350 $ log 'head()'
1351 1351 0
1352 1352 1
1353 1353 2
1354 1354 3
1355 1355 4
1356 1356 5
1357 1357 6
1358 1358 7
1359 1359 9
1360
1361 Test heads
1362
1360 1363 $ log 'heads(6::)'
1361 1364 7
1365
1366 heads() can be computed in subset '9:'
1367
1368 $ hg debugrevspec -s '9: & heads(all())'
1369 * set:
1370 <filteredset
1371 <filteredset
1372 <baseset [9]>,
1373 <spanset+ 0:10>>,
1374 <not
1375 <filteredset
1376 <baseset [9]>, set([0, 1, 2, 3, 4, 5, 6, 8])>>>
1377 9
1378
1379 BROKEN: but should follow the order of the subset
1380
1381 $ log 'heads(all())'
1382 7
1383 9
1384 $ log 'heads(tip:0)'
1385 9
1386 7
1387 $ log 'tip:0 & heads(all())'
1388 9
1389 7
1390 $ log 'tip:0 & heads(0:tip)'
1391 7
1392 9
1393
1362 1394 $ log 'keyword(issue)'
1363 1395 6
1364 1396 $ log 'keyword("test a")'
1365 1397
1366 1398 Test first (=limit) and last
1367 1399
1368 1400 $ log 'limit(head(), 1)'
1369 1401 0
1370 1402 $ log 'limit(author("re:bob|test"), 3, 5)'
1371 1403 5
1372 1404 6
1373 1405 7
1374 1406 $ log 'limit(author("re:bob|test"), offset=6)'
1375 1407 6
1376 1408 $ log 'limit(author("re:bob|test"), offset=10)'
1377 1409 $ log 'limit(all(), 1, -1)'
1378 1410 hg: parse error: negative offset
1379 1411 [255]
1380 1412 $ log 'limit(all(), -1)'
1381 1413 hg: parse error: negative number to select
1382 1414 [255]
1383 1415 $ log 'limit(all(), 0)'
1384 1416
1385 1417 $ log 'last(all(), -1)'
1386 1418 hg: parse error: negative number to select
1387 1419 [255]
1388 1420 $ log 'last(all(), 0)'
1389 1421 $ log 'last(all(), 1)'
1390 1422 9
1391 1423 $ log 'last(all(), 2)'
1392 1424 8
1393 1425 9
1394 1426
1395 1427 Test smartset.slice() by first/last()
1396 1428
1397 1429 (using unoptimized set, filteredset as example)
1398 1430
1399 1431 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1400 1432 * set:
1401 1433 <filteredset
1402 1434 <spanset+ 0:8>,
1403 1435 <branch 're:'>>
1404 1436 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1405 1437 4
1406 1438 5
1407 1439 6
1408 1440 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1409 1441 3
1410 1442 2
1411 1443 1
1412 1444 $ log 'last(0:7 & branch("re:"), 2)'
1413 1445 6
1414 1446 7
1415 1447
1416 1448 (using baseset)
1417 1449
1418 1450 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1419 1451 * set:
1420 1452 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1421 1453 $ hg debugrevspec --no-show-revs -s 0::7
1422 1454 * set:
1423 1455 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1424 1456 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1425 1457 4
1426 1458 5
1427 1459 6
1428 1460 $ log 'limit(sort(0::7, rev), 3, 4)'
1429 1461 4
1430 1462 5
1431 1463 6
1432 1464 $ log 'limit(sort(0::7, -rev), 3, 4)'
1433 1465 3
1434 1466 2
1435 1467 1
1436 1468 $ log 'last(sort(0::7, rev), 2)'
1437 1469 6
1438 1470 7
1439 1471 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1440 1472 * set:
1441 1473 <baseset+ [6, 7]>
1442 1474 6
1443 1475 7
1444 1476 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1445 1477 * set:
1446 1478 <baseset+ []>
1447 1479 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1448 1480 * set:
1449 1481 <baseset- [0, 1]>
1450 1482 1
1451 1483 0
1452 1484 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1453 1485 * set:
1454 1486 <baseset- []>
1455 1487 $ hg debugrevspec -s 'limit(0::7, 0)'
1456 1488 * set:
1457 1489 <baseset+ []>
1458 1490
1459 1491 (using spanset)
1460 1492
1461 1493 $ hg debugrevspec --no-show-revs -s 0:7
1462 1494 * set:
1463 1495 <spanset+ 0:8>
1464 1496 $ log 'limit(0:7, 3, 4)'
1465 1497 4
1466 1498 5
1467 1499 6
1468 1500 $ log 'limit(7:0, 3, 4)'
1469 1501 3
1470 1502 2
1471 1503 1
1472 1504 $ log 'limit(0:7, 3, 6)'
1473 1505 6
1474 1506 7
1475 1507 $ log 'limit(7:0, 3, 6)'
1476 1508 1
1477 1509 0
1478 1510 $ log 'last(0:7, 2)'
1479 1511 6
1480 1512 7
1481 1513 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1482 1514 * set:
1483 1515 <spanset+ 6:8>
1484 1516 6
1485 1517 7
1486 1518 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1487 1519 * set:
1488 1520 <spanset+ 8:8>
1489 1521 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1490 1522 * set:
1491 1523 <spanset- 0:2>
1492 1524 1
1493 1525 0
1494 1526 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1495 1527 * set:
1496 1528 <spanset- 0:0>
1497 1529 $ hg debugrevspec -s 'limit(0:7, 0)'
1498 1530 * set:
1499 1531 <spanset+ 0:0>
1500 1532
1501 1533 Test order of first/last revisions
1502 1534
1503 1535 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1504 1536 * set:
1505 1537 <filteredset
1506 1538 <spanset- 2:5>,
1507 1539 <spanset+ 3:10>>
1508 1540 4
1509 1541 3
1510 1542
1511 1543 $ hg debugrevspec -s '3: & first(4:0, 3)'
1512 1544 * set:
1513 1545 <filteredset
1514 1546 <spanset+ 3:10>,
1515 1547 <spanset- 2:5>>
1516 1548 3
1517 1549 4
1518 1550
1519 1551 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1520 1552 * set:
1521 1553 <filteredset
1522 1554 <spanset- 0:3>,
1523 1555 <spanset+ 0:2>>
1524 1556 1
1525 1557 0
1526 1558
1527 1559 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1528 1560 * set:
1529 1561 <filteredset
1530 1562 <spanset+ 0:2>,
1531 1563 <spanset+ 0:3>>
1532 1564 0
1533 1565 1
1534 1566
1535 1567 Test scmutil.revsingle() should return the last revision
1536 1568
1537 1569 $ hg debugrevspec -s 'last(0::)'
1538 1570 * set:
1539 1571 <baseset slice=0:1
1540 1572 <generatorsetasc->>
1541 1573 9
1542 1574 $ hg identify -r '0::' --num
1543 1575 9
1544 1576
1545 1577 Test matching
1546 1578
1547 1579 $ log 'matching(6)'
1548 1580 6
1549 1581 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1550 1582 6
1551 1583 7
1552 1584
1553 1585 Testing min and max
1554 1586
1555 1587 max: simple
1556 1588
1557 1589 $ log 'max(contains(a))'
1558 1590 5
1559 1591
1560 1592 max: simple on unordered set)
1561 1593
1562 1594 $ log 'max((4+0+2+5+7) and contains(a))'
1563 1595 5
1564 1596
1565 1597 max: no result
1566 1598
1567 1599 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1568 1600
1569 1601 max: no result on unordered set
1570 1602
1571 1603 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1572 1604
1573 1605 min: simple
1574 1606
1575 1607 $ log 'min(contains(a))'
1576 1608 0
1577 1609
1578 1610 min: simple on unordered set
1579 1611
1580 1612 $ log 'min((4+0+2+5+7) and contains(a))'
1581 1613 0
1582 1614
1583 1615 min: empty
1584 1616
1585 1617 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1586 1618
1587 1619 min: empty on unordered set
1588 1620
1589 1621 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1590 1622
1591 1623
1592 1624 $ log 'merge()'
1593 1625 6
1594 1626 $ log 'branchpoint()'
1595 1627 1
1596 1628 4
1597 1629 $ log 'modifies(b)'
1598 1630 4
1599 1631 $ log 'modifies("path:b")'
1600 1632 4
1601 1633 $ log 'modifies("*")'
1602 1634 4
1603 1635 6
1604 1636 $ log 'modifies("set:modified()")'
1605 1637 4
1606 1638 $ log 'id(5)'
1607 1639 2
1608 1640 $ log 'only(9)'
1609 1641 8
1610 1642 9
1611 1643 $ log 'only(8)'
1612 1644 8
1613 1645 $ log 'only(9, 5)'
1614 1646 2
1615 1647 4
1616 1648 8
1617 1649 9
1618 1650 $ log 'only(7 + 9, 5 + 2)'
1619 1651 4
1620 1652 6
1621 1653 7
1622 1654 8
1623 1655 9
1624 1656
1625 1657 Test empty set input
1626 1658 $ log 'only(p2())'
1627 1659 $ log 'only(p1(), p2())'
1628 1660 0
1629 1661 1
1630 1662 2
1631 1663 4
1632 1664 8
1633 1665 9
1634 1666
1635 1667 Test '%' operator
1636 1668
1637 1669 $ log '9%'
1638 1670 8
1639 1671 9
1640 1672 $ log '9%5'
1641 1673 2
1642 1674 4
1643 1675 8
1644 1676 9
1645 1677 $ log '(7 + 9)%(5 + 2)'
1646 1678 4
1647 1679 6
1648 1680 7
1649 1681 8
1650 1682 9
1651 1683
1652 1684 Test operand of '%' is optimized recursively (issue4670)
1653 1685
1654 1686 $ try --optimize '8:9-8%'
1655 1687 (onlypost
1656 1688 (minus
1657 1689 (range
1658 1690 (symbol '8')
1659 1691 (symbol '9'))
1660 1692 (symbol '8')))
1661 1693 * optimized:
1662 1694 (func
1663 1695 (symbol 'only')
1664 1696 (difference
1665 1697 (range
1666 1698 (symbol '8')
1667 1699 (symbol '9'))
1668 1700 (symbol '8')))
1669 1701 * set:
1670 1702 <baseset+ [8, 9]>
1671 1703 8
1672 1704 9
1673 1705 $ try --optimize '(9)%(5)'
1674 1706 (only
1675 1707 (group
1676 1708 (symbol '9'))
1677 1709 (group
1678 1710 (symbol '5')))
1679 1711 * optimized:
1680 1712 (func
1681 1713 (symbol 'only')
1682 1714 (list
1683 1715 (symbol '9')
1684 1716 (symbol '5')))
1685 1717 * set:
1686 1718 <baseset+ [2, 4, 8, 9]>
1687 1719 2
1688 1720 4
1689 1721 8
1690 1722 9
1691 1723
1692 1724 Test the order of operations
1693 1725
1694 1726 $ log '7 + 9%5 + 2'
1695 1727 7
1696 1728 2
1697 1729 4
1698 1730 8
1699 1731 9
1700 1732
1701 1733 Test explicit numeric revision
1702 1734 $ log 'rev(-2)'
1703 1735 $ log 'rev(-1)'
1704 1736 -1
1705 1737 $ log 'rev(0)'
1706 1738 0
1707 1739 $ log 'rev(9)'
1708 1740 9
1709 1741 $ log 'rev(10)'
1710 1742 $ log 'rev(tip)'
1711 1743 hg: parse error: rev expects a number
1712 1744 [255]
1713 1745
1714 1746 Test hexadecimal revision
1715 1747 $ log 'id(2)'
1716 1748 $ log 'id(23268)'
1717 1749 4
1718 1750 $ log 'id(2785f51eece)'
1719 1751 0
1720 1752 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1721 1753 8
1722 1754 $ log 'id(d5d0dcbdc4a)'
1723 1755 $ log 'id(d5d0dcbdc4w)'
1724 1756 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1725 1757 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1726 1758 $ log 'id(1.0)'
1727 1759 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1728 1760
1729 1761 Test null revision
1730 1762 $ log '(null)'
1731 1763 -1
1732 1764 $ log '(null:0)'
1733 1765 -1
1734 1766 0
1735 1767 $ log '(0:null)'
1736 1768 0
1737 1769 -1
1738 1770 $ log 'null::0'
1739 1771 -1
1740 1772 0
1741 1773 $ log 'null:tip - 0:'
1742 1774 -1
1743 1775 $ log 'null: and null::' | head -1
1744 1776 -1
1745 1777 $ log 'null: or 0:' | head -2
1746 1778 -1
1747 1779 0
1748 1780 $ log 'ancestors(null)'
1749 1781 -1
1750 1782 $ log 'reverse(null:)' | tail -2
1751 1783 0
1752 1784 -1
1753 1785 $ log 'first(null:)'
1754 1786 -1
1755 1787 $ log 'min(null:)'
1756 1788 BROKEN: should be '-1'
1757 1789 $ log 'tip:null and all()' | tail -2
1758 1790 1
1759 1791 0
1760 1792
1761 1793 Test working-directory revision
1762 1794 $ hg debugrevspec 'wdir()'
1763 1795 2147483647
1764 1796 $ hg debugrevspec 'wdir()^'
1765 1797 9
1766 1798 $ hg up 7
1767 1799 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1768 1800 $ hg debugrevspec 'wdir()^'
1769 1801 7
1770 1802 $ hg debugrevspec 'wdir()^0'
1771 1803 2147483647
1772 1804 $ hg debugrevspec 'wdir()~3'
1773 1805 5
1774 1806 $ hg debugrevspec 'ancestors(wdir())'
1775 1807 0
1776 1808 1
1777 1809 2
1778 1810 3
1779 1811 4
1780 1812 5
1781 1813 6
1782 1814 7
1783 1815 2147483647
1784 1816 $ hg debugrevspec 'wdir()~0'
1785 1817 2147483647
1786 1818 $ hg debugrevspec 'p1(wdir())'
1787 1819 7
1788 1820 $ hg debugrevspec 'p2(wdir())'
1789 1821 $ hg debugrevspec 'parents(wdir())'
1790 1822 7
1791 1823 $ hg debugrevspec 'wdir()^1'
1792 1824 7
1793 1825 $ hg debugrevspec 'wdir()^2'
1794 1826 $ hg debugrevspec 'wdir()^3'
1795 1827 hg: parse error: ^ expects a number 0, 1, or 2
1796 1828 [255]
1797 1829 For tests consistency
1798 1830 $ hg up 9
1799 1831 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1800 1832 $ hg debugrevspec 'tip or wdir()'
1801 1833 9
1802 1834 2147483647
1803 1835 $ hg debugrevspec '0:tip and wdir()'
1804 1836 $ log '0:wdir()' | tail -3
1805 1837 8
1806 1838 9
1807 1839 2147483647
1808 1840 $ log 'wdir():0' | head -3
1809 1841 2147483647
1810 1842 9
1811 1843 8
1812 1844 $ log 'wdir():wdir()'
1813 1845 2147483647
1814 1846 $ log '(all() + wdir()) & min(. + wdir())'
1815 1847 9
1816 1848 $ log '(all() + wdir()) & max(. + wdir())'
1817 1849 2147483647
1818 1850 $ log 'first(wdir() + .)'
1819 1851 2147483647
1820 1852 $ log 'last(. + wdir())'
1821 1853 2147483647
1822 1854
1823 1855 Test working-directory integer revision and node id
1824 1856 (BUG: '0:wdir()' is still needed to populate wdir revision)
1825 1857
1826 1858 $ hg debugrevspec '0:wdir() & 2147483647'
1827 1859 2147483647
1828 1860 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1829 1861 2147483647
1830 1862 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1831 1863 2147483647
1832 1864 $ hg debugrevspec '0:wdir() & ffffffffffff'
1833 1865 2147483647
1834 1866 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1835 1867 2147483647
1836 1868 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1837 1869 2147483647
1838 1870
1839 1871 $ cd ..
1840 1872
1841 1873 Test short 'ff...' hash collision
1842 1874 (BUG: '0:wdir()' is still needed to populate wdir revision)
1843 1875
1844 1876 $ hg init wdir-hashcollision
1845 1877 $ cd wdir-hashcollision
1846 1878 $ cat <<EOF >> .hg/hgrc
1847 1879 > [experimental]
1848 1880 > evolution.createmarkers=True
1849 1881 > EOF
1850 1882 $ echo 0 > a
1851 1883 $ hg ci -qAm 0
1852 1884 $ for i in 2463 2961 6726 78127; do
1853 1885 > hg up -q 0
1854 1886 > echo $i > a
1855 1887 > hg ci -qm $i
1856 1888 > done
1857 1889 $ hg up -q null
1858 1890 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1859 1891 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1860 1892 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1861 1893 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1862 1894 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1863 1895 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1864 1896 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
1865 1897 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
1866 1898 obsoleted 1 changesets
1867 1899
1868 1900 $ hg debugrevspec '0:wdir() & fff'
1869 1901 abort: 00changelog.i@fff: ambiguous identifier!
1870 1902 [255]
1871 1903 $ hg debugrevspec '0:wdir() & ffff'
1872 1904 abort: 00changelog.i@ffff: ambiguous identifier!
1873 1905 [255]
1874 1906 $ hg debugrevspec '0:wdir() & fffb'
1875 1907 abort: 00changelog.i@fffb: ambiguous identifier!
1876 1908 [255]
1877 1909 BROKEN should be '2' (node lookup uses unfiltered repo)
1878 1910 $ hg debugrevspec '0:wdir() & id(fffb)'
1879 1911 BROKEN should be '2' (node lookup uses unfiltered repo)
1880 1912 $ hg debugrevspec '0:wdir() & ffff8'
1881 1913 4
1882 1914 $ hg debugrevspec '0:wdir() & fffff'
1883 1915 2147483647
1884 1916
1885 1917 $ cd ..
1886 1918
1887 1919 Test branch() with wdir()
1888 1920
1889 1921 $ cd repo
1890 1922
1891 1923 $ log '0:wdir() & branch("literal:Γ©")'
1892 1924 8
1893 1925 9
1894 1926 2147483647
1895 1927 $ log '0:wdir() & branch("re:Γ©")'
1896 1928 8
1897 1929 9
1898 1930 2147483647
1899 1931 $ log '0:wdir() & branch("re:^a")'
1900 1932 0
1901 1933 2
1902 1934 $ log '0:wdir() & branch(8)'
1903 1935 8
1904 1936 9
1905 1937 2147483647
1906 1938
1907 1939 branch(wdir()) returns all revisions belonging to the working branch. The wdir
1908 1940 itself isn't returned unless it is explicitly populated.
1909 1941
1910 1942 $ log 'branch(wdir())'
1911 1943 8
1912 1944 9
1913 1945 $ log '0:wdir() & branch(wdir())'
1914 1946 8
1915 1947 9
1916 1948 2147483647
1917 1949
1918 1950 $ log 'outgoing()'
1919 1951 8
1920 1952 9
1921 1953 $ log 'outgoing("../remote1")'
1922 1954 8
1923 1955 9
1924 1956 $ log 'outgoing("../remote2")'
1925 1957 3
1926 1958 5
1927 1959 6
1928 1960 7
1929 1961 9
1930 1962 $ log 'p1(merge())'
1931 1963 5
1932 1964 $ log 'p2(merge())'
1933 1965 4
1934 1966 $ log 'parents(merge())'
1935 1967 4
1936 1968 5
1937 1969 $ log 'p1(branchpoint())'
1938 1970 0
1939 1971 2
1940 1972 $ log 'p2(branchpoint())'
1941 1973 $ log 'parents(branchpoint())'
1942 1974 0
1943 1975 2
1944 1976 $ log 'removes(a)'
1945 1977 2
1946 1978 6
1947 1979 $ log 'roots(all())'
1948 1980 0
1949 1981 $ log 'reverse(2 or 3 or 4 or 5)'
1950 1982 5
1951 1983 4
1952 1984 3
1953 1985 2
1954 1986 $ log 'reverse(all())'
1955 1987 9
1956 1988 8
1957 1989 7
1958 1990 6
1959 1991 5
1960 1992 4
1961 1993 3
1962 1994 2
1963 1995 1
1964 1996 0
1965 1997 $ log 'reverse(all()) & filelog(b)'
1966 1998 4
1967 1999 1
1968 2000 $ log 'rev(5)'
1969 2001 5
1970 2002 $ log 'sort(limit(reverse(all()), 3))'
1971 2003 7
1972 2004 8
1973 2005 9
1974 2006 $ log 'sort(2 or 3 or 4 or 5, date)'
1975 2007 2
1976 2008 3
1977 2009 5
1978 2010 4
1979 2011 $ log 'tagged()'
1980 2012 6
1981 2013 $ log 'tag()'
1982 2014 6
1983 2015 $ log 'tag(1.0)'
1984 2016 6
1985 2017 $ log 'tag(tip)'
1986 2018 9
1987 2019
1988 2020 Test order of revisions in compound expression
1989 2021 ----------------------------------------------
1990 2022
1991 2023 The general rule is that only the outermost (= leftmost) predicate can
1992 2024 enforce its ordering requirement. The other predicates should take the
1993 2025 ordering defined by it.
1994 2026
1995 2027 'A & B' should follow the order of 'A':
1996 2028
1997 2029 $ log '2:0 & 0::2'
1998 2030 2
1999 2031 1
2000 2032 0
2001 2033
2002 2034 'head()' combines sets in right order:
2003 2035
2004 2036 $ log '2:0 & head()'
2005 2037 2
2006 2038 1
2007 2039 0
2008 2040
2009 2041 'x:y' takes ordering parameter into account:
2010 2042
2011 2043 $ try -p optimized '3:0 & 0:3 & not 2:1'
2012 2044 * optimized:
2013 2045 (difference
2014 2046 (and
2015 2047 (range
2016 2048 (symbol '3')
2017 2049 (symbol '0'))
2018 2050 (range
2019 2051 (symbol '0')
2020 2052 (symbol '3')))
2021 2053 (range
2022 2054 (symbol '2')
2023 2055 (symbol '1')))
2024 2056 * set:
2025 2057 <filteredset
2026 2058 <filteredset
2027 2059 <spanset- 0:4>,
2028 2060 <spanset+ 0:4>>,
2029 2061 <not
2030 2062 <spanset+ 1:3>>>
2031 2063 3
2032 2064 0
2033 2065
2034 2066 'a + b', which is optimized to '_list(a b)', should take the ordering of
2035 2067 the left expression:
2036 2068
2037 2069 $ try --optimize '2:0 & (0 + 1 + 2)'
2038 2070 (and
2039 2071 (range
2040 2072 (symbol '2')
2041 2073 (symbol '0'))
2042 2074 (group
2043 2075 (or
2044 2076 (list
2045 2077 (symbol '0')
2046 2078 (symbol '1')
2047 2079 (symbol '2')))))
2048 2080 * optimized:
2049 2081 (and
2050 2082 (range
2051 2083 (symbol '2')
2052 2084 (symbol '0'))
2053 2085 (func
2054 2086 (symbol '_list')
2055 2087 (string '0\x001\x002')))
2056 2088 * set:
2057 2089 <filteredset
2058 2090 <spanset- 0:3>,
2059 2091 <baseset [0, 1, 2]>>
2060 2092 2
2061 2093 1
2062 2094 0
2063 2095
2064 2096 'A + B' should take the ordering of the left expression:
2065 2097
2066 2098 $ try --optimize '2:0 & (0:1 + 2)'
2067 2099 (and
2068 2100 (range
2069 2101 (symbol '2')
2070 2102 (symbol '0'))
2071 2103 (group
2072 2104 (or
2073 2105 (list
2074 2106 (range
2075 2107 (symbol '0')
2076 2108 (symbol '1'))
2077 2109 (symbol '2')))))
2078 2110 * optimized:
2079 2111 (and
2080 2112 (range
2081 2113 (symbol '2')
2082 2114 (symbol '0'))
2083 2115 (or
2084 2116 (list
2085 2117 (range
2086 2118 (symbol '0')
2087 2119 (symbol '1'))
2088 2120 (symbol '2'))))
2089 2121 * set:
2090 2122 <filteredset
2091 2123 <spanset- 0:3>,
2092 2124 <addset
2093 2125 <spanset+ 0:2>,
2094 2126 <baseset [2]>>>
2095 2127 2
2096 2128 1
2097 2129 0
2098 2130
2099 2131 '_intlist(a b)' should behave like 'a + b':
2100 2132
2101 2133 $ trylist --optimize '2:0 & %ld' 0 1 2
2102 2134 (and
2103 2135 (range
2104 2136 (symbol '2')
2105 2137 (symbol '0'))
2106 2138 (func
2107 2139 (symbol '_intlist')
2108 2140 (string '0\x001\x002')))
2109 2141 * optimized:
2110 2142 (andsmally
2111 2143 (range
2112 2144 (symbol '2')
2113 2145 (symbol '0'))
2114 2146 (func
2115 2147 (symbol '_intlist')
2116 2148 (string '0\x001\x002')))
2117 2149 * set:
2118 2150 <filteredset
2119 2151 <spanset- 0:3>,
2120 2152 <baseset+ [0, 1, 2]>>
2121 2153 2
2122 2154 1
2123 2155 0
2124 2156
2125 2157 $ trylist --optimize '%ld & 2:0' 0 2 1
2126 2158 (and
2127 2159 (func
2128 2160 (symbol '_intlist')
2129 2161 (string '0\x002\x001'))
2130 2162 (range
2131 2163 (symbol '2')
2132 2164 (symbol '0')))
2133 2165 * optimized:
2134 2166 (and
2135 2167 (func
2136 2168 (symbol '_intlist')
2137 2169 (string '0\x002\x001'))
2138 2170 (range
2139 2171 (symbol '2')
2140 2172 (symbol '0')))
2141 2173 * set:
2142 2174 <filteredset
2143 2175 <baseset [0, 2, 1]>,
2144 2176 <spanset- 0:3>>
2145 2177 0
2146 2178 2
2147 2179 1
2148 2180
2149 2181 '_hexlist(a b)' should behave like 'a + b':
2150 2182
2151 2183 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2152 2184 (and
2153 2185 (range
2154 2186 (symbol '2')
2155 2187 (symbol '0'))
2156 2188 (func
2157 2189 (symbol '_hexlist')
2158 2190 (string '*'))) (glob)
2159 2191 * optimized:
2160 2192 (and
2161 2193 (range
2162 2194 (symbol '2')
2163 2195 (symbol '0'))
2164 2196 (func
2165 2197 (symbol '_hexlist')
2166 2198 (string '*'))) (glob)
2167 2199 * set:
2168 2200 <filteredset
2169 2201 <spanset- 0:3>,
2170 2202 <baseset [0, 1, 2]>>
2171 2203 2
2172 2204 1
2173 2205 0
2174 2206
2175 2207 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2176 2208 (and
2177 2209 (func
2178 2210 (symbol '_hexlist')
2179 2211 (string '*')) (glob)
2180 2212 (range
2181 2213 (symbol '2')
2182 2214 (symbol '0')))
2183 2215 * optimized:
2184 2216 (andsmally
2185 2217 (func
2186 2218 (symbol '_hexlist')
2187 2219 (string '*')) (glob)
2188 2220 (range
2189 2221 (symbol '2')
2190 2222 (symbol '0')))
2191 2223 * set:
2192 2224 <baseset [0, 2, 1]>
2193 2225 0
2194 2226 2
2195 2227 1
2196 2228
2197 2229 '_list' should not go through the slow follow-order path if order doesn't
2198 2230 matter:
2199 2231
2200 2232 $ try -p optimized '2:0 & not (0 + 1)'
2201 2233 * optimized:
2202 2234 (difference
2203 2235 (range
2204 2236 (symbol '2')
2205 2237 (symbol '0'))
2206 2238 (func
2207 2239 (symbol '_list')
2208 2240 (string '0\x001')))
2209 2241 * set:
2210 2242 <filteredset
2211 2243 <spanset- 0:3>,
2212 2244 <not
2213 2245 <baseset [0, 1]>>>
2214 2246 2
2215 2247
2216 2248 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2217 2249 * optimized:
2218 2250 (difference
2219 2251 (range
2220 2252 (symbol '2')
2221 2253 (symbol '0'))
2222 2254 (and
2223 2255 (range
2224 2256 (symbol '0')
2225 2257 (symbol '2'))
2226 2258 (func
2227 2259 (symbol '_list')
2228 2260 (string '0\x001'))))
2229 2261 * set:
2230 2262 <filteredset
2231 2263 <spanset- 0:3>,
2232 2264 <not
2233 2265 <baseset [0, 1]>>>
2234 2266 2
2235 2267
2236 2268 because 'present()' does nothing other than suppressing an error, the
2237 2269 ordering requirement should be forwarded to the nested expression
2238 2270
2239 2271 $ try -p optimized 'present(2 + 0 + 1)'
2240 2272 * optimized:
2241 2273 (func
2242 2274 (symbol 'present')
2243 2275 (func
2244 2276 (symbol '_list')
2245 2277 (string '2\x000\x001')))
2246 2278 * set:
2247 2279 <baseset [2, 0, 1]>
2248 2280 2
2249 2281 0
2250 2282 1
2251 2283
2252 2284 $ try --optimize '2:0 & present(0 + 1 + 2)'
2253 2285 (and
2254 2286 (range
2255 2287 (symbol '2')
2256 2288 (symbol '0'))
2257 2289 (func
2258 2290 (symbol 'present')
2259 2291 (or
2260 2292 (list
2261 2293 (symbol '0')
2262 2294 (symbol '1')
2263 2295 (symbol '2')))))
2264 2296 * optimized:
2265 2297 (and
2266 2298 (range
2267 2299 (symbol '2')
2268 2300 (symbol '0'))
2269 2301 (func
2270 2302 (symbol 'present')
2271 2303 (func
2272 2304 (symbol '_list')
2273 2305 (string '0\x001\x002'))))
2274 2306 * set:
2275 2307 <filteredset
2276 2308 <spanset- 0:3>,
2277 2309 <baseset [0, 1, 2]>>
2278 2310 2
2279 2311 1
2280 2312 0
2281 2313
2282 2314 'reverse()' should take effect only if it is the outermost expression:
2283 2315
2284 2316 $ try --optimize '0:2 & reverse(all())'
2285 2317 (and
2286 2318 (range
2287 2319 (symbol '0')
2288 2320 (symbol '2'))
2289 2321 (func
2290 2322 (symbol 'reverse')
2291 2323 (func
2292 2324 (symbol 'all')
2293 2325 None)))
2294 2326 * optimized:
2295 2327 (and
2296 2328 (range
2297 2329 (symbol '0')
2298 2330 (symbol '2'))
2299 2331 (func
2300 2332 (symbol 'reverse')
2301 2333 (func
2302 2334 (symbol 'all')
2303 2335 None)))
2304 2336 * set:
2305 2337 <filteredset
2306 2338 <spanset+ 0:3>,
2307 2339 <spanset+ 0:10>>
2308 2340 0
2309 2341 1
2310 2342 2
2311 2343
2312 2344 'sort()' should take effect only if it is the outermost expression:
2313 2345
2314 2346 $ try --optimize '0:2 & sort(all(), -rev)'
2315 2347 (and
2316 2348 (range
2317 2349 (symbol '0')
2318 2350 (symbol '2'))
2319 2351 (func
2320 2352 (symbol 'sort')
2321 2353 (list
2322 2354 (func
2323 2355 (symbol 'all')
2324 2356 None)
2325 2357 (negate
2326 2358 (symbol 'rev')))))
2327 2359 * optimized:
2328 2360 (and
2329 2361 (range
2330 2362 (symbol '0')
2331 2363 (symbol '2'))
2332 2364 (func
2333 2365 (symbol 'sort')
2334 2366 (list
2335 2367 (func
2336 2368 (symbol 'all')
2337 2369 None)
2338 2370 (string '-rev'))))
2339 2371 * set:
2340 2372 <filteredset
2341 2373 <spanset+ 0:3>,
2342 2374 <spanset+ 0:10>>
2343 2375 0
2344 2376 1
2345 2377 2
2346 2378
2347 2379 invalid argument passed to noop sort():
2348 2380
2349 2381 $ log '0:2 & sort()'
2350 2382 hg: parse error: sort requires one or two arguments
2351 2383 [255]
2352 2384 $ log '0:2 & sort(all(), -invalid)'
2353 2385 hg: parse error: unknown sort key '-invalid'
2354 2386 [255]
2355 2387
2356 2388 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2357 2389
2358 2390 $ try --optimize '2:0 & first(1 + 0 + 2)'
2359 2391 (and
2360 2392 (range
2361 2393 (symbol '2')
2362 2394 (symbol '0'))
2363 2395 (func
2364 2396 (symbol 'first')
2365 2397 (or
2366 2398 (list
2367 2399 (symbol '1')
2368 2400 (symbol '0')
2369 2401 (symbol '2')))))
2370 2402 * optimized:
2371 2403 (and
2372 2404 (range
2373 2405 (symbol '2')
2374 2406 (symbol '0'))
2375 2407 (func
2376 2408 (symbol 'first')
2377 2409 (func
2378 2410 (symbol '_list')
2379 2411 (string '1\x000\x002'))))
2380 2412 * set:
2381 2413 <filteredset
2382 2414 <baseset [1]>,
2383 2415 <spanset- 0:3>>
2384 2416 1
2385 2417
2386 2418 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2387 2419 (and
2388 2420 (range
2389 2421 (symbol '2')
2390 2422 (symbol '0'))
2391 2423 (not
2392 2424 (func
2393 2425 (symbol 'last')
2394 2426 (or
2395 2427 (list
2396 2428 (symbol '0')
2397 2429 (symbol '2')
2398 2430 (symbol '1'))))))
2399 2431 * optimized:
2400 2432 (difference
2401 2433 (range
2402 2434 (symbol '2')
2403 2435 (symbol '0'))
2404 2436 (func
2405 2437 (symbol 'last')
2406 2438 (func
2407 2439 (symbol '_list')
2408 2440 (string '0\x002\x001'))))
2409 2441 * set:
2410 2442 <filteredset
2411 2443 <spanset- 0:3>,
2412 2444 <not
2413 2445 <baseset [1]>>>
2414 2446 2
2415 2447 0
2416 2448
2417 2449 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2418 2450
2419 2451 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2420 2452 (and
2421 2453 (range
2422 2454 (symbol '2')
2423 2455 (symbol '0'))
2424 2456 (range
2425 2457 (group
2426 2458 (or
2427 2459 (list
2428 2460 (symbol '1')
2429 2461 (symbol '0')
2430 2462 (symbol '2'))))
2431 2463 (group
2432 2464 (or
2433 2465 (list
2434 2466 (symbol '0')
2435 2467 (symbol '2')
2436 2468 (symbol '1'))))))
2437 2469 * optimized:
2438 2470 (and
2439 2471 (range
2440 2472 (symbol '2')
2441 2473 (symbol '0'))
2442 2474 (range
2443 2475 (func
2444 2476 (symbol '_list')
2445 2477 (string '1\x000\x002'))
2446 2478 (func
2447 2479 (symbol '_list')
2448 2480 (string '0\x002\x001'))))
2449 2481 * set:
2450 2482 <filteredset
2451 2483 <spanset- 0:3>,
2452 2484 <baseset [1]>>
2453 2485 1
2454 2486
2455 2487 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2456 2488
2457 2489 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2458 2490 (and
2459 2491 (func
2460 2492 (symbol 'contains')
2461 2493 (string 'glob:*'))
2462 2494 (group
2463 2495 (or
2464 2496 (list
2465 2497 (symbol '2')
2466 2498 (symbol '0')
2467 2499 (symbol '1')))))
2468 2500 * optimized:
2469 2501 (andsmally
2470 2502 (func
2471 2503 (symbol 'contains')
2472 2504 (string 'glob:*'))
2473 2505 (func
2474 2506 (symbol '_list')
2475 2507 (string '2\x000\x001')))
2476 2508 * set:
2477 2509 <filteredset
2478 2510 <baseset+ [0, 1, 2]>,
2479 2511 <contains 'glob:*'>>
2480 2512 0
2481 2513 1
2482 2514 2
2483 2515
2484 2516 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2485 2517 the order appropriately:
2486 2518
2487 2519 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2488 2520 (and
2489 2521 (func
2490 2522 (symbol 'reverse')
2491 2523 (func
2492 2524 (symbol 'contains')
2493 2525 (string 'glob:*')))
2494 2526 (group
2495 2527 (or
2496 2528 (list
2497 2529 (symbol '0')
2498 2530 (symbol '2')
2499 2531 (symbol '1')))))
2500 2532 * optimized:
2501 2533 (andsmally
2502 2534 (func
2503 2535 (symbol 'reverse')
2504 2536 (func
2505 2537 (symbol 'contains')
2506 2538 (string 'glob:*')))
2507 2539 (func
2508 2540 (symbol '_list')
2509 2541 (string '0\x002\x001')))
2510 2542 * set:
2511 2543 <filteredset
2512 2544 <baseset- [0, 1, 2]>,
2513 2545 <contains 'glob:*'>>
2514 2546 2
2515 2547 1
2516 2548 0
2517 2549
2518 2550 test sort revset
2519 2551 --------------------------------------------
2520 2552
2521 2553 test when adding two unordered revsets
2522 2554
2523 2555 $ log 'sort(keyword(issue) or modifies(b))'
2524 2556 4
2525 2557 6
2526 2558
2527 2559 test when sorting a reversed collection in the same way it is
2528 2560
2529 2561 $ log 'sort(reverse(all()), -rev)'
2530 2562 9
2531 2563 8
2532 2564 7
2533 2565 6
2534 2566 5
2535 2567 4
2536 2568 3
2537 2569 2
2538 2570 1
2539 2571 0
2540 2572
2541 2573 test when sorting a reversed collection
2542 2574
2543 2575 $ log 'sort(reverse(all()), rev)'
2544 2576 0
2545 2577 1
2546 2578 2
2547 2579 3
2548 2580 4
2549 2581 5
2550 2582 6
2551 2583 7
2552 2584 8
2553 2585 9
2554 2586
2555 2587
2556 2588 test sorting two sorted collections in different orders
2557 2589
2558 2590 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2559 2591 2
2560 2592 6
2561 2593 8
2562 2594 9
2563 2595
2564 2596 test sorting two sorted collections in different orders backwards
2565 2597
2566 2598 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2567 2599 9
2568 2600 8
2569 2601 6
2570 2602 2
2571 2603
2572 2604 test empty sort key which is noop
2573 2605
2574 2606 $ log 'sort(0 + 2 + 1, "")'
2575 2607 0
2576 2608 2
2577 2609 1
2578 2610
2579 2611 test invalid sort keys
2580 2612
2581 2613 $ log 'sort(all(), -invalid)'
2582 2614 hg: parse error: unknown sort key '-invalid'
2583 2615 [255]
2584 2616
2585 2617 $ cd ..
2586 2618
2587 2619 test sorting by multiple keys including variable-length strings
2588 2620
2589 2621 $ hg init sorting
2590 2622 $ cd sorting
2591 2623 $ cat <<EOF >> .hg/hgrc
2592 2624 > [ui]
2593 2625 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2594 2626 > [templatealias]
2595 2627 > p5(s) = pad(s, 5)
2596 2628 > EOF
2597 2629 $ hg branch -qf b12
2598 2630 $ hg ci -m m111 -u u112 -d '111 10800'
2599 2631 $ hg branch -qf b11
2600 2632 $ hg ci -m m12 -u u111 -d '112 7200'
2601 2633 $ hg branch -qf b111
2602 2634 $ hg ci -m m11 -u u12 -d '111 3600'
2603 2635 $ hg branch -qf b112
2604 2636 $ hg ci -m m111 -u u11 -d '120 0'
2605 2637 $ hg branch -qf b111
2606 2638 $ hg ci -m m112 -u u111 -d '110 14400'
2607 2639 created new head
2608 2640
2609 2641 compare revisions (has fast path):
2610 2642
2611 2643 $ hg log -r 'sort(all(), rev)'
2612 2644 0 b12 m111 u112 111 10800
2613 2645 1 b11 m12 u111 112 7200
2614 2646 2 b111 m11 u12 111 3600
2615 2647 3 b112 m111 u11 120 0
2616 2648 4 b111 m112 u111 110 14400
2617 2649
2618 2650 $ hg log -r 'sort(all(), -rev)'
2619 2651 4 b111 m112 u111 110 14400
2620 2652 3 b112 m111 u11 120 0
2621 2653 2 b111 m11 u12 111 3600
2622 2654 1 b11 m12 u111 112 7200
2623 2655 0 b12 m111 u112 111 10800
2624 2656
2625 2657 compare variable-length strings (issue5218):
2626 2658
2627 2659 $ hg log -r 'sort(all(), branch)'
2628 2660 1 b11 m12 u111 112 7200
2629 2661 2 b111 m11 u12 111 3600
2630 2662 4 b111 m112 u111 110 14400
2631 2663 3 b112 m111 u11 120 0
2632 2664 0 b12 m111 u112 111 10800
2633 2665
2634 2666 $ hg log -r 'sort(all(), -branch)'
2635 2667 0 b12 m111 u112 111 10800
2636 2668 3 b112 m111 u11 120 0
2637 2669 2 b111 m11 u12 111 3600
2638 2670 4 b111 m112 u111 110 14400
2639 2671 1 b11 m12 u111 112 7200
2640 2672
2641 2673 $ hg log -r 'sort(all(), desc)'
2642 2674 2 b111 m11 u12 111 3600
2643 2675 0 b12 m111 u112 111 10800
2644 2676 3 b112 m111 u11 120 0
2645 2677 4 b111 m112 u111 110 14400
2646 2678 1 b11 m12 u111 112 7200
2647 2679
2648 2680 $ hg log -r 'sort(all(), -desc)'
2649 2681 1 b11 m12 u111 112 7200
2650 2682 4 b111 m112 u111 110 14400
2651 2683 0 b12 m111 u112 111 10800
2652 2684 3 b112 m111 u11 120 0
2653 2685 2 b111 m11 u12 111 3600
2654 2686
2655 2687 $ hg log -r 'sort(all(), user)'
2656 2688 3 b112 m111 u11 120 0
2657 2689 1 b11 m12 u111 112 7200
2658 2690 4 b111 m112 u111 110 14400
2659 2691 0 b12 m111 u112 111 10800
2660 2692 2 b111 m11 u12 111 3600
2661 2693
2662 2694 $ hg log -r 'sort(all(), -user)'
2663 2695 2 b111 m11 u12 111 3600
2664 2696 0 b12 m111 u112 111 10800
2665 2697 1 b11 m12 u111 112 7200
2666 2698 4 b111 m112 u111 110 14400
2667 2699 3 b112 m111 u11 120 0
2668 2700
2669 2701 compare dates (tz offset should have no effect):
2670 2702
2671 2703 $ hg log -r 'sort(all(), date)'
2672 2704 4 b111 m112 u111 110 14400
2673 2705 0 b12 m111 u112 111 10800
2674 2706 2 b111 m11 u12 111 3600
2675 2707 1 b11 m12 u111 112 7200
2676 2708 3 b112 m111 u11 120 0
2677 2709
2678 2710 $ hg log -r 'sort(all(), -date)'
2679 2711 3 b112 m111 u11 120 0
2680 2712 1 b11 m12 u111 112 7200
2681 2713 0 b12 m111 u112 111 10800
2682 2714 2 b111 m11 u12 111 3600
2683 2715 4 b111 m112 u111 110 14400
2684 2716
2685 2717 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2686 2718 because '-k' reverses the comparison, not the list itself:
2687 2719
2688 2720 $ hg log -r 'sort(0 + 2, date)'
2689 2721 0 b12 m111 u112 111 10800
2690 2722 2 b111 m11 u12 111 3600
2691 2723
2692 2724 $ hg log -r 'sort(0 + 2, -date)'
2693 2725 0 b12 m111 u112 111 10800
2694 2726 2 b111 m11 u12 111 3600
2695 2727
2696 2728 $ hg log -r 'reverse(sort(0 + 2, date))'
2697 2729 2 b111 m11 u12 111 3600
2698 2730 0 b12 m111 u112 111 10800
2699 2731
2700 2732 sort by multiple keys:
2701 2733
2702 2734 $ hg log -r 'sort(all(), "branch -rev")'
2703 2735 1 b11 m12 u111 112 7200
2704 2736 4 b111 m112 u111 110 14400
2705 2737 2 b111 m11 u12 111 3600
2706 2738 3 b112 m111 u11 120 0
2707 2739 0 b12 m111 u112 111 10800
2708 2740
2709 2741 $ hg log -r 'sort(all(), "-desc -date")'
2710 2742 1 b11 m12 u111 112 7200
2711 2743 4 b111 m112 u111 110 14400
2712 2744 3 b112 m111 u11 120 0
2713 2745 0 b12 m111 u112 111 10800
2714 2746 2 b111 m11 u12 111 3600
2715 2747
2716 2748 $ hg log -r 'sort(all(), "user -branch date rev")'
2717 2749 3 b112 m111 u11 120 0
2718 2750 4 b111 m112 u111 110 14400
2719 2751 1 b11 m12 u111 112 7200
2720 2752 0 b12 m111 u112 111 10800
2721 2753 2 b111 m11 u12 111 3600
2722 2754
2723 2755 toposort prioritises graph branches
2724 2756
2725 2757 $ hg up 2
2726 2758 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2727 2759 $ touch a
2728 2760 $ hg addremove
2729 2761 adding a
2730 2762 $ hg ci -m 't1' -u 'tu' -d '130 0'
2731 2763 created new head
2732 2764 $ echo 'a' >> a
2733 2765 $ hg ci -m 't2' -u 'tu' -d '130 0'
2734 2766 $ hg book book1
2735 2767 $ hg up 4
2736 2768 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2737 2769 (leaving bookmark book1)
2738 2770 $ touch a
2739 2771 $ hg addremove
2740 2772 adding a
2741 2773 $ hg ci -m 't3' -u 'tu' -d '130 0'
2742 2774
2743 2775 $ hg log -r 'sort(all(), topo)'
2744 2776 7 b111 t3 tu 130 0
2745 2777 4 b111 m112 u111 110 14400
2746 2778 3 b112 m111 u11 120 0
2747 2779 6 b111 t2 tu 130 0
2748 2780 5 b111 t1 tu 130 0
2749 2781 2 b111 m11 u12 111 3600
2750 2782 1 b11 m12 u111 112 7200
2751 2783 0 b12 m111 u112 111 10800
2752 2784
2753 2785 $ hg log -r 'sort(all(), -topo)'
2754 2786 0 b12 m111 u112 111 10800
2755 2787 1 b11 m12 u111 112 7200
2756 2788 2 b111 m11 u12 111 3600
2757 2789 5 b111 t1 tu 130 0
2758 2790 6 b111 t2 tu 130 0
2759 2791 3 b112 m111 u11 120 0
2760 2792 4 b111 m112 u111 110 14400
2761 2793 7 b111 t3 tu 130 0
2762 2794
2763 2795 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2764 2796 6 b111 t2 tu 130 0
2765 2797 5 b111 t1 tu 130 0
2766 2798 7 b111 t3 tu 130 0
2767 2799 4 b111 m112 u111 110 14400
2768 2800 3 b112 m111 u11 120 0
2769 2801 2 b111 m11 u12 111 3600
2770 2802 1 b11 m12 u111 112 7200
2771 2803 0 b12 m111 u112 111 10800
2772 2804
2773 2805 topographical sorting can't be combined with other sort keys, and you can't
2774 2806 use the topo.firstbranch option when topo sort is not active:
2775 2807
2776 2808 $ hg log -r 'sort(all(), "topo user")'
2777 2809 hg: parse error: topo sort order cannot be combined with other sort keys
2778 2810 [255]
2779 2811
2780 2812 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2781 2813 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2782 2814 [255]
2783 2815
2784 2816 topo.firstbranch should accept any kind of expressions:
2785 2817
2786 2818 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2787 2819 0 b12 m111 u112 111 10800
2788 2820
2789 2821 $ cd ..
2790 2822 $ cd repo
2791 2823
2792 2824 test multiline revset with errors
2793 2825
2794 2826 $ echo > multiline-revset
2795 2827 $ echo '. +' >> multiline-revset
2796 2828 $ echo '.^ +' >> multiline-revset
2797 2829 $ hg log -r "`cat multiline-revset`"
2798 2830 hg: parse error at 9: not a prefix: end
2799 2831 ( . + .^ +
2800 2832 ^ here)
2801 2833 [255]
2802 2834 $ hg debugrevspec -v 'revset(first(rev(0)))' -p all
2803 2835 * parsed:
2804 2836 (func
2805 2837 (symbol 'revset')
2806 2838 (func
2807 2839 (symbol 'first')
2808 2840 (func
2809 2841 (symbol 'rev')
2810 2842 (symbol '0'))))
2811 2843 * expanded:
2812 2844 (func
2813 2845 (symbol 'revset')
2814 2846 (func
2815 2847 (symbol 'first')
2816 2848 (func
2817 2849 (symbol 'rev')
2818 2850 (symbol '0'))))
2819 2851 * concatenated:
2820 2852 (func
2821 2853 (symbol 'revset')
2822 2854 (func
2823 2855 (symbol 'first')
2824 2856 (func
2825 2857 (symbol 'rev')
2826 2858 (symbol '0'))))
2827 2859 * analyzed:
2828 2860 (func
2829 2861 (symbol 'first')
2830 2862 (func
2831 2863 (symbol 'rev')
2832 2864 (symbol '0')))
2833 2865 * optimized:
2834 2866 (func
2835 2867 (symbol 'first')
2836 2868 (func
2837 2869 (symbol 'rev')
2838 2870 (symbol '0')))
2839 2871 * set:
2840 2872 <baseset+ [0]>
2841 2873 0
General Comments 0
You need to be logged in to leave comments. Login now