Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/tests/test-revset.t Mon Feb 11 11:18:37 2019 -0500 +++ b/tests/test-revset.t Sun Feb 03 19:10:39 2019 +0530 @@ -2978,3 +2978,63 @@ * set: <baseset+ [0]> 0 + +abort if the revset doesn't expect given size + $ log 'expectsize()' + hg: parse error: invalid set of arguments + [255] + $ log 'expectsize(0:2, a)' + hg: parse error: expectsize requires a size range or a positive integer + [255] + $ log 'expectsize(0:2, 3)' + 0 + 1 + 2 + + $ log 'expectsize(2:0, 3)' + 2 + 1 + 0 + $ log 'expectsize(0:1, 1)' + abort: revset size mismatch. expected 1, got 2! + [255] + $ log 'expectsize(0:4, -1)' + hg: parse error: negative size + [255] + $ log 'expectsize(0:2, 2:4)' + 0 + 1 + 2 + $ log 'expectsize(0:1, 3:5)' + abort: revset size mismatch. expected between 3 and 5, got 2! + [255] + $ log 'expectsize(0:1, -1:2)' + hg: parse error: negative size + [255] + $ log 'expectsize(0:1, 1:-2)' + hg: parse error: negative size + [255] + $ log 'expectsize(0:2, a:4)' + hg: parse error: size range bounds must be integers + [255] + $ log 'expectsize(0:2, 2:b)' + hg: parse error: size range bounds must be integers + [255] + $ log 'expectsize(0:2, 2:)' + 0 + 1 + 2 + $ log 'expectsize(0:2, :5)' + 0 + 1 + 2 + $ log 'expectsize(0:2, :)' + 0 + 1 + 2 + $ log 'expectsize(0:2, 4:)' + abort: revset size mismatch. expected between 4 and 11, got 3! + [255] + $ log 'expectsize(0:2, :2)' + abort: revset size mismatch. expected between 0 and 2, got 3! + [255]