Patchwork [V2] help: avoid using "$n" parameter in revsetalias example

login
register
mail settings
Submitter Yuya Nishihara
Date April 14, 2016, 4:02 p.m.
Message ID <ddc554c9197094594d9e.1460649744@mimosa>
Download mbox | patch
Permalink /patch/14626/
State Accepted
Headers show

Comments

Yuya Nishihara - April 14, 2016, 4:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1458985856 -32400
#      Sat Mar 26 18:50:56 2016 +0900
# Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
# Parent  08da136a18335f677751512883156d3f246bb3c7
help: avoid using "$n" parameter in revsetalias example

Because parsing "$n" requires a crafted tokenizer, it exists only for backward
compatibility (as documented in revset._tokenizealias.) This patch updates the
examples so that users are encouraged to use symbolic names instead of "$n"s.

I'm going to implement alias expansion in templater, which won't support "$n"
parameters to make my life easier. Templater is more complicated than revset
because tokenizer and parser call each other.
Simon Farnsworth - April 14, 2016, 6:56 p.m.
Looks good to me.

On 14/04/2016 17:02, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1458985856 -32400
> #      Sat Mar 26 18:50:56 2016 +0900
> # Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
> # Parent  08da136a18335f677751512883156d3f246bb3c7
> help: avoid using "$n" parameter in revsetalias example
>
> Because parsing "$n" requires a crafted tokenizer, it exists only for backward
> compatibility (as documented in revset._tokenizealias.) This patch updates the
> examples so that users are encouraged to use symbolic names instead of "$n"s.
>
> I'm going to implement alias expansion in templater, which won't support "$n"
> parameters to make my life easier. Templater is more complicated than revset
> because tokenizer and parser call each other.
>
> diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
> --- a/mercurial/help/revsets.txt
> +++ b/mercurial/help/revsets.txt
> @@ -66,7 +66,7 @@ existing predicates or other aliases. An
>     <alias> = <definition>
>
>   in the ``revsetalias`` section of a Mercurial configuration file. Arguments
> -of the form `$1`, `$2`, etc. are substituted from the alias into the
> +of the form `a1`, `a2`, etc. are substituted from the alias into the
>   definition.
>
>   For example,
> @@ -75,8 +75,8 @@ For example,
>
>     [revsetalias]
>     h = heads()
> -  d($1) = sort($1, date)
> -  rs($1, $2) = reverse(sort($1, $2))
> +  d(s) = sort(s, date)
> +  rs(s, k) = reverse(sort(s, k))
>
>   defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
>   exactly equivalent to ``reverse(sort(0:tip, author))``.
> @@ -85,14 +85,14 @@ An infix operator ``##`` can concatenate
>   one string. For example::
>
>     [revsetalias]
> -  issue($1) = grep(r'\bissue[ :]?' ## $1 ## r'\b|\bbug\(' ## $1 ## r'\)')
> +  issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
>
>   ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
>   in this case. This matches against all of "issue 1234", "issue:1234",
>   "issue1234" and "bug(1234)".
>
>   All other prefix, infix and postfix operators have lower priority than
> -``##``. For example, ``$1 ## $2~2`` is equivalent to ``($1 ## $2)~2``.
> +``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
>
>   Command line equivalents for :hg:`log`::
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=mEgSWILcY4c4W3zjApBQLA&m=oNXHMCCdOF3Ezpc1crraTlB9AGyXexPYotVfTUZgSMM&s=GQy53sc9D5B1YPdgbbqRMW4b9h_ZDhiIukuY5MfaDLI&e=
>
Augie Fackler - April 14, 2016, 10:02 p.m.
On Thu, Apr 14, 2016 at 07:56:31PM +0100, Simon Farnsworth wrote:
> Looks good to me.

queued this, thanks

>
> On 14/04/2016 17:02, Yuya Nishihara wrote:
> ># HG changeset patch
> ># User Yuya Nishihara <yuya@tcha.org>
> ># Date 1458985856 -32400
> >#      Sat Mar 26 18:50:56 2016 +0900
> ># Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
> ># Parent  08da136a18335f677751512883156d3f246bb3c7
> >help: avoid using "$n" parameter in revsetalias example
> >
> >Because parsing "$n" requires a crafted tokenizer, it exists only for backward
> >compatibility (as documented in revset._tokenizealias.) This patch updates the
> >examples so that users are encouraged to use symbolic names instead of "$n"s.
> >
> >I'm going to implement alias expansion in templater, which won't support "$n"
> >parameters to make my life easier. Templater is more complicated than revset
> >because tokenizer and parser call each other.
> >
> >diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
> >--- a/mercurial/help/revsets.txt
> >+++ b/mercurial/help/revsets.txt
> >@@ -66,7 +66,7 @@ existing predicates or other aliases. An
> >    <alias> = <definition>
> >
> >  in the ``revsetalias`` section of a Mercurial configuration file. Arguments
> >-of the form `$1`, `$2`, etc. are substituted from the alias into the
> >+of the form `a1`, `a2`, etc. are substituted from the alias into the
> >  definition.
> >
> >  For example,
> >@@ -75,8 +75,8 @@ For example,
> >
> >    [revsetalias]
> >    h = heads()
> >-  d($1) = sort($1, date)
> >-  rs($1, $2) = reverse(sort($1, $2))
> >+  d(s) = sort(s, date)
> >+  rs(s, k) = reverse(sort(s, k))
> >
> >  defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
> >  exactly equivalent to ``reverse(sort(0:tip, author))``.
> >@@ -85,14 +85,14 @@ An infix operator ``##`` can concatenate
> >  one string. For example::
> >
> >    [revsetalias]
> >-  issue($1) = grep(r'\bissue[ :]?' ## $1 ## r'\b|\bbug\(' ## $1 ## r'\)')
> >+  issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
> >
> >  ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
> >  in this case. This matches against all of "issue 1234", "issue:1234",
> >  "issue1234" and "bug(1234)".
> >
> >  All other prefix, infix and postfix operators have lower priority than
> >-``##``. For example, ``$1 ## $2~2`` is equivalent to ``($1 ## $2)~2``.
> >+``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
> >
> >  Command line equivalents for :hg:`log`::
> >
> >_______________________________________________
> >Mercurial-devel mailing list
> >Mercurial-devel@mercurial-scm.org
> >https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=mEgSWILcY4c4W3zjApBQLA&m=oNXHMCCdOF3Ezpc1crraTlB9AGyXexPYotVfTUZgSMM&s=GQy53sc9D5B1YPdgbbqRMW4b9h_ZDhiIukuY5MfaDLI&e=
> >
>
> --
> Simon Farnsworth
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - April 18, 2016, 1:04 p.m.
On Fri, 15 Apr 2016 01:02:24 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1458985856 -32400
> #      Sat Mar 26 18:50:56 2016 +0900
> # Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
> # Parent  08da136a18335f677751512883156d3f246bb3c7
> help: avoid using "$n" parameter in revsetalias example
> 
> Because parsing "$n" requires a crafted tokenizer, it exists only for backward
> compatibility (as documented in revset._tokenizealias.) This patch updates the
> examples so that users are encouraged to use symbolic names instead of "$n"s.
> 
> I'm going to implement alias expansion in templater, which won't support "$n"
> parameters to make my life easier. Templater is more complicated than revset
> because tokenizer and parser call each other.
> 
> diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
> --- a/mercurial/help/revsets.txt
> +++ b/mercurial/help/revsets.txt
> @@ -66,7 +66,7 @@ existing predicates or other aliases. An
>    <alias> = <definition>
>  
>  in the ``revsetalias`` section of a Mercurial configuration file. Arguments
> -of the form `$1`, `$2`, etc. are substituted from the alias into the
> +of the form `a1`, `a2`, etc. are substituted from the alias into the
>  definition.

This seems missed and floating in the committed repo. Should I rebase it to
stable or drop it?
Augie Fackler - April 18, 2016, 1:42 p.m.
> On Apr 18, 2016, at 09:04, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Fri, 15 Apr 2016 01:02:24 +0900, Yuya Nishihara wrote:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya@tcha.org>
>> # Date 1458985856 -32400
>> #      Sat Mar 26 18:50:56 2016 +0900
>> # Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
>> # Parent  08da136a18335f677751512883156d3f246bb3c7
>> help: avoid using "$n" parameter in revsetalias example
>> 
>> Because parsing "$n" requires a crafted tokenizer, it exists only for backward
>> compatibility (as documented in revset._tokenizealias.) This patch updates the
>> examples so that users are encouraged to use symbolic names instead of "$n"s.
>> 
>> I'm going to implement alias expansion in templater, which won't support "$n"
>> parameters to make my life easier. Templater is more complicated than revset
>> because tokenizer and parser call each other.
>> 
>> diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
>> --- a/mercurial/help/revsets.txt
>> +++ b/mercurial/help/revsets.txt
>> @@ -66,7 +66,7 @@ existing predicates or other aliases. An
>>   <alias> = <definition>
>> 
>> in the ``revsetalias`` section of a Mercurial configuration file. Arguments
>> -of the form `$1`, `$2`, etc. are substituted from the alias into the
>> +of the form `a1`, `a2`, etc. are substituted from the alias into the
>> definition.
> 
> This seems missed and floating in the committed repo. Should I rebase it to
> stable or drop it?

That's really up to mpm for now - I'd say let's just take it, but we could also just do it during the start of the 3.9 cycle.

AF

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Matt Mackall - April 18, 2016, 3:31 p.m.
On Mon, 2016-04-18 at 09:42 -0400, Augie Fackler wrote:
> > 
> > On Apr 18, 2016, at 09:04, Yuya Nishihara <yuya@tcha.org> wrote:
> > 
> > On Fri, 15 Apr 2016 01:02:24 +0900, Yuya Nishihara wrote:
> > > 
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1458985856 -32400
> > > #      Sat Mar 26 18:50:56 2016 +0900
> > > # Node ID ddc554c9197094594d9e5fdb40774f04fa25f3a5
> > > # Parent  08da136a18335f677751512883156d3f246bb3c7
> > > help: avoid using "$n" parameter in revsetalias example
> > > 
> > > Because parsing "$n" requires a crafted tokenizer, it exists only for
> > > backward
> > > compatibility (as documented in revset._tokenizealias.) This patch updates
> > > the
> > > examples so that users are encouraged to use symbolic names instead of
> > > "$n"s.
> > > 
> > > I'm going to implement alias expansion in templater, which won't support
> > > "$n"
> > > parameters to make my life easier. Templater is more complicated than
> > > revset
> > > because tokenizer and parser call each other.
> > > 
> > > diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
> > > --- a/mercurial/help/revsets.txt
> > > +++ b/mercurial/help/revsets.txt
> > > @@ -66,7 +66,7 @@ existing predicates or other aliases. An
> > >   <alias> = <definition>
> > > 
> > > in the ``revsetalias`` section of a Mercurial configuration file.
> > > Arguments
> > > -of the form `$1`, `$2`, etc. are substituted from the alias into the
> > > +of the form `a1`, `a2`, etc. are substituted from the alias into the
> > > definition.
> > This seems missed and floating in the committed repo. Should I rebase it to
> > stable or drop it?
> That's really up to mpm for now - I'd say let's just take it, but we could
> also just do it during the start of the 3.9 cycle.

I'll move it to stable. I'm ok with small doc improvements on stable, but I'd
like to avoid a significant amount of churn there.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
--- a/mercurial/help/revsets.txt
+++ b/mercurial/help/revsets.txt
@@ -66,7 +66,7 @@  existing predicates or other aliases. An
   <alias> = <definition>
 
 in the ``revsetalias`` section of a Mercurial configuration file. Arguments
-of the form `$1`, `$2`, etc. are substituted from the alias into the
+of the form `a1`, `a2`, etc. are substituted from the alias into the
 definition.
 
 For example,
@@ -75,8 +75,8 @@  For example,
 
   [revsetalias]
   h = heads()
-  d($1) = sort($1, date)
-  rs($1, $2) = reverse(sort($1, $2))
+  d(s) = sort(s, date)
+  rs(s, k) = reverse(sort(s, k))
 
 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
 exactly equivalent to ``reverse(sort(0:tip, author))``.
@@ -85,14 +85,14 @@  An infix operator ``##`` can concatenate
 one string. For example::
 
   [revsetalias]
-  issue($1) = grep(r'\bissue[ :]?' ## $1 ## r'\b|\bbug\(' ## $1 ## r'\)')
+  issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
 
 ``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
 in this case. This matches against all of "issue 1234", "issue:1234",
 "issue1234" and "bug(1234)".
 
 All other prefix, infix and postfix operators have lower priority than
-``##``. For example, ``$1 ## $2~2`` is equivalent to ``($1 ## $2)~2``.
+``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
 
 Command line equivalents for :hg:`log`::