tests/test-revset.t
changeset 34126 af13097b44dd
parent 34073 7bbc4e113e5f
child 34866 1644623ab096
equal deleted inserted replaced
34125:57dc78d757ff 34126:af13097b44dd
  2735   $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
  2735   $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
  2736   0 b12  m111 u112 111 10800
  2736   0 b12  m111 u112 111 10800
  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')))))