[PATCH 1 of 5 v3] revset: add pattern matching to 'tag' revset expression

Matt Mackall mpm at selenic.com
Wed May 30 15:33:01 CDT 2012


On Mon, 2012-05-28 at 22:43 +0100, Simon King wrote:
> # HG changeset patch
> # User Simon King <simon at simonking.org.uk>
> # Date 1338237440 -3600
> # Node ID cffe3364b6c7540aecb04ae2ecfd72fde251c2cb
> # Parent  2ac08d8b21aa7b6e0a062afed5a3f357ccef67f9
> revset: add pattern matching to 'tag' revset expression
> 
> If the string provided to the 'tag' predicate starts with 're:', the rest
> of the string will be treated as a regular expression and matched against
> all tags in the repository.
> 
> There is a slight backwards-compatibility problem for people who actually
> have tags that start with 're:'. As a workaround, these tags can be matched
> using a 'literal:' prefix.
> 
> If no tags match the pattern, an error is raised. This matches the behaviour
> of the previous exact-match code.

This ought to be two patches. Here, I'm mostly happy with the
stringmatcher, but less happy with its use in tags:

> +        kind, pattern, matcher = _stringmatcher(pattern)
> +        s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
> +        if not s:
> +            if kind == 'literal':
> +                # i18n: "tag" is a keyword
> +                errmsg = _("tag '%s' does not exist") % pattern
> +            else:
> +                errmsg = _("no tags exist that match '%s'") % pattern
> +            raise util.Abort(errmsg)

Here we ought to instead do:

kind, pattern, matcher = _stringmatcher(pattern)
if kind == 'literal'
  # old direct lookup
else:
  # new way

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list