On Fri, 15 Feb 2019 15:00:12 -0500, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jord...@octave.org>
> # Date 1550259811 18000
> #      Fri Feb 15 14:43:31 2019 -0500
> # Node ID 2aa9472715119f26f2e688dd9130f717113ec518
> # Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
> templatekw: add a {negrev} keyword

The word "negative revision" isn't correct, but I can't think of any better
name, and I like the feature. Queued, thanks.

Any naming idea is welcome.

> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -777,6 +777,14 @@ def showrev(context, mapping):
>      ctx = context.resource(mapping, 'ctx')
>      return scmutil.intrev(ctx)
>  
> +@templatekeyword('negrev', requires={'repo', 'ctx'})

Moved this so the functions are roughly sorted lexicographically.

> +def shownegrev(context, mapping):
> +    """Integer. The repository-local changeset negative revision number,
> +    which counts in the opposite direction."""
> +    ctx = context.resource(mapping, 'ctx')
> +    repo = context.resource(mapping, 'repo')
> +    return scmutil.intrev(ctx) - len(repo)

There are two weird cases:

 -r 'wdir()' => not negative
 -r null => unsupported negative integer (out of range)

Maybe return None for these?
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to