comparison tests/test-revset.t @ 41680:8185c8abce87

revset: add expectsize to check the size of a set `expectsize(<set>, <int>)` revset fails if `<set>` is not exactly `<int>` elements. `expectsize(<set>, <min>:<max>)` revset fails if `<set>` is not exactly between `<min>` and `<max>` inclusive. This then allows an alias for `hg next` to be `update -r one(children(.))` with sane failure behavior, and also makes some other scripting tasks a little less difficult. (Summary from WeShouldDoThat) Differential Revision: https://phab.mercurial-scm.org/D5813
author Navaneeth Suresh <navaneeths1998@gmail.com>
date Sun, 03 Feb 2019 19:10:39 +0530
parents 13f7a6a4f0db
children c70bdd222dcd
comparison
equal deleted inserted replaced
41679:91701785c2c5 41680:8185c8abce87
2976 (symbol 'rev') 2976 (symbol 'rev')
2977 (symbol '0')))) 2977 (symbol '0'))))
2978 * set: 2978 * set:
2979 <baseset+ [0]> 2979 <baseset+ [0]>
2980 0 2980 0
2981
2982 abort if the revset doesn't expect given size
2983 $ log 'expectsize()'
2984 hg: parse error: invalid set of arguments
2985 [255]
2986 $ log 'expectsize(0:2, a)'
2987 hg: parse error: expectsize requires a size range or a positive integer
2988 [255]
2989 $ log 'expectsize(0:2, 3)'
2990 0
2991 1
2992 2
2993
2994 $ log 'expectsize(2:0, 3)'
2995 2
2996 1
2997 0
2998 $ log 'expectsize(0:1, 1)'
2999 abort: revset size mismatch. expected 1, got 2!
3000 [255]
3001 $ log 'expectsize(0:4, -1)'
3002 hg: parse error: negative size
3003 [255]
3004 $ log 'expectsize(0:2, 2:4)'
3005 0
3006 1
3007 2
3008 $ log 'expectsize(0:1, 3:5)'
3009 abort: revset size mismatch. expected between 3 and 5, got 2!
3010 [255]
3011 $ log 'expectsize(0:1, -1:2)'
3012 hg: parse error: negative size
3013 [255]
3014 $ log 'expectsize(0:1, 1:-2)'
3015 hg: parse error: negative size
3016 [255]
3017 $ log 'expectsize(0:2, a:4)'
3018 hg: parse error: size range bounds must be integers
3019 [255]
3020 $ log 'expectsize(0:2, 2:b)'
3021 hg: parse error: size range bounds must be integers
3022 [255]
3023 $ log 'expectsize(0:2, 2:)'
3024 0
3025 1
3026 2
3027 $ log 'expectsize(0:2, :5)'
3028 0
3029 1
3030 2
3031 $ log 'expectsize(0:2, :)'
3032 0
3033 1
3034 2
3035 $ log 'expectsize(0:2, 4:)'
3036 abort: revset size mismatch. expected between 4 and 11, got 3!
3037 [255]
3038 $ log 'expectsize(0:2, :2)'
3039 abort: revset size mismatch. expected between 0 and 2, got 3!
3040 [255]