D5813: revset: add expect to check the size of a set
Yuya Nishihara
yuya at tcha.org
Mon Feb 11 02:12:05 UTC 2019
Getting close.
On Sun, 10 Feb 2019 05:19:55 +0000, navaneeth.suresh (Navaneeth Suresh) wrote:
> + $ log 'expectsize(0:2, 2:4)'
Can you test `:max`, `min:`, and `:` (no constraint)?
They shouldn't fail.
> + at predicate('expectsize(set[, size])', safe=True, takeorder=True)
> +def expectrevsetsize(repo, subset, x, order):
> + """Abort if the revset doesn't expect given size"""
> + args = getargsdict(x, 'expect', 'set size')
> + size = args.get('size')
> + minsize = None
> + maxsize = None
> + err = ''
> + if size is not None:
> + minsize, maxsize = getintrange(size,
> + _('expectsize requires a size range'
> + ' or a positive integer'),
> + _('size range bounds must be integers'))
> + if minsize < 0 or maxsize < 0:
> + raise error.ParseError(_('negative size'))
> + if size is None or 'set' not in args:
> + raise error.ParseError(_('invalid set of arguments'))
Nit: `if size is not None` (and the `size` variable itself) can be removed
if we checked the invalid set of arguments first.
More information about the Mercurial-devel
mailing list