Patchwork [11,of,12] templatekw: add a keyword to list all labels

login
register
mail settings
Submitter Sean Farley
Date Aug. 18, 2014, 9:18 p.m.
Message ID <e1ab9da20be237323a13.1408396687@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/5469/
State Changes Requested
Headers show

Comments

Sean Farley - Aug. 18, 2014, 9:18 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1408394525 18000
#      Mon Aug 18 15:42:05 2014 -0500
# Node ID e1ab9da20be237323a1340efa16b58b03525596f
# Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
templatekw: add a keyword to list all labels
Pierre-Yves David - Aug. 21, 2014, 8 a.m.
On 08/18/2014 02:18 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1408394525 18000
> #      Mon Aug 18 15:42:05 2014 -0500
> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
> templatekw: add a keyword to list all labels
>
> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -374,10 +374,16 @@ def showsubrepos(**args):
>
>   def showtags(**args):
>       """:tags: List of strings. Any tags associated with the changeset."""
>       return showlist('tag', args['ctx'].tags(), **args)
>
> +def showlabels(**args):
> +    """:tags: List of strings. Any labels in the namespace `namespace`
> +    associated with the changeset."""

did you forget to update the inital :tags: ?

Also you docstring hint that this takes an argument while the 
implementation does not.


> +    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))

isn't l[0] the namespace?

> +    return showlist('label', labels, **args)
> +

You don't perform any deduplication. should we?

>   # keywords are callables like:
>   # fn(repo, ctx, templ, cache, revcache, **args)
>   # with:
>   # repo - current repository instance
>   # ctx - the changectx being displayed
> @@ -400,10 +406,11 @@ keywords = {
>       'file_copies': showfilecopies,
>       'file_copies_switch': showfilecopiesswitch,
>       'file_dels': showfiledels,
>       'file_mods': showfilemods,
>       'files': showfiles,
> +    'labels': showlabels,
>       'latesttag': showlatesttag,
>       'latesttagdistance': showlatesttagdistance,
>       'manifest': showmanifest,
>       'node': shownode,
>       'p1rev': showp1rev,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Sean Farley - Aug. 21, 2014, 6:26 p.m.
Pierre-Yves David writes:

> On 08/18/2014 02:18 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1408394525 18000
>> #      Mon Aug 18 15:42:05 2014 -0500
>> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
>> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
>> templatekw: add a keyword to list all labels
>>
>> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
>> --- a/mercurial/templatekw.py
>> +++ b/mercurial/templatekw.py
>> @@ -374,10 +374,16 @@ def showsubrepos(**args):
>>
>>   def showtags(**args):
>>       """:tags: List of strings. Any tags associated with the changeset."""
>>       return showlist('tag', args['ctx'].tags(), **args)
>>
>> +def showlabels(**args):
>> +    """:tags: List of strings. Any labels in the namespace `namespace`
>> +    associated with the changeset."""
>
> did you forget to update the inital :tags: ?
>
> Also you docstring hint that this takes an argument while the 
> implementation does not.

Oops, yep, I changed that but forgot to update the docstring.

>> +    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))
>
> isn't l[0] the namespace?
>
>> +    return showlist('label', labels, **args)
>> +
>
> You don't perform any deduplication. should we?

Good point. I would say 'yes'. Or we could do something else
(e.g. prefix the name with its namespace)?
Pierre-Yves David - Aug. 21, 2014, 7:30 p.m.
On 08/21/2014 11:26 AM, Sean Farley wrote:
>
> Pierre-Yves David writes:
>
>> On 08/18/2014 02:18 PM, Sean Farley wrote:
>>> # HG changeset patch
>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>> # Date 1408394525 18000
>>> #      Mon Aug 18 15:42:05 2014 -0500
>>> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
>>> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
>>> templatekw: add a keyword to list all labels
>>>
>>> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
>>> --- a/mercurial/templatekw.py
>>> +++ b/mercurial/templatekw.py
>>> @@ -374,10 +374,16 @@ def showsubrepos(**args):
>>>
>>>    def showtags(**args):
>>>        """:tags: List of strings. Any tags associated with the changeset."""
>>>        return showlist('tag', args['ctx'].tags(), **args)
>>>
>>> +def showlabels(**args):
>>> +    """:tags: List of strings. Any labels in the namespace `namespace`
>>> +    associated with the changeset."""
>>
>> did you forget to update the inital :tags: ?
>>
>> Also you docstring hint that this takes an argument while the
>> implementation does not.
>
> Oops, yep, I changed that but forgot to update the docstring.
>
>>> +    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))
>>
>> isn't l[0] the namespace?

