[PATCH] revset: move subscript relation functions to its own dict

Yuya Nishihara yuya at tcha.org
Thu Dec 13 06:25:54 EST 2018


On Thu, 13 Dec 2018 19:03:22 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1544692737 -28800
> #      Thu Dec 13 17:18:57 2018 +0800
> # Node ID ae0a18541e4354201303032cd37ccc819d64c5a0
> # Parent  008f3491dc5377e9e6f210e0a3f161323049db5d
> revset: move subscript relation functions to its own dict

Queued, thanks.

> -    # TODO: perhaps this should be a table of relation functions
> -    if rel in ('g', 'generations'):
> -        # TODO: support range, rewrite tests, and drop startdepth argument
> -        # from ancestors() and descendants() predicates
> -        if n <= 0:
> -            n = -n
> -            return _ancestors(repo, subset, x, startdepth=n, stopdepth=n + 1)
> -        else:
> -            return _descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
> +    if rel in subscriptrelations:
> +        return subscriptrelations[rel](repo, subset, x, rel, n, order)
>  
> -    raise error.UnknownIdentifier(rel, ['generations'])
> +    relnames = (n for n in subscriptrelations.keys() if len(n) > 1)

Changed this to list comprehension, and renamed the variable to silence
pyflakes. We shouldn't expect that the exception attribute would be consumed
only once.

> +    raise error.UnknownIdentifier(rel, relnames)


More information about the Mercurial-devel mailing list