[PATCH 1 of 4] revset: introduce an internal `_rev` predicate for '%d' usage

Yuya Nishihara yuya at tcha.org
Sat Jan 19 06:28:08 EST 2019


On Fri, 18 Jan 2019 16:53:16 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1547817707 -3600
> #      Fri Jan 18 14:21:47 2019 +0100
> # Node ID 52d20e4fe2e3049eec58140fdcadb43528729b3d
> # Parent  4fab8a7d2d72b4d50d1d647a015d33f64c1e2e4d
> # EXP-Topic intlist
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 52d20e4fe2e3
> revset: introduce an internal `_rev` predicate for '%d' usage

Queued this for stable, thanks.

IIUC, the behavior of "%ld" was unchanged though it's inconsistent. So I think
the other 3 patches can be deferred for 5.0 cycle.

> + at predicate('_rev(number)', safe=True)
> +def _rev(repo, subset, x):
> +    # internal version of "rev(x)" that raise error if "x" is invalid
> +    # i18n: "rev" is a keyword
> +    l = getargs(x, 1, 1, _("_rev requires one argument"))

Unified "_rev" in error messages to "rev" as we'll probably want to rewrite
rev() by using _rev().

> +    try:
> +        # i18n: "rev" is a keyword
> +        l = int(getstring(l[0], _("rev requires a number")))
> +    except (TypeError, ValueError):
> +        # i18n: "rev" is a keyword
> +        raise error.ParseError(_("rev expects a number"))
> +    repo.changelog.node(l) # check that the rev exists

We'll need to catch WdirUnsupported here if we change _intlist in that way.


More information about the Mercurial-devel mailing list