isn't it ?

>>
>>> +    return showlist('label', labels, **args)
>>> +
>>
>> You don't perform any deduplication. should we?
>
> Good point. I would say 'yes'. Or we could do something else
> (e.g. prefix the name with its namespace)?

meh, we should at least keep a simple version around by default (withotu 
namespace) just deduplicating should be fine.
Sean Farley - Aug. 21, 2014, 9:01 p.m.
Pierre-Yves David writes:

> On 08/21/2014 11:26 AM, Sean Farley wrote:
>>
>> Pierre-Yves David writes:
>>
>>> On 08/18/2014 02:18 PM, Sean Farley wrote:
>>>> # HG changeset patch
>>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>>> # Date 1408394525 18000
>>>> #      Mon Aug 18 15:42:05 2014 -0500
>>>> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
>>>> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
>>>> templatekw: add a keyword to list all labels
>>>>
>>>> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
>>>> --- a/mercurial/templatekw.py
>>>> +++ b/mercurial/templatekw.py
>>>> @@ -374,10 +374,16 @@ def showsubrepos(**args):
>>>>
>>>>    def showtags(**args):
>>>>        """:tags: List of strings. Any tags associated with the changeset."""
>>>>        return showlist('tag', args['ctx'].tags(), **args)
>>>>
>>>> +def showlabels(**args):
>>>> +    """:tags: List of strings. Any labels in the namespace `namespace`
>>>> +    associated with the changeset."""
>>>
>>> did you forget to update the inital :tags: ?
>>>
>>> Also you docstring hint that this takes an argument while the
>>> implementation does not.
>>
>> Oops, yep, I changed that but forgot to update the docstring.
>>
>>>> +    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))
>>>
>>> isn't l[0] the namespace?
>
> isn't it ?

I seem to have reversed the label with namespace in the sorted
list. This will be refactored by using util.sortdict.

>>>
>>>> +    return showlist('label', labels, **args)
>>>> +
>>>
>>> You don't perform any deduplication. should we?
>>
>> Good point. I would say 'yes'. Or we could do something else
>> (e.g. prefix the name with its namespace)?
>
> meh, we should at least keep a simple version around by default (withotu 
> namespace) just deduplicating should be fine.

Sure, will do.
Jordi GutiƩrrez Hermoso - Aug. 29, 2014, 1:59 p.m.
On Mon, 2014-08-18 at 16:18 -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1408394525 18000
> #      Mon Aug 18 15:42:05 2014 -0500
> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
> templatekw: add a keyword to list all labels

I just noticed this patch and part of its series. I apologise for
tl;dr'ing the whole thing, but is this sort of the same thing that I
am trying to do with my --color=debug patch, or supercedes it?

- Jordi G. H.
Sean Farley - Aug. 29, 2014, 2:06 p.m.
Jordi GutiƩrrez Hermoso writes:

> On Mon, 2014-08-18 at 16:18 -0500, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1408394525 18000
>> #      Mon Aug 18 15:42:05 2014 -0500
>> # Node ID e1ab9da20be237323a1340efa16b58b03525596f
>> # Parent  f49b99874b05d0a902f8ed02201d9e57fc81c684
>> templatekw: add a keyword to list all labels
>
> I just noticed this patch and part of its series. I apologise for
> tl;dr'ing the whole thing, but is this sort of the same thing that I
> am trying to do with my --color=debug patch, or supercedes it?

No, because I'm overloading the name of 'label'. This is a bad thing to
do so we've decided at the sprint for 'references'.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -374,10 +374,16 @@  def showsubrepos(**args):
 
 def showtags(**args):
     """:tags: List of strings. Any tags associated with the changeset."""
     return showlist('tag', args['ctx'].tags(), **args)
 
+def showlabels(**args):
+    """:tags: List of strings. Any labels in the namespace `namespace`
+    associated with the changeset."""
+    labels = sorted(l[0] for l in args['repo'].nodelabels(args['ctx'].node()))
+    return showlist('label', labels, **args)
+
 # keywords are callables like:
 # fn(repo, ctx, templ, cache, revcache, **args)
 # with:
 # repo - current repository instance
 # ctx - the changectx being displayed
@@ -400,10 +406,11 @@  keywords = {
     'file_copies': showfilecopies,
     'file_copies_switch': showfilecopiesswitch,
     'file_dels': showfiledels,
     'file_mods': showfilemods,
     'files': showfiles,
+    'labels': showlabels,
     'latesttag': showlatesttag,
     'latesttagdistance': showlatesttagdistance,
     'manifest': showmanifest,
     'node': shownode,
     'p1rev': showp1rev,