Patchwork [2,of,8] revset: remove a rare usage of "%d" for a non-revision item

login
register
mail settings
Submitter Boris Feld
Date Jan. 11, 2019, 11:29 a.m.
Message ID <a71dd521a4a53b19e89f.1547206144@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37659/
State Accepted
Headers show

Comments

Boris Feld - Jan. 11, 2019, 11:29 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1547132233 -3600
#      Thu Jan 10 15:57:13 2019 +0100
# Node ID a71dd521a4a53b19e89f9ad9c20fb85e604783c6
# Parent  348c85f511e3afa0a38943581790cd5dae308d21
# EXP-Topic revs-efficiency
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a71dd521a4a5
revset: remove a rare usage of "%d" for a non-revision item

In order to fix an important bug, we are about to narrow the semantic of "%d"
in revset. This is one of the few exceptions that we need to get rid of before
being able to fix the bug.

See the later semantic narrowing changeset for full rationale on the semantic
change.
Yuya Nishihara - Jan. 12, 2019, 3:54 a.m.
On Fri, 11 Jan 2019 12:29:04 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1547132233 -3600
> #      Thu Jan 10 15:57:13 2019 +0100
> # Node ID a71dd521a4a53b19e89f9ad9c20fb85e604783c6
> # Parent  348c85f511e3afa0a38943581790cd5dae308d21
> # EXP-Topic revs-efficiency
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a71dd521a4a5
> revset: remove a rare usage of "%d" for a non-revision item
> 
> In order to fix an important bug, we are about to narrow the semantic of "%d"
> in revset. This is one of the few exceptions that we need to get rid of before
> being able to fix the bug.
> 
> See the later semantic narrowing changeset for full rationale on the semantic
> change.
> 
> diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
> --- a/mercurial/wireprotov2server.py
> +++ b/mercurial/wireprotov2server.py
> @@ -823,8 +823,8 @@ def resolvenodes(repo, revisions):
>                          '%s key not present in changesetexplicitdepth revision '
>                          'specifier', (key,))
>  
> -            for rev in repo.revs(b'ancestors(%ln, %d)', spec[b'nodes'],
> -                                 spec[b'depth'] - 1):
> +            query = b'ancestors(%%ln, %d)' % (spec[b'depth'] - 1)
> +            for rev in repo.revs(query, spec[b'nodes']):

I'm okay with this, but we could also use "%s" if you want to avid the %%
escape. "1" is a valid integer in revset language.

Patch

diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -823,8 +823,8 @@  def resolvenodes(repo, revisions):
                         '%s key not present in changesetexplicitdepth revision '
                         'specifier', (key,))
 
-            for rev in repo.revs(b'ancestors(%ln, %d)', spec[b'nodes'],
-                                 spec[b'depth'] - 1):
+            query = b'ancestors(%%ln, %d)' % (spec[b'depth'] - 1)
+            for rev in repo.revs(query, spec[b'nodes']):
                 node = cl.node(rev)
 
                 if node not in seen: