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