[PATCH 4 of 4] revset: introduce a 'foo#stack[n]' subscript relation to access stack revisions

Yuya Nishihara yuya at tcha.org
Mon Sep 23 08:58:47 EDT 2019


On Mon, 23 Sep 2019 10:39:52 +0700, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1569139969 -25200
> #      Sun Sep 22 15:12:49 2019 +0700
> # Node ID ab8f097abacb8ce0f9cea2bce0924bb2fd3261a2
> # Parent  07af98a1e730c1ffa6911c9ab2cdcc06d4ffe52d
> # EXP-Topic stack-object
> revset: introduce a 'foo#stack[n]' subscript relation to access stack revisions
> 
> The idea behind making n = 0 cases special is that stack base should be
> accessible, but only when users ask for it explicitly.

> +def stackrel(repo, subset, x, rel, z, order):
> +    a, b = getintrange(z,
> +                       _('relation subscript must be an integer or a range'),
> +                       _('relation subscript bounds must be integers'),
> +                       deffirst=None,
> +                       deflast=None)
> +
> +    s = getset(repo, fullreposet(repo), x)
> +    if not s:
> +        return baseset()
> +
> +    def getrange(st, a, b):
> +        start = 1 if a is None else a
> +        end = len(st.indexedrevs) if b is None else b + 1

I feel it's weird that stack[:] doesn't include stack[0].


More information about the Mercurial-devel mailing list