Patchwork [2,of,2,STABLE] revset: skip old style lookup if external whitespace are detected

login
register
mail settings
Submitter Boris Feld
Date Feb. 12, 2018, 4:19 p.m.
Message ID <475525edc7da195b7df9.1518452367@FB>
Download mbox | patch
Permalink /patch/27669/
State Superseded
Headers show

Comments

Boris Feld - Feb. 12, 2018, 4:19 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1518448909 -3600
#      Mon Feb 12 16:21:49 2018 +0100
# Branch stable
# Node ID 475525edc7da195b7df93c980df322eacb0a41bb
# Parent  23d835f2d32dfc2aac772a443d2061a57a8aa997
# EXP-Topic noname
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 475525edc7da
revset: skip old style lookup if external whitespace are detected

Since label cannot contains leading or trailing whitespace we can skip looking
for them. This is useful in repository with slow labels (eg: special type of
tags). Short command running on a specific revision can benefit from such
shortcut.

eg on a repository where loading tags take 0.4s:

1: hg log --template '{node}\n' --rev 'rev(0)'
   0.560 seconds

2: hg log --template '{node}\n' --rev ' rev(0)'
   0.109 seconds
Boris FELD - Feb. 12, 2018, 4:20 p.m.
Just saw that the changesets are on stable somehow, sorry ignore this, I 
will send a V2.


On 12/02/2018 17:19, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1518448909 -3600
> #      Mon Feb 12 16:21:49 2018 +0100
> # Branch stable
> # Node ID 475525edc7da195b7df93c980df322eacb0a41bb
> # Parent  23d835f2d32dfc2aac772a443d2061a57a8aa997
> # EXP-Topic noname
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 475525edc7da
> revset: skip old style lookup if external whitespace are detected
>
> Since label cannot contains leading or trailing whitespace we can skip looking
> for them. This is useful in repository with slow labels (eg: special type of
> tags). Short command running on a specific revision can benefit from such
> shortcut.
>
> eg on a repository where loading tags take 0.4s:
>
> 1: hg log --template '{node}\n' --rev 'rev(0)'
>     0.560 seconds
>
> 2: hg log --template '{node}\n' --rev ' rev(0)'
>     0.109 seconds
>
> diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
> --- a/mercurial/revsetlang.py
> +++ b/mercurial/revsetlang.py
> @@ -96,7 +96,7 @@ def tokenize(program, lookup=None, symin
>           # attempt to parse old-style ranges first to deal with
>           # things like old-tag which contain query metacharacters
>           parts = program.split(':', 1)
> -        if all(lookup(sym) for sym in parts if sym):
> +        if all((sym.strip() == sym and lookup(sym)) for sym in parts if sym):
>               if parts[0]:
>                   yield ('symbol', parts[0], 0)
>               if len(parts) > 1:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -96,7 +96,7 @@  def tokenize(program, lookup=None, symin
         # attempt to parse old-style ranges first to deal with
         # things like old-tag which contain query metacharacters
         parts = program.split(':', 1)
-        if all(lookup(sym) for sym in parts if sym):
+        if all((sym.strip() == sym and lookup(sym)) for sym in parts if sym):
             if parts[0]:
                 yield ('symbol', parts[0], 0)
             if len(parts) > 1: