Patchwork revset: add "reversed" as a synonym for "reverse"

login
register
mail settings
Submitter Daniel Colascione (SEATTLE)
Date Oct. 12, 2015, 9:12 p.m.
Message ID <561C2257.6000001@fb.com>
Download mbox | patch
Permalink /patch/10976/
State Deferred
Delegated to: Augie Fackler
Headers show

Comments

Daniel Colascione (SEATTLE) - Oct. 12, 2015, 9:12 p.m.
# HG changeset patch
# User Daniel Colascione <dancol@fb.com>
# Date 1444684285 25200
#      Mon Oct 12 14:11:25 2015 -0700
# Node ID 348e3483614878ac1049c836f4f3bb36127cae27
# Parent  a3fcc8e3136bd19012d28b863d6bf4429948c573
revset: add "reversed" as synonym for "reverse"
Augie Fackler - Oct. 13, 2015, 3:22 p.m.
On Mon, Oct 12, 2015 at 02:12:55PM -0700, Daniel Colascione (SEATTLE) wrote:
> # HG changeset patch
> # User Daniel Colascione <dancol@fb.com>
> # Date 1444684285 25200
> #      Mon Oct 12 14:11:25 2015 -0700
> # Node ID 348e3483614878ac1049c836f4f3bb36127cae27
> # Parent  a3fcc8e3136bd19012d28b863d6bf4429948c573
> revset: add "reversed" as synonym for "reverse"

I'm hesitant to do this, what's the benefit?

I get that it matches Python, but I'm not sure that merits the
duplicated name. Besides, hg tells you what you meant:

augie$ hg log -r 'reversed(::@)'
hg: parse error: unknown identifier: reversed
(did you mean one of removes, reverse?)

>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -2193,6 +2193,7 @@
>      "removes": removes,
>      "rev": rev,
>      "reverse": reverse,
> +    "reversed": reverse,
>      "roots": roots,
>      "sort": sort,
>      "secret": secret,
> @@ -2422,7 +2423,7 @@
>              w = 100 # very slow
>          elif f == "ancestor":
>              w = 1 * smallbonus
> -        elif f in "reverse limit first _intlist":
> +        elif f in "reverse reversed limit first _intlist":
>              w = 0
>          elif f in "sort":
>              w = 10 # assume most sorts look at changelog
>
>



> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Daniel Colascione (SEATTLE) - Oct. 14, 2015, 3:13 a.m.
On 10/13/2015 08:22 AM, Augie Fackler wrote:
> On Mon, Oct 12, 2015 at 02:12:55PM -0700, Daniel Colascione (SEATTLE) wrote:
>> # HG changeset patch
>> # User Daniel Colascione <dancol@fb.com>
>> # Date 1444684285 25200
>> #      Mon Oct 12 14:11:25 2015 -0700
>> # Node ID 348e3483614878ac1049c836f4f3bb36127cae27
>> # Parent  a3fcc8e3136bd19012d28b863d6bf4429948c573
>> revset: add "reversed" as synonym for "reverse"
> 
> I'm hesitant to do this, what's the benefit?
> 
> I get that it matches Python, but I'm not sure that merits the
> duplicated name. Besides, hg tells you what you meant:
> 
> augie$ hg log -r 'reversed(::@)'
> hg: parse error: unknown identifier: reversed
> (did you mean one of removes, reverse?)

I write a lot of Python. On the day I wrote this patch, I found myself
typing "reversed" instead of "reverse" three times in a single day. Of
course fixing the problem is trivial, but so is the patch, which can
reduce annoyance without costing anything.
Matt Mackall - Oct. 16, 2015, 5:02 p.m.
On Tue, 2015-10-13 at 20:13 -0700, Daniel Colascione (SEATTLE) wrote:
> On 10/13/2015 08:22 AM, Augie Fackler wrote:
> > On Mon, Oct 12, 2015 at 02:12:55PM -0700, Daniel Colascione (SEATTLE) wrote:
> >> # HG changeset patch
> >> # User Daniel Colascione <dancol@fb.com>
> >> # Date 1444684285 25200
> >> #      Mon Oct 12 14:11:25 2015 -0700
> >> # Node ID 348e3483614878ac1049c836f4f3bb36127cae27
> >> # Parent  a3fcc8e3136bd19012d28b863d6bf4429948c573
> >> revset: add "reversed" as synonym for "reverse"
> > 
> > I'm hesitant to do this, what's the benefit?
> > 
> > I get that it matches Python, but I'm not sure that merits the
> > duplicated name. Besides, hg tells you what you meant:
> > 
> > augie$ hg log -r 'reversed(::@)'
> > hg: parse error: unknown identifier: reversed
> > (did you mean one of removes, reverse?)
> 
> I write a lot of Python. On the day I wrote this patch, I found myself
> typing "reversed" instead of "reverse" three times in a single day. Of
> course fixing the problem is trivial, but so is the patch, which can
> reduce annoyance without costing anything.

I'm basically fine with this idea because we've already got a bunch of
aliases for commands. This patch does however miss two things:

- not added to safesymbols (allowed for remote queries)
- appears twice in the help

The right way to implement this is probably something like we've done
for commands: add a smart decorator that knows how to insert a method
into all the relevant tables.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2193,6 +2193,7 @@ 
     "removes": removes,
     "rev": rev,
     "reverse": reverse,
+    "reversed": reverse,
     "roots": roots,
     "sort": sort,
     "secret": secret,
@@ -2422,7 +2423,7 @@ 
             w = 100 # very slow
         elif f == "ancestor":
             w = 1 * smallbonus
-        elif f in "reverse limit first _intlist":
+        elif f in "reverse reversed limit first _intlist":
             w = 0
         elif f in "sort":
             w = 10 # assume most sorts look at changelog