tests/test-revset2.t
changeset 34126 af13097b44dd
parent 34073 7bbc4e113e5f
child 34866 1644623ab096
equal deleted inserted replaced
34125:57dc78d757ff 34126:af13097b44dd
       
     1   $ HGENCODING=utf-8
       
     2   $ export HGENCODING
       
     3   $ cat >> $HGRCPATH << EOF
       
     4   > [extensions]
       
     5   > drawdag=$TESTDIR/drawdag.py
       
     6   > EOF
       
     7 
       
     8   $ try() {
       
     9   >   hg debugrevspec --debug "$@"
       
    10   > }
       
    11 
       
    12   $ log() {
       
    13   >   hg log --template '{rev}\n' -r "$1"
       
    14   > }
       
    15 
       
    16   $ hg init repo
       
    17   $ cd repo
       
    18 
       
    19   $ echo a > a
       
    20   $ hg branch a
       
    21   marked working directory as branch a
       
    22   (branches are permanent and global, did you want a bookmark?)
       
    23   $ hg ci -Aqm0
       
    24 
       
    25   $ echo b > b
       
    26   $ hg branch b
       
    27   marked working directory as branch b
       
    28   $ hg ci -Aqm1
       
    29 
       
    30   $ rm a
       
    31   $ hg branch a-b-c-
       
    32   marked working directory as branch a-b-c-
       
    33   $ hg ci -Aqm2 -u Bob
       
    34 
       
    35   $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
       
    36   2
       
    37   $ hg log -r "extra('branch')" --template '{rev}\n'
       
    38   0
       
    39   1
       
    40   2
       
    41   $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
       
    42   0 a
       
    43   2 a-b-c-
       
    44 
       
    45   $ hg co 1
       
    46   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    47   $ hg branch +a+b+c+
       
    48   marked working directory as branch +a+b+c+
       
    49   $ hg ci -Aqm3
       
    50 
       
    51   $ hg co 2  # interleave
       
    52   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
    53   $ echo bb > b
       
    54   $ hg branch -- -a-b-c-
       
    55   marked working directory as branch -a-b-c-
       
    56   $ hg ci -Aqm4 -d "May 12 2005"
       
    57 
       
    58   $ hg co 3
       
    59   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    60   $ hg branch !a/b/c/
       
    61   marked working directory as branch !a/b/c/
       
    62   $ hg ci -Aqm"5 bug"
       
    63 
       
    64   $ hg merge 4
       
    65   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
    66   (branch merge, don't forget to commit)
       
    67   $ hg branch _a_b_c_
       
    68   marked working directory as branch _a_b_c_
       
    69   $ hg ci -Aqm"6 issue619"
       
    70 
       
    71   $ hg branch .a.b.c.
       
    72   marked working directory as branch .a.b.c.
       
    73   $ hg ci -Aqm7
       
    74 
       
    75   $ hg branch all
       
    76   marked working directory as branch all
       
    77 
       
    78   $ hg co 4
       
    79   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    80   $ hg branch é
       
    81   marked working directory as branch \xc3\xa9 (esc)
       
    82   $ hg ci -Aqm9
       
    83 
       
    84   $ hg tag -r6 1.0
       
    85   $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       
    86 
       
    87   $ hg clone --quiet -U -r 7 . ../remote1
       
    88   $ hg clone --quiet -U -r 8 . ../remote2
       
    89   $ echo "[paths]" >> .hg/hgrc
       
    90   $ echo "default = ../remote1" >> .hg/hgrc
       
    91 
       
    92 test subtracting something from an addset
       
    93 
       
    94   $ log '(outgoing() or removes(a)) - removes(a)'
       
    95   8
       
    96   9
       
    97 
       
    98 test intersecting something with an addset
       
    99 
       
   100   $ log 'parents(outgoing() or removes(a))'
       
   101   1
       
   102   4
       
   103   5
       
   104   8
       
   105 
       
   106 test that `or` operation combines elements in the right order:
       
   107 
       
   108   $ log '3:4 or 2:5'
       
   109   3
       
   110   4
       
   111   2
       
   112   5
       
   113   $ log '3:4 or 5:2'
       
   114   3
       
   115   4
       
   116   5
       
   117   2
       
   118   $ log 'sort(3:4 or 2:5)'
       
   119   2
       
   120   3
       
   121   4
       
   122   5
       
   123   $ log 'sort(3:4 or 5:2)'
       
   124   2
       
   125   3
       
   126   4
       
   127   5
       
   128 
       
   129 test that more than one `-r`s are combined in the right order and deduplicated:
       
   130 
       
   131   $ hg log -T '{rev}\n' -r 3 -r 3 -r 4 -r 5:2 -r 'ancestors(4)'
       
   132   3
       
   133   4
       
   134   5
       
   135   2
       
   136   0
       
   137   1
       
   138 
       
   139 test that `or` operation skips duplicated revisions from right-hand side
       
   140 
       
   141   $ try 'reverse(1::5) or ancestors(4)'
       
   142   (or
       
   143     (list
       
   144       (func
       
   145         (symbol 'reverse')
       
   146         (dagrange
       
   147           (symbol '1')
       
   148           (symbol '5')))
       
   149       (func
       
   150         (symbol 'ancestors')
       
   151         (symbol '4'))))
       
   152   * set:
       
   153   <addset
       
   154     <baseset- [1, 3, 5]>,
       
   155     <generatorset+>>
       
   156   5
       
   157   3
       
   158   1
       
   159   0
       
   160   2
       
   161   4
       
   162   $ try 'sort(ancestors(4) or reverse(1::5))'
       
   163   (func
       
   164     (symbol 'sort')
       
   165     (or
       
   166       (list
       
   167         (func
       
   168           (symbol 'ancestors')
       
   169           (symbol '4'))
       
   170         (func
       
   171           (symbol 'reverse')
       
   172           (dagrange
       
   173             (symbol '1')
       
   174             (symbol '5'))))))
       
   175   * set:
       
   176   <addset+
       
   177     <generatorset+>,
       
   178     <baseset- [1, 3, 5]>>
       
   179   0
       
   180   1
       
   181   2
       
   182   3
       
   183   4
       
   184   5
       
   185 
       
   186 test optimization of trivial `or` operation
       
   187 
       
   188   $ try --optimize '0|(1)|"2"|-2|tip|null'
       
   189   (or
       
   190     (list
       
   191       (symbol '0')
       
   192       (group
       
   193         (symbol '1'))
       
   194       (string '2')
       
   195       (negate
       
   196         (symbol '2'))
       
   197       (symbol 'tip')
       
   198       (symbol 'null')))
       
   199   * optimized:
       
   200   (func
       
   201     (symbol '_list')
       
   202     (string '0\x001\x002\x00-2\x00tip\x00null'))
       
   203   * set:
       
   204   <baseset [0, 1, 2, 8, 9, -1]>
       
   205   0
       
   206   1
       
   207   2
       
   208   8
       
   209   9
       
   210   -1
       
   211 
       
   212   $ try --optimize '0|1|2:3'
       
   213   (or
       
   214     (list
       
   215       (symbol '0')
       
   216       (symbol '1')
       
   217       (range
       
   218         (symbol '2')
       
   219         (symbol '3'))))
       
   220   * optimized:
       
   221   (or
       
   222     (list
       
   223       (func
       
   224         (symbol '_list')
       
   225         (string '0\x001'))
       
   226       (range
       
   227         (symbol '2')
       
   228         (symbol '3'))))
       
   229   * set:
       
   230   <addset
       
   231     <baseset [0, 1]>,
       
   232     <spanset+ 2:4>>
       
   233   0
       
   234   1
       
   235   2
       
   236   3
       
   237 
       
   238   $ try --optimize '0:1|2|3:4|5|6'
       
   239   (or
       
   240     (list
       
   241       (range
       
   242         (symbol '0')
       
   243         (symbol '1'))
       
   244       (symbol '2')
       
   245       (range
       
   246         (symbol '3')
       
   247         (symbol '4'))
       
   248       (symbol '5')
       
   249       (symbol '6')))
       
   250   * optimized:
       
   251   (or
       
   252     (list
       
   253       (range
       
   254         (symbol '0')
       
   255         (symbol '1'))
       
   256       (symbol '2')
       
   257       (range
       
   258         (symbol '3')
       
   259         (symbol '4'))
       
   260       (func
       
   261         (symbol '_list')
       
   262         (string '5\x006'))))
       
   263   * set:
       
   264   <addset
       
   265     <addset
       
   266       <spanset+ 0:2>,
       
   267       <baseset [2]>>,
       
   268     <addset
       
   269       <spanset+ 3:5>,
       
   270       <baseset [5, 6]>>>
       
   271   0
       
   272   1
       
   273   2
       
   274   3
       
   275   4
       
   276   5
       
   277   6
       
   278 
       
   279 unoptimized `or` looks like this
       
   280 
       
   281   $ try --no-optimized -p analyzed '0|1|2|3|4'
       
   282   * analyzed:
       
   283   (or
       
   284     (list
       
   285       (symbol '0')
       
   286       (symbol '1')
       
   287       (symbol '2')
       
   288       (symbol '3')
       
   289       (symbol '4')))
       
   290   * set:
       
   291   <addset
       
   292     <addset
       
   293       <baseset [0]>,
       
   294       <baseset [1]>>,
       
   295     <addset
       
   296       <baseset [2]>,
       
   297       <addset
       
   298         <baseset [3]>,
       
   299         <baseset [4]>>>>
       
   300   0
       
   301   1
       
   302   2
       
   303   3
       
   304   4
       
   305 
       
   306 test that `_list` should be narrowed by provided `subset`
       
   307 
       
   308   $ log '0:2 and (null|1|2|3)'
       
   309   1
       
   310   2
       
   311 
       
   312 test that `_list` should remove duplicates
       
   313 
       
   314   $ log '0|1|2|1|2|-1|tip'
       
   315   0
       
   316   1
       
   317   2
       
   318   9
       
   319 
       
   320 test unknown revision in `_list`
       
   321 
       
   322   $ log '0|unknown'
       
   323   abort: unknown revision 'unknown'!
       
   324   [255]
       
   325 
       
   326 test integer range in `_list`
       
   327 
       
   328   $ log '-1|-10'
       
   329   9
       
   330   0
       
   331 
       
   332   $ log '-10|-11'
       
   333   abort: unknown revision '-11'!
       
   334   [255]
       
   335 
       
   336   $ log '9|10'
       
   337   abort: unknown revision '10'!
       
   338   [255]
       
   339 
       
   340 test '0000' != '0' in `_list`
       
   341 
       
   342   $ log '0|0000'
       
   343   0
       
   344   -1
       
   345 
       
   346 test ',' in `_list`
       
   347   $ log '0,1'
       
   348   hg: parse error: can't use a list in this context
       
   349   (see hg help "revsets.x or y")
       
   350   [255]
       
   351   $ try '0,1,2'
       
   352   (list
       
   353     (symbol '0')
       
   354     (symbol '1')
       
   355     (symbol '2'))
       
   356   hg: parse error: can't use a list in this context
       
   357   (see hg help "revsets.x or y")
       
   358   [255]
       
   359 
       
   360 test that chained `or` operations make balanced addsets
       
   361 
       
   362   $ try '0:1|1:2|2:3|3:4|4:5'
       
   363   (or
       
   364     (list
       
   365       (range
       
   366         (symbol '0')
       
   367         (symbol '1'))
       
   368       (range
       
   369         (symbol '1')
       
   370         (symbol '2'))
       
   371       (range
       
   372         (symbol '2')
       
   373         (symbol '3'))
       
   374       (range
       
   375         (symbol '3')
       
   376         (symbol '4'))
       
   377       (range
       
   378         (symbol '4')
       
   379         (symbol '5'))))
       
   380   * set:
       
   381   <addset
       
   382     <addset
       
   383       <spanset+ 0:2>,
       
   384       <spanset+ 1:3>>,
       
   385     <addset
       
   386       <spanset+ 2:4>,
       
   387       <addset
       
   388         <spanset+ 3:5>,
       
   389         <spanset+ 4:6>>>>
       
   390   0
       
   391   1
       
   392   2
       
   393   3
       
   394   4
       
   395   5
       
   396 
       
   397 no crash by empty group "()" while optimizing `or` operations
       
   398 
       
   399   $ try --optimize '0|()'
       
   400   (or
       
   401     (list
       
   402       (symbol '0')
       
   403       (group
       
   404         None)))
       
   405   * optimized:
       
   406   (or
       
   407     (list
       
   408       (symbol '0')
       
   409       None))
       
   410   hg: parse error: missing argument
       
   411   [255]
       
   412 
       
   413 test that chained `or` operations never eat up stack (issue4624)
       
   414 (uses `0:1` instead of `0` to avoid future optimization of trivial revisions)
       
   415 
       
   416   $ hg log -T '{rev}\n' -r `$PYTHON -c "print '+'.join(['0:1'] * 500)"`
       
   417   0
       
   418   1
       
   419 
       
   420 test that repeated `-r` options never eat up stack (issue4565)
       
   421 (uses `-r 0::1` to avoid possible optimization at old-style parser)
       
   422 
       
   423   $ hg log -T '{rev}\n' `$PYTHON -c "for i in xrange(500): print '-r 0::1 ',"`
       
   424   0
       
   425   1
       
   426 
       
   427 check that conversion to only works
       
   428   $ try --optimize '::3 - ::1'
       
   429   (minus
       
   430     (dagrangepre
       
   431       (symbol '3'))
       
   432     (dagrangepre
       
   433       (symbol '1')))
       
   434   * optimized:
       
   435   (func
       
   436     (symbol 'only')
       
   437     (list
       
   438       (symbol '3')
       
   439       (symbol '1')))
       
   440   * set:
       
   441   <baseset+ [3]>
       
   442   3
       
   443   $ try --optimize 'ancestors(1) - ancestors(3)'
       
   444   (minus
       
   445     (func
       
   446       (symbol 'ancestors')
       
   447       (symbol '1'))
       
   448     (func
       
   449       (symbol 'ancestors')
       
   450       (symbol '3')))
       
   451   * optimized:
       
   452   (func
       
   453     (symbol 'only')
       
   454     (list
       
   455       (symbol '1')
       
   456       (symbol '3')))
       
   457   * set:
       
   458   <baseset+ []>
       
   459   $ try --optimize 'not ::2 and ::6'
       
   460   (and
       
   461     (not
       
   462       (dagrangepre
       
   463         (symbol '2')))
       
   464     (dagrangepre
       
   465       (symbol '6')))
       
   466   * optimized:
       
   467   (func
       
   468     (symbol 'only')
       
   469     (list
       
   470       (symbol '6')
       
   471       (symbol '2')))
       
   472   * set:
       
   473   <baseset+ [3, 4, 5, 6]>
       
   474   3
       
   475   4
       
   476   5
       
   477   6
       
   478   $ try --optimize 'ancestors(6) and not ancestors(4)'
       
   479   (and
       
   480     (func
       
   481       (symbol 'ancestors')
       
   482       (symbol '6'))
       
   483     (not
       
   484       (func
       
   485         (symbol 'ancestors')
       
   486         (symbol '4'))))
       
   487   * optimized:
       
   488   (func
       
   489     (symbol 'only')
       
   490     (list
       
   491       (symbol '6')
       
   492       (symbol '4')))
       
   493   * set:
       
   494   <baseset+ [3, 5, 6]>
       
   495   3
       
   496   5
       
   497   6
       
   498 
       
   499 no crash by empty group "()" while optimizing to "only()"
       
   500 
       
   501   $ try --optimize '::1 and ()'
       
   502   (and
       
   503     (dagrangepre
       
   504       (symbol '1'))
       
   505     (group
       
   506       None))
       
   507   * optimized:
       
   508   (andsmally
       
   509     (func
       
   510       (symbol 'ancestors')
       
   511       (symbol '1'))
       
   512     None)
       
   513   hg: parse error: missing argument
       
   514   [255]
       
   515 
       
   516 optimization to only() works only if ancestors() takes only one argument
       
   517 
       
   518   $ hg debugrevspec -p optimized 'ancestors(6) - ancestors(4, 1)'
       
   519   * optimized:
       
   520   (difference
       
   521     (func
       
   522       (symbol 'ancestors')
       
   523       (symbol '6'))
       
   524     (func
       
   525       (symbol 'ancestors')
       
   526       (list
       
   527         (symbol '4')
       
   528         (symbol '1'))))
       
   529   0
       
   530   1
       
   531   3
       
   532   5
       
   533   6
       
   534   $ hg debugrevspec -p optimized 'ancestors(6, 1) - ancestors(4)'
       
   535   * optimized:
       
   536   (difference
       
   537     (func
       
   538       (symbol 'ancestors')
       
   539       (list
       
   540         (symbol '6')
       
   541         (symbol '1')))
       
   542     (func
       
   543       (symbol 'ancestors')
       
   544       (symbol '4')))
       
   545   5
       
   546   6
       
   547 
       
   548 optimization disabled if keyword arguments passed (because we're too lazy
       
   549 to support it)
       
   550 
       
   551   $ hg debugrevspec -p optimized 'ancestors(set=6) - ancestors(set=4)'
       
   552   * optimized:
       
   553   (difference
       
   554     (func
       
   555       (symbol 'ancestors')
       
   556       (keyvalue
       
   557         (symbol 'set')
       
   558         (symbol '6')))
       
   559     (func
       
   560       (symbol 'ancestors')
       
   561       (keyvalue
       
   562         (symbol 'set')
       
   563         (symbol '4'))))
       
   564   3
       
   565   5
       
   566   6
       
   567 
       
   568 invalid function call should not be optimized to only()
       
   569 
       
   570   $ log '"ancestors"(6) and not ancestors(4)'
       
   571   hg: parse error: not a symbol
       
   572   [255]
       
   573 
       
   574   $ log 'ancestors(6) and not "ancestors"(4)'
       
   575   hg: parse error: not a symbol
       
   576   [255]
       
   577 
       
   578 we can use patterns when searching for tags
       
   579 
       
   580   $ log 'tag("1..*")'
       
   581   abort: tag '1..*' does not exist!
       
   582   [255]
       
   583   $ log 'tag("re:1..*")'
       
   584   6
       
   585   $ log 'tag("re:[0-9].[0-9]")'
       
   586   6
       
   587   $ log 'tag("literal:1.0")'
       
   588   6
       
   589   $ log 'tag("re:0..*")'
       
   590 
       
   591   $ log 'tag(unknown)'
       
   592   abort: tag 'unknown' does not exist!
       
   593   [255]
       
   594   $ log 'tag("re:unknown")'
       
   595   $ log 'present(tag("unknown"))'
       
   596   $ log 'present(tag("re:unknown"))'
       
   597   $ log 'branch(unknown)'
       
   598   abort: unknown revision 'unknown'!
       
   599   [255]
       
   600   $ log 'branch("literal:unknown")'
       
   601   abort: branch 'unknown' does not exist!
       
   602   [255]
       
   603   $ log 'branch("re:unknown")'
       
   604   $ log 'present(branch("unknown"))'
       
   605   $ log 'present(branch("re:unknown"))'
       
   606   $ log 'user(bob)'
       
   607   2
       
   608 
       
   609   $ log '4::8'
       
   610   4
       
   611   8
       
   612   $ log '4:8'
       
   613   4
       
   614   5
       
   615   6
       
   616   7
       
   617   8
       
   618 
       
   619   $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
       
   620   4
       
   621   2
       
   622   5
       
   623 
       
   624   $ log 'not 0 and 0:2'
       
   625   1
       
   626   2
       
   627   $ log 'not 1 and 0:2'
       
   628   0
       
   629   2
       
   630   $ log 'not 2 and 0:2'
       
   631   0
       
   632   1
       
   633   $ log '(1 and 2)::'
       
   634   $ log '(1 and 2):'
       
   635   $ log '(1 and 2):3'
       
   636   $ log 'sort(head(), -rev)'
       
   637   9
       
   638   7
       
   639   6
       
   640   5
       
   641   4
       
   642   3
       
   643   2
       
   644   1
       
   645   0
       
   646   $ log '4::8 - 8'
       
   647   4
       
   648 
       
   649 matching() should preserve the order of the input set:
       
   650 
       
   651   $ log '(2 or 3 or 1) and matching(1 or 2 or 3)'
       
   652   2
       
   653   3
       
   654   1
       
   655 
       
   656   $ log 'named("unknown")'
       
   657   abort: namespace 'unknown' does not exist!
       
   658   [255]
       
   659   $ log 'named("re:unknown")'
       
   660   abort: no namespace exists that match 'unknown'!
       
   661   [255]
       
   662   $ log 'present(named("unknown"))'
       
   663   $ log 'present(named("re:unknown"))'
       
   664 
       
   665   $ log 'tag()'
       
   666   6
       
   667   $ log 'named("tags")'
       
   668   6
       
   669 
       
   670 issue2437
       
   671 
       
   672   $ log '3 and p1(5)'
       
   673   3
       
   674   $ log '4 and p2(6)'
       
   675   4
       
   676   $ log '1 and parents(:2)'
       
   677   1
       
   678   $ log '2 and children(1:)'
       
   679   2
       
   680   $ log 'roots(all()) or roots(all())'
       
   681   0
       
   682   $ hg debugrevspec 'roots(all()) or roots(all())'
       
   683   0
       
   684   $ log 'heads(branch(é)) or heads(branch(é))'
       
   685   9
       
   686   $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(é)))'
       
   687   4
       
   688 
       
   689 issue2654: report a parse error if the revset was not completely parsed
       
   690 
       
   691   $ log '1 OR 2'
       
   692   hg: parse error at 2: invalid token
       
   693   [255]
       
   694 
       
   695 or operator should preserve ordering:
       
   696   $ log 'reverse(2::4) or tip'
       
   697   4
       
   698   2
       
   699   9
       
   700 
       
   701 parentrevspec
       
   702 
       
   703   $ log 'merge()^0'
       
   704   6
       
   705   $ log 'merge()^'
       
   706   5
       
   707   $ log 'merge()^1'
       
   708   5
       
   709   $ log 'merge()^2'
       
   710   4
       
   711   $ log '(not merge())^2'
       
   712   $ log 'merge()^^'
       
   713   3
       
   714   $ log 'merge()^1^'
       
   715   3
       
   716   $ log 'merge()^^^'
       
   717   1
       
   718 
       
   719   $ hg debugrevspec -s '(merge() | 0)~-1'
       
   720   * set:
       
   721   <baseset+ [1, 7]>
       
   722   1
       
   723   7
       
   724   $ log 'merge()~-1'
       
   725   7
       
   726   $ log 'tip~-1'
       
   727   $ log '(tip | merge())~-1'
       
   728   7
       
   729   $ log 'merge()~0'
       
   730   6
       
   731   $ log 'merge()~1'
       
   732   5
       
   733   $ log 'merge()~2'
       
   734   3
       
   735   $ log 'merge()~2^1'
       
   736   1
       
   737   $ log 'merge()~3'
       
   738   1
       
   739 
       
   740   $ log '(-3:tip)^'
       
   741   4
       
   742   6
       
   743   8
       
   744 
       
   745   $ log 'tip^foo'
       
   746   hg: parse error: ^ expects a number 0, 1, or 2
       
   747   [255]
       
   748 
       
   749   $ log 'branchpoint()~-1'
       
   750   abort: revision in set has more than one child!
       
   751   [255]
       
   752 
       
   753 Bogus function gets suggestions
       
   754   $ log 'add()'
       
   755   hg: parse error: unknown identifier: add
       
   756   (did you mean adds?)
       
   757   [255]
       
   758   $ log 'added()'
       
   759   hg: parse error: unknown identifier: added
       
   760   (did you mean adds?)
       
   761   [255]
       
   762   $ log 'remo()'
       
   763   hg: parse error: unknown identifier: remo
       
   764   (did you mean one of remote, removes?)
       
   765   [255]
       
   766   $ log 'babar()'
       
   767   hg: parse error: unknown identifier: babar
       
   768   [255]
       
   769 
       
   770 Bogus function with a similar internal name doesn't suggest the internal name
       
   771   $ log 'matches()'
       
   772   hg: parse error: unknown identifier: matches
       
   773   (did you mean matching?)
       
   774   [255]
       
   775 
       
   776 Undocumented functions aren't suggested as similar either
       
   777   $ log 'tagged2()'
       
   778   hg: parse error: unknown identifier: tagged2
       
   779   [255]
       
   780 
       
   781 multiple revspecs
       
   782 
       
   783   $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
       
   784   8
       
   785   9
       
   786   4
       
   787   5
       
   788   6
       
   789   7
       
   790 
       
   791 test usage in revpair (with "+")
       
   792 
       
   793 (real pair)
       
   794 
       
   795   $ hg diff -r 'tip^^' -r 'tip'
       
   796   diff -r 2326846efdab -r 24286f4ae135 .hgtags
       
   797   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   798   +++ b/.hgtags	Thu Jan 01 00:00:00 1970 +0000
       
   799   @@ -0,0 +1,1 @@
       
   800   +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
       
   801   $ hg diff -r 'tip^^::tip'
       
   802   diff -r 2326846efdab -r 24286f4ae135 .hgtags
       
   803   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   804   +++ b/.hgtags	Thu Jan 01 00:00:00 1970 +0000
       
   805   @@ -0,0 +1,1 @@
       
   806   +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
       
   807 
       
   808 (single rev)
       
   809 
       
   810   $ hg diff -r 'tip^' -r 'tip^'
       
   811   $ hg diff -r 'tip^:tip^'
       
   812 
       
   813 (single rev that does not looks like a range)
       
   814 
       
   815   $ hg diff -r 'tip^::tip^ or tip^'
       
   816   diff -r d5d0dcbdc4d9 .hgtags
       
   817   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   818   +++ b/.hgtags	* (glob)
       
   819   @@ -0,0 +1,1 @@
       
   820   +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
       
   821   $ hg diff -r 'tip^ or tip^'
       
   822   diff -r d5d0dcbdc4d9 .hgtags
       
   823   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       
   824   +++ b/.hgtags	* (glob)
       
   825   @@ -0,0 +1,1 @@
       
   826   +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
       
   827 
       
   828 (no rev)
       
   829 
       
   830   $ hg diff -r 'author("babar") or author("celeste")'
       
   831   abort: empty revision range
       
   832   [255]
       
   833 
       
   834 aliases:
       
   835 
       
   836   $ echo '[revsetalias]' >> .hg/hgrc
       
   837   $ echo 'm = merge()' >> .hg/hgrc
       
   838 (revset aliases can override builtin revsets)
       
   839   $ echo 'p2($1) = p1($1)' >> .hg/hgrc
       
   840   $ echo 'sincem = descendants(m)' >> .hg/hgrc
       
   841   $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
       
   842   $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
       
   843   $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
       
   844 
       
   845   $ try m
       
   846   (symbol 'm')
       
   847   * expanded:
       
   848   (func
       
   849     (symbol 'merge')
       
   850     None)
       
   851   * set:
       
   852   <filteredset
       
   853     <fullreposet+ 0:10>,
       
   854     <merge>>
       
   855   6
       
   856 
       
   857   $ HGPLAIN=1
       
   858   $ export HGPLAIN
       
   859   $ try m
       
   860   (symbol 'm')
       
   861   abort: unknown revision 'm'!
       
   862   [255]
       
   863 
       
   864   $ HGPLAINEXCEPT=revsetalias
       
   865   $ export HGPLAINEXCEPT
       
   866   $ try m
       
   867   (symbol 'm')
       
   868   * expanded:
       
   869   (func
       
   870     (symbol 'merge')
       
   871     None)
       
   872   * set:
       
   873   <filteredset
       
   874     <fullreposet+ 0:10>,
       
   875     <merge>>
       
   876   6
       
   877 
       
   878   $ unset HGPLAIN
       
   879   $ unset HGPLAINEXCEPT
       
   880 
       
   881   $ try 'p2(.)'
       
   882   (func
       
   883     (symbol 'p2')
       
   884     (symbol '.'))
       
   885   * expanded:
       
   886   (func
       
   887     (symbol 'p1')
       
   888     (symbol '.'))
       
   889   * set:
       
   890   <baseset+ [8]>
       
   891   8
       
   892 
       
   893   $ HGPLAIN=1
       
   894   $ export HGPLAIN
       
   895   $ try 'p2(.)'
       
   896   (func
       
   897     (symbol 'p2')
       
   898     (symbol '.'))
       
   899   * set:
       
   900   <baseset+ []>
       
   901 
       
   902   $ HGPLAINEXCEPT=revsetalias
       
   903   $ export HGPLAINEXCEPT
       
   904   $ try 'p2(.)'
       
   905   (func
       
   906     (symbol 'p2')
       
   907     (symbol '.'))
       
   908   * expanded:
       
   909   (func
       
   910     (symbol 'p1')
       
   911     (symbol '.'))
       
   912   * set:
       
   913   <baseset+ [8]>
       
   914   8
       
   915 
       
   916   $ unset HGPLAIN
       
   917   $ unset HGPLAINEXCEPT
       
   918 
       
   919 test alias recursion
       
   920 
       
   921   $ try sincem
       
   922   (symbol 'sincem')
       
   923   * expanded:
       
   924   (func
       
   925     (symbol 'descendants')
       
   926     (func
       
   927       (symbol 'merge')
       
   928       None))
       
   929   * set:
       
   930   <generatorset+>
       
   931   6
       
   932   7
       
   933 
       
   934 test infinite recursion
       
   935 
       
   936   $ echo 'recurse1 = recurse2' >> .hg/hgrc
       
   937   $ echo 'recurse2 = recurse1' >> .hg/hgrc
       
   938   $ try recurse1
       
   939   (symbol 'recurse1')
       
   940   hg: parse error: infinite expansion of revset alias "recurse1" detected
       
   941   [255]
       
   942 
       
   943   $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc
       
   944   $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc
       
   945   $ try "level2(level1(1, 2), 3)"
       
   946   (func
       
   947     (symbol 'level2')
       
   948     (list
       
   949       (func
       
   950         (symbol 'level1')
       
   951         (list
       
   952           (symbol '1')
       
   953           (symbol '2')))
       
   954       (symbol '3')))
       
   955   * expanded:
       
   956   (or
       
   957     (list
       
   958       (symbol '3')
       
   959       (or
       
   960         (list
       
   961           (symbol '1')
       
   962           (symbol '2')))))
       
   963   * set:
       
   964   <addset
       
   965     <baseset [3]>,
       
   966     <baseset [1, 2]>>
       
   967   3
       
   968   1
       
   969   2
       
   970 
       
   971 test nesting and variable passing
       
   972 
       
   973   $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
       
   974   $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
       
   975   $ echo 'nested3($1) = max($1)' >> .hg/hgrc
       
   976   $ try 'nested(2:5)'
       
   977   (func
       
   978     (symbol 'nested')
       
   979     (range
       
   980       (symbol '2')
       
   981       (symbol '5')))
       
   982   * expanded:
       
   983   (func
       
   984     (symbol 'max')
       
   985     (range
       
   986       (symbol '2')
       
   987       (symbol '5')))
       
   988   * set:
       
   989   <baseset
       
   990     <max
       
   991       <fullreposet+ 0:10>,
       
   992       <spanset+ 2:6>>>
       
   993   5
       
   994 
       
   995 test chained `or` operations are flattened at parsing phase
       
   996 
       
   997   $ echo 'chainedorops($1, $2, $3) = $1|$2|$3' >> .hg/hgrc
       
   998   $ try 'chainedorops(0:1, 1:2, 2:3)'
       
   999   (func
       
  1000     (symbol 'chainedorops')
       
  1001     (list
       
  1002       (range
       
  1003         (symbol '0')
       
  1004         (symbol '1'))
       
  1005       (range
       
  1006         (symbol '1')
       
  1007         (symbol '2'))
       
  1008       (range
       
  1009         (symbol '2')
       
  1010         (symbol '3'))))
       
  1011   * expanded:
       
  1012   (or
       
  1013     (list
       
  1014       (range
       
  1015         (symbol '0')
       
  1016         (symbol '1'))
       
  1017       (range
       
  1018         (symbol '1')
       
  1019         (symbol '2'))
       
  1020       (range
       
  1021         (symbol '2')
       
  1022         (symbol '3'))))
       
  1023   * set:
       
  1024   <addset
       
  1025     <spanset+ 0:2>,
       
  1026     <addset
       
  1027       <spanset+ 1:3>,
       
  1028       <spanset+ 2:4>>>
       
  1029   0
       
  1030   1
       
  1031   2
       
  1032   3
       
  1033 
       
  1034 test variable isolation, variable placeholders are rewritten as string
       
  1035 then parsed and matched again as string. Check they do not leak too
       
  1036 far away.
       
  1037 
       
  1038   $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
       
  1039   $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
       
  1040   $ try 'callinjection(2:5)'
       
  1041   (func
       
  1042     (symbol 'callinjection')
       
  1043     (range
       
  1044       (symbol '2')
       
  1045       (symbol '5')))
       
  1046   * expanded:
       
  1047   (func
       
  1048     (symbol 'descendants')
       
  1049     (func
       
  1050       (symbol 'max')
       
  1051       (string '$1')))
       
  1052   abort: unknown revision '$1'!
       
  1053   [255]
       
  1054 
       
  1055 test scope of alias expansion: 'universe' is expanded prior to 'shadowall(0)',
       
  1056 but 'all()' should never be substituted to '0()'.
       
  1057 
       
  1058   $ echo 'universe = all()' >> .hg/hgrc
       
  1059   $ echo 'shadowall(all) = all and universe' >> .hg/hgrc
       
  1060   $ try 'shadowall(0)'
       
  1061   (func
       
  1062     (symbol 'shadowall')
       
  1063     (symbol '0'))
       
  1064   * expanded:
       
  1065   (and
       
  1066     (symbol '0')
       
  1067     (func
       
  1068       (symbol 'all')
       
  1069       None))
       
  1070   * set:
       
  1071   <filteredset
       
  1072     <baseset [0]>,
       
  1073     <spanset+ 0:10>>
       
  1074   0
       
  1075 
       
  1076 test unknown reference:
       
  1077 
       
  1078   $ try "unknownref(0)" --config 'revsetalias.unknownref($1)=$1:$2'
       
  1079   (func
       
  1080     (symbol 'unknownref')
       
  1081     (symbol '0'))
       
  1082   abort: bad definition of revset alias "unknownref": invalid symbol '$2'
       
  1083   [255]
       
  1084 
       
  1085   $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
       
  1086   (symbol 'tip')
       
  1087   warning: bad definition of revset alias "anotherbadone": at 7: not a prefix: end
       
  1088   * set:
       
  1089   <baseset [9]>
       
  1090   9
       
  1091 
       
  1092   $ try 'tip'
       
  1093   (symbol 'tip')
       
  1094   * set:
       
  1095   <baseset [9]>
       
  1096   9
       
  1097 
       
  1098   $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
       
  1099   (symbol 'tip')
       
  1100   warning: bad declaration of revset alias "bad name": at 4: invalid token
       
  1101   * set:
       
  1102   <baseset [9]>
       
  1103   9
       
  1104   $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
       
  1105   $ try 'strictreplacing("foo", tip)'
       
  1106   (func
       
  1107     (symbol 'strictreplacing')
       
  1108     (list
       
  1109       (string 'foo')
       
  1110       (symbol 'tip')))
       
  1111   * expanded:
       
  1112   (or
       
  1113     (list
       
  1114       (symbol 'tip')
       
  1115       (func
       
  1116         (symbol 'desc')
       
  1117         (string '$1'))))
       
  1118   * set:
       
  1119   <addset
       
  1120     <baseset [9]>,
       
  1121     <filteredset
       
  1122       <fullreposet+ 0:10>,
       
  1123       <desc '$1'>>>
       
  1124   9
       
  1125 
       
  1126   $ try 'd(2:5)'
       
  1127   (func
       
  1128     (symbol 'd')
       
  1129     (range
       
  1130       (symbol '2')
       
  1131       (symbol '5')))
       
  1132   * expanded:
       
  1133   (func
       
  1134     (symbol 'reverse')
       
  1135     (func
       
  1136       (symbol 'sort')
       
  1137       (list
       
  1138         (range
       
  1139           (symbol '2')
       
  1140           (symbol '5'))
       
  1141         (symbol 'date'))))
       
  1142   * set:
       
  1143   <baseset [4, 5, 3, 2]>
       
  1144   4
       
  1145   5
       
  1146   3
       
  1147   2
       
  1148   $ try 'rs(2 or 3, date)'
       
  1149   (func
       
  1150     (symbol 'rs')
       
  1151     (list
       
  1152       (or
       
  1153         (list
       
  1154           (symbol '2')
       
  1155           (symbol '3')))
       
  1156       (symbol 'date')))
       
  1157   * expanded:
       
  1158   (func
       
  1159     (symbol 'reverse')
       
  1160     (func
       
  1161       (symbol 'sort')
       
  1162       (list
       
  1163         (or
       
  1164           (list
       
  1165             (symbol '2')
       
  1166             (symbol '3')))
       
  1167         (symbol 'date'))))
       
  1168   * set:
       
  1169   <baseset [3, 2]>
       
  1170   3
       
  1171   2
       
  1172   $ try 'rs()'
       
  1173   (func
       
  1174     (symbol 'rs')
       
  1175     None)
       
  1176   hg: parse error: invalid number of arguments: 0
       
  1177   [255]
       
  1178   $ try 'rs(2)'
       
  1179   (func
       
  1180     (symbol 'rs')
       
  1181     (symbol '2'))
       
  1182   hg: parse error: invalid number of arguments: 1
       
  1183   [255]
       
  1184   $ try 'rs(2, data, 7)'
       
  1185   (func
       
  1186     (symbol 'rs')
       
  1187     (list
       
  1188       (symbol '2')
       
  1189       (symbol 'data')
       
  1190       (symbol '7')))
       
  1191   hg: parse error: invalid number of arguments: 3
       
  1192   [255]
       
  1193   $ try 'rs4(2 or 3, x, x, date)'
       
  1194   (func
       
  1195     (symbol 'rs4')
       
  1196     (list
       
  1197       (or
       
  1198         (list
       
  1199           (symbol '2')
       
  1200           (symbol '3')))
       
  1201       (symbol 'x')
       
  1202       (symbol 'x')
       
  1203       (symbol 'date')))
       
  1204   * expanded:
       
  1205   (func
       
  1206     (symbol 'reverse')
       
  1207     (func
       
  1208       (symbol 'sort')
       
  1209       (list
       
  1210         (or
       
  1211           (list
       
  1212             (symbol '2')
       
  1213             (symbol '3')))
       
  1214         (symbol 'date'))))
       
  1215   * set:
       
  1216   <baseset [3, 2]>
       
  1217   3
       
  1218   2
       
  1219 
       
  1220 issue4553: check that revset aliases override existing hash prefix
       
  1221 
       
  1222   $ hg log -qr e
       
  1223   6:e0cc66ef77e8
       
  1224 
       
  1225   $ hg log -qr e --config revsetalias.e="all()"
       
  1226   0:2785f51eece5
       
  1227   1:d75937da8da0
       
  1228   2:5ed5505e9f1c
       
  1229   3:8528aa5637f2
       
  1230   4:2326846efdab
       
  1231   5:904fa392b941
       
  1232   6:e0cc66ef77e8
       
  1233   7:013af1973af4
       
  1234   8:d5d0dcbdc4d9
       
  1235   9:24286f4ae135
       
  1236 
       
  1237   $ hg log -qr e: --config revsetalias.e="0"
       
  1238   0:2785f51eece5
       
  1239   1:d75937da8da0
       
  1240   2:5ed5505e9f1c
       
  1241   3:8528aa5637f2
       
  1242   4:2326846efdab
       
  1243   5:904fa392b941
       
  1244   6:e0cc66ef77e8
       
  1245   7:013af1973af4
       
  1246   8:d5d0dcbdc4d9
       
  1247   9:24286f4ae135
       
  1248 
       
  1249   $ hg log -qr :e --config revsetalias.e="9"
       
  1250   0:2785f51eece5
       
  1251   1:d75937da8da0
       
  1252   2:5ed5505e9f1c
       
  1253   3:8528aa5637f2
       
  1254   4:2326846efdab
       
  1255   5:904fa392b941
       
  1256   6:e0cc66ef77e8
       
  1257   7:013af1973af4
       
  1258   8:d5d0dcbdc4d9
       
  1259   9:24286f4ae135
       
  1260 
       
  1261   $ hg log -qr e:
       
  1262   6:e0cc66ef77e8
       
  1263   7:013af1973af4
       
  1264   8:d5d0dcbdc4d9
       
  1265   9:24286f4ae135
       
  1266 
       
  1267   $ hg log -qr :e
       
  1268   0:2785f51eece5
       
  1269   1:d75937da8da0
       
  1270   2:5ed5505e9f1c
       
  1271   3:8528aa5637f2
       
  1272   4:2326846efdab
       
  1273   5:904fa392b941
       
  1274   6:e0cc66ef77e8
       
  1275 
       
  1276 issue2549 - correct optimizations
       
  1277 
       
  1278   $ try 'limit(1 or 2 or 3, 2) and not 2'
       
  1279   (and
       
  1280     (func
       
  1281       (symbol 'limit')
       
  1282       (list
       
  1283         (or
       
  1284           (list
       
  1285             (symbol '1')
       
  1286             (symbol '2')
       
  1287             (symbol '3')))
       
  1288         (symbol '2')))
       
  1289     (not
       
  1290       (symbol '2')))
       
  1291   * set:
       
  1292   <filteredset
       
  1293     <baseset [1, 2]>,
       
  1294     <not
       
  1295       <baseset [2]>>>
       
  1296   1
       
  1297   $ try 'max(1 or 2) and not 2'
       
  1298   (and
       
  1299     (func
       
  1300       (symbol 'max')
       
  1301       (or
       
  1302         (list
       
  1303           (symbol '1')
       
  1304           (symbol '2'))))
       
  1305     (not
       
  1306       (symbol '2')))
       
  1307   * set:
       
  1308   <filteredset
       
  1309     <baseset
       
  1310       <max
       
  1311         <fullreposet+ 0:10>,
       
  1312         <baseset [1, 2]>>>,
       
  1313     <not
       
  1314       <baseset [2]>>>
       
  1315   $ try 'min(1 or 2) and not 1'
       
  1316   (and
       
  1317     (func
       
  1318       (symbol 'min')
       
  1319       (or
       
  1320         (list
       
  1321           (symbol '1')
       
  1322           (symbol '2'))))
       
  1323     (not
       
  1324       (symbol '1')))
       
  1325   * set:
       
  1326   <filteredset
       
  1327     <baseset
       
  1328       <min
       
  1329         <fullreposet+ 0:10>,
       
  1330         <baseset [1, 2]>>>,
       
  1331     <not
       
  1332       <baseset [1]>>>
       
  1333   $ try 'last(1 or 2, 1) and not 2'
       
  1334   (and
       
  1335     (func
       
  1336       (symbol 'last')
       
  1337       (list
       
  1338         (or
       
  1339           (list
       
  1340             (symbol '1')
       
  1341             (symbol '2')))
       
  1342         (symbol '1')))
       
  1343     (not
       
  1344       (symbol '2')))
       
  1345   * set:
       
  1346   <filteredset
       
  1347     <baseset [2]>,
       
  1348     <not
       
  1349       <baseset [2]>>>
       
  1350 
       
  1351 issue4289 - ordering of built-ins
       
  1352   $ hg log -M -q -r 3:2
       
  1353   3:8528aa5637f2
       
  1354   2:5ed5505e9f1c
       
  1355 
       
  1356 test revsets started with 40-chars hash (issue3669)
       
  1357 
       
  1358   $ ISSUE3669_TIP=`hg tip --template '{node}'`
       
  1359   $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n'
       
  1360   9
       
  1361   $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n'
       
  1362   8
       
  1363 
       
  1364 test or-ed indirect predicates (issue3775)
       
  1365 
       
  1366   $ log '6 or 6^1' | sort
       
  1367   5
       
  1368   6
       
  1369   $ log '6^1 or 6' | sort
       
  1370   5
       
  1371   6
       
  1372   $ log '4 or 4~1' | sort
       
  1373   2
       
  1374   4
       
  1375   $ log '4~1 or 4' | sort
       
  1376   2
       
  1377   4
       
  1378   $ log '(0 or 2):(4 or 6) or 0 or 6' | sort
       
  1379   0
       
  1380   1
       
  1381   2
       
  1382   3
       
  1383   4
       
  1384   5
       
  1385   6
       
  1386   $ log '0 or 6 or (0 or 2):(4 or 6)' | sort
       
  1387   0
       
  1388   1
       
  1389   2
       
  1390   3
       
  1391   4
       
  1392   5
       
  1393   6
       
  1394 
       
  1395 tests for 'remote()' predicate:
       
  1396 #.  (csets in remote) (id)            (remote)
       
  1397 1.  less than local   current branch  "default"
       
  1398 2.  same with local   specified       "default"
       
  1399 3.  more than local   specified       specified
       
  1400 
       
  1401   $ hg clone --quiet -U . ../remote3
       
  1402   $ cd ../remote3
       
  1403   $ hg update -q 7
       
  1404   $ echo r > r
       
  1405   $ hg ci -Aqm 10
       
  1406   $ log 'remote()'
       
  1407   7
       
  1408   $ log 'remote("a-b-c-")'
       
  1409   2
       
  1410   $ cd ../repo
       
  1411   $ log 'remote(".a.b.c.", "../remote3")'
       
  1412 
       
  1413 tests for concatenation of strings/symbols by "##"
       
  1414 
       
  1415   $ try "278 ## '5f5' ## 1ee ## 'ce5'"
       
  1416   (_concat
       
  1417     (_concat
       
  1418       (_concat
       
  1419         (symbol '278')
       
  1420         (string '5f5'))
       
  1421       (symbol '1ee'))
       
  1422     (string 'ce5'))
       
  1423   * concatenated:
       
  1424   (string '2785f51eece5')
       
  1425   * set:
       
  1426   <baseset [0]>
       
  1427   0
       
  1428 
       
  1429   $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc
       
  1430   $ try "cat4(278, '5f5', 1ee, 'ce5')"
       
  1431   (func
       
  1432     (symbol 'cat4')
       
  1433     (list
       
  1434       (symbol '278')
       
  1435       (string '5f5')
       
  1436       (symbol '1ee')
       
  1437       (string 'ce5')))
       
  1438   * expanded:
       
  1439   (_concat
       
  1440     (_concat
       
  1441       (_concat
       
  1442         (symbol '278')
       
  1443         (string '5f5'))
       
  1444       (symbol '1ee'))
       
  1445     (string 'ce5'))
       
  1446   * concatenated:
       
  1447   (string '2785f51eece5')
       
  1448   * set:
       
  1449   <baseset [0]>
       
  1450   0
       
  1451 
       
  1452 (check concatenation in alias nesting)
       
  1453 
       
  1454   $ echo 'cat2($1, $2) = $1 ## $2' >> .hg/hgrc
       
  1455   $ echo 'cat2x2($1, $2, $3, $4) = cat2($1 ## $2, $3 ## $4)' >> .hg/hgrc
       
  1456   $ log "cat2x2(278, '5f5', 1ee, 'ce5')"
       
  1457   0
       
  1458 
       
  1459 (check operator priority)
       
  1460 
       
  1461   $ echo 'cat2n2($1, $2, $3, $4) = $1 ## $2 or $3 ## $4~2' >> .hg/hgrc
       
  1462   $ log "cat2n2(2785f5, 1eece5, 24286f, 4ae135)"
       
  1463   0
       
  1464   4
       
  1465 
       
  1466   $ cd ..
       
  1467 
       
  1468 prepare repository that has "default" branches of multiple roots
       
  1469 
       
  1470   $ hg init namedbranch
       
  1471   $ cd namedbranch
       
  1472 
       
  1473   $ echo default0 >> a
       
  1474   $ hg ci -Aqm0
       
  1475   $ echo default1 >> a
       
  1476   $ hg ci -m1
       
  1477 
       
  1478   $ hg branch -q stable
       
  1479   $ echo stable2 >> a
       
  1480   $ hg ci -m2
       
  1481   $ echo stable3 >> a
       
  1482   $ hg ci -m3
       
  1483 
       
  1484   $ hg update -q null
       
  1485   $ echo default4 >> a
       
  1486   $ hg ci -Aqm4
       
  1487   $ echo default5 >> a
       
  1488   $ hg ci -m5
       
  1489 
       
  1490 "null" revision belongs to "default" branch (issue4683)
       
  1491 
       
  1492   $ log 'branch(null)'
       
  1493   0
       
  1494   1
       
  1495   4
       
  1496   5
       
  1497 
       
  1498 "null" revision belongs to "default" branch, but it shouldn't appear in set
       
  1499 unless explicitly specified (issue4682)
       
  1500 
       
  1501   $ log 'children(branch(default))'
       
  1502   1
       
  1503   2
       
  1504   5
       
  1505 
       
  1506   $ cd ..
       
  1507 
       
  1508 test author/desc/keyword in problematic encoding
       
  1509 # unicode: cp932:
       
  1510 # u30A2    0x83 0x41(= 'A')
       
  1511 # u30C2    0x83 0x61(= 'a')
       
  1512 
       
  1513   $ hg init problematicencoding
       
  1514   $ cd problematicencoding
       
  1515 
       
  1516   $ $PYTHON > setup.sh <<EOF
       
  1517   > print u'''
       
  1518   > echo a > text
       
  1519   > hg add text
       
  1520   > hg --encoding utf-8 commit -u '\u30A2' -m none
       
  1521   > echo b > text
       
  1522   > hg --encoding utf-8 commit -u '\u30C2' -m none
       
  1523   > echo c > text
       
  1524   > hg --encoding utf-8 commit -u none -m '\u30A2'
       
  1525   > echo d > text
       
  1526   > hg --encoding utf-8 commit -u none -m '\u30C2'
       
  1527   > '''.encode('utf-8')
       
  1528   > EOF
       
  1529   $ sh < setup.sh
       
  1530 
       
  1531 test in problematic encoding
       
  1532   $ $PYTHON > test.sh <<EOF
       
  1533   > print u'''
       
  1534   > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
       
  1535   > echo ====
       
  1536   > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
       
  1537   > echo ====
       
  1538   > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
       
  1539   > echo ====
       
  1540   > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
       
  1541   > echo ====
       
  1542   > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
       
  1543   > echo ====
       
  1544   > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
       
  1545   > '''.encode('cp932')
       
  1546   > EOF
       
  1547   $ sh < test.sh
       
  1548   0
       
  1549   ====
       
  1550   1
       
  1551   ====
       
  1552   2
       
  1553   ====
       
  1554   3
       
  1555   ====
       
  1556   0
       
  1557   2
       
  1558   ====
       
  1559   1
       
  1560   3
       
  1561 
       
  1562 test error message of bad revset
       
  1563   $ hg log -r 'foo\\'
       
  1564   hg: parse error at 3: syntax error in revset 'foo\\'
       
  1565   [255]
       
  1566 
       
  1567   $ cd ..
       
  1568 
       
  1569 Test that revset predicate of extension isn't loaded at failure of
       
  1570 loading it
       
  1571 
       
  1572   $ cd repo
       
  1573 
       
  1574   $ cat <<EOF > $TESTTMP/custompredicate.py
       
  1575   > from mercurial import error, registrar, revset
       
  1576   > 
       
  1577   > revsetpredicate = registrar.revsetpredicate()
       
  1578   > 
       
  1579   > @revsetpredicate('custom1()')
       
  1580   > def custom1(repo, subset, x):
       
  1581   >     return revset.baseset([1])
       
  1582   > 
       
  1583   > raise error.Abort('intentional failure of loading extension')
       
  1584   > EOF
       
  1585   $ cat <<EOF > .hg/hgrc
       
  1586   > [extensions]
       
  1587   > custompredicate = $TESTTMP/custompredicate.py
       
  1588   > EOF
       
  1589 
       
  1590   $ hg debugrevspec "custom1()"
       
  1591   *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
       
  1592   hg: parse error: unknown identifier: custom1
       
  1593   [255]
       
  1594 
       
  1595 Test repo.anyrevs with customized revset overrides
       
  1596 
       
  1597   $ cat > $TESTTMP/printprevset.py <<EOF
       
  1598   > from mercurial import encoding, registrar
       
  1599   > cmdtable = {}
       
  1600   > command = registrar.command(cmdtable)
       
  1601   > @command('printprevset')
       
  1602   > def printprevset(ui, repo):
       
  1603   >     alias = {}
       
  1604   >     p = encoding.environ.get('P')
       
  1605   >     if p:
       
  1606   >         alias['P'] = p
       
  1607   >     revs = repo.anyrevs(['P'], user=True, localalias=alias)
       
  1608   >     ui.write('P=%r\n' % list(revs))
       
  1609   > EOF
       
  1610 
       
  1611   $ cat >> .hg/hgrc <<EOF
       
  1612   > custompredicate = !
       
  1613   > printprevset = $TESTTMP/printprevset.py
       
  1614   > EOF
       
  1615 
       
  1616   $ hg --config revsetalias.P=1 printprevset
       
  1617   P=[1]
       
  1618   $ P=3 hg --config revsetalias.P=2 printprevset
       
  1619   P=[3]
       
  1620 
       
  1621   $ cd ..
       
  1622 
       
  1623 Test obsstore related revsets
       
  1624 
       
  1625   $ hg init repo1
       
  1626   $ cd repo1
       
  1627   $ cat <<EOF >> .hg/hgrc
       
  1628   > [experimental]
       
  1629   > stabilization = createmarkers
       
  1630   > EOF
       
  1631 
       
  1632   $ hg debugdrawdag <<'EOS'
       
  1633   >        F G
       
  1634   >        |/    # split: B -> E, F
       
  1635   > B C D  E     # amend: B -> C -> D
       
  1636   >  \|/   |     # amend: F -> G
       
  1637   >   A    A  Z  # amend: A -> Z
       
  1638   > EOS
       
  1639 
       
  1640   $ hg log -r 'successors(Z)' -T '{desc}\n'
       
  1641   Z
       
  1642 
       
  1643   $ hg log -r 'successors(F)' -T '{desc}\n'
       
  1644   F
       
  1645   G
       
  1646 
       
  1647   $ hg tag --remove --local C D E F G
       
  1648 
       
  1649   $ hg log -r 'successors(B)' -T '{desc}\n'
       
  1650   B
       
  1651   D
       
  1652   E
       
  1653   G
       
  1654 
       
  1655   $ hg log -r 'successors(B)' -T '{desc}\n' --hidden
       
  1656   B
       
  1657   C
       
  1658   D
       
  1659   E
       
  1660   F
       
  1661   G
       
  1662 
       
  1663   $ hg log -r 'successors(B)-obsolete()' -T '{desc}\n' --hidden
       
  1664   D
       
  1665   E
       
  1666   G
       
  1667 
       
  1668   $ hg log -r 'successors(B+A)-contentdivergent()' -T '{desc}\n'
       
  1669   A
       
  1670   Z
       
  1671   B
       
  1672 
       
  1673   $ hg log -r 'successors(B+A)-contentdivergent()-obsolete()' -T '{desc}\n'
       
  1674   Z
       
  1675 
       
  1676 Test `draft() & ::x` optimization
       
  1677 
       
  1678   $ hg init $TESTTMP/repo2
       
  1679   $ cd $TESTTMP/repo2
       
  1680   $ hg debugdrawdag <<'EOS'
       
  1681   >   P5 S1
       
  1682   >    |  |
       
  1683   > S2 | D3
       
  1684   >   \|/
       
  1685   >   P4
       
  1686   >    |
       
  1687   >   P3 D2
       
  1688   >    |  |
       
  1689   >   P2 D1
       
  1690   >    |/
       
  1691   >   P1
       
  1692   >    |
       
  1693   >   P0
       
  1694   > EOS
       
  1695   $ hg phase --public -r P5
       
  1696   $ hg phase --force --secret -r S1+S2
       
  1697   $ hg log -G -T '{rev} {desc} {phase}' -r 'sort(all(), topo, topo.firstbranch=P5)'
       
  1698   o  8 P5 public
       
  1699   |
       
  1700   | o  10 S1 secret
       
  1701   | |
       
  1702   | o  7 D3 draft
       
  1703   |/
       
  1704   | o  9 S2 secret
       
  1705   |/
       
  1706   o  6 P4 public
       
  1707   |
       
  1708   o  5 P3 public
       
  1709   |
       
  1710   o  3 P2 public
       
  1711   |
       
  1712   | o  4 D2 draft
       
  1713   | |
       
  1714   | o  2 D1 draft
       
  1715   |/
       
  1716   o  1 P1 public
       
  1717   |
       
  1718   o  0 P0 public
       
  1719   
       
  1720   $ hg debugrevspec --verify -p analyzed -p optimized 'draft() & ::(((S1+D1+P5)-D3)+S2)'
       
  1721   * analyzed:
       
  1722   (and
       
  1723     (func
       
  1724       (symbol 'draft')
       
  1725       None)
       
  1726     (func
       
  1727       (symbol 'ancestors')
       
  1728       (or
       
  1729         (list
       
  1730           (and
       
  1731             (or
       
  1732               (list
       
  1733                 (symbol 'S1')
       
  1734                 (symbol 'D1')
       
  1735                 (symbol 'P5')))
       
  1736             (not
       
  1737               (symbol 'D3')))
       
  1738           (symbol 'S2')))))
       
  1739   * optimized:
       
  1740   (func
       
  1741     (symbol '_phaseandancestors')
       
  1742     (list
       
  1743       (symbol 'draft')
       
  1744       (or
       
  1745         (list
       
  1746           (difference
       
  1747             (func
       
  1748               (symbol '_list')
       
  1749               (string 'S1\x00D1\x00P5'))
       
  1750             (symbol 'D3'))
       
  1751           (symbol 'S2')))))
       
  1752   $ hg debugrevspec --verify -p analyzed -p optimized 'secret() & ::9'
       
  1753   * analyzed:
       
  1754   (and
       
  1755     (func
       
  1756       (symbol 'secret')
       
  1757       None)
       
  1758     (func
       
  1759       (symbol 'ancestors')
       
  1760       (symbol '9')))
       
  1761   * optimized:
       
  1762   (func
       
  1763     (symbol '_phaseandancestors')
       
  1764     (list
       
  1765       (symbol 'secret')
       
  1766       (symbol '9')))
       
  1767   $ hg debugrevspec --verify -p analyzed -p optimized '7 & ( (not public()) & ::(tag()) )'
       
  1768   * analyzed:
       
  1769   (and
       
  1770     (symbol '7')
       
  1771     (and
       
  1772       (not
       
  1773         (func
       
  1774           (symbol 'public')
       
  1775           None))
       
  1776       (func
       
  1777         (symbol 'ancestors')
       
  1778         (func
       
  1779           (symbol 'tag')
       
  1780           None))))
       
  1781   * optimized:
       
  1782   (and
       
  1783     (symbol '7')
       
  1784     (func
       
  1785       (symbol '_phaseandancestors')
       
  1786       (list
       
  1787         (symbol '_notpublic')
       
  1788         (func
       
  1789           (symbol 'tag')
       
  1790           None))))
       
  1791   $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, 1)'
       
  1792   * optimized:
       
  1793   (and
       
  1794     (func
       
  1795       (symbol '_notpublic')
       
  1796       None)
       
  1797     (func
       
  1798       (symbol 'ancestors')
       
  1799       (list
       
  1800         (func
       
  1801           (symbol '_list')
       
  1802           (string 'S1\x00D2\x00P5'))
       
  1803         (symbol '1'))))
       
  1804   $ hg debugrevspec --verify -p optimized '(not public()) & ancestors(S1+D2+P5, depth=1)'
       
  1805   * optimized:
       
  1806   (and
       
  1807     (func
       
  1808       (symbol '_notpublic')
       
  1809       None)
       
  1810     (func
       
  1811       (symbol 'ancestors')
       
  1812       (list
       
  1813         (func
       
  1814           (symbol '_list')
       
  1815           (string 'S1\x00D2\x00P5'))
       
  1816         (keyvalue
       
  1817           (symbol 'depth')
       
  1818           (symbol '1')))))