Patchwork template: add a ``troubles`` keyword

login
register
mail settings
Submitter Pierre-Yves David
Date June 11, 2014, 1:40 a.m.
Message ID <7de3cb6ec08823d98c93.1402450814@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4971/
State Deferred
Headers show

Comments

Pierre-Yves David - June 11, 2014, 1:40 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1402445823 25200
#      Tue Jun 10 17:17:03 2014 -0700
# Node ID 7de3cb6ec08823d98c93c421b506504401329f25
# Parent  0f73ed6293629f69aa2f01d8940e91faeded49ae
template: add a ``troubles`` keyword

This keyword list all evolution troubles that affect a changeset. Evolution
troubles can be "unstable", "divergent" and "bumped".
Greg Ward - June 11, 2014, 12:10 p.m.
On 10 June 2014, pierre-yves.david@ens-lyon.org said:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1402445823 25200
> #      Tue Jun 10 17:17:03 2014 -0700
> # Node ID 7de3cb6ec08823d98c93c421b506504401329f25
> # Parent  0f73ed6293629f69aa2f01d8940e91faeded49ae
> template: add a ``troubles`` keyword

Woo-hoo!

But should this be provided by evolve? Or is that impractical?

> +def showtroubles(repo, ctx, **args):
> +    """:troubles: List of strings. Evolution troubles affecting the changeset.
> +    Evolution troubles can be "unstable", "divergent" and "bumped".
> +    """

How about:

    """:troubles: List of strings. Evolution troubles affecting the changeset
    (zero or more of "unstable", "divergent" or "bumped")."""

?

Also: is "Obsolescence troubles" more accurate than "Evolution
troubles"?

       Greg
Pierre-Yves David - June 12, 2014, 9:53 p.m.
On 06/11/2014 05:10 AM, Greg Ward wrote:
> On 10 June 2014, pierre-yves.david@ens-lyon.org said:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1402445823 25200
>> #      Tue Jun 10 17:17:03 2014 -0700
>> # Node ID 7de3cb6ec08823d98c93c421b506504401329f25
>> # Parent  0f73ed6293629f69aa2f01d8940e91faeded49ae
>> template: add a ``troubles`` keyword
>
> Woo-hoo!
>
> But should this be provided by evolve? Or is that impractical?

It would be possible, (and even more practical to me) to put this into 
evolve. But as core already have the related troubles revset (and all 
logic related to them). I would make sense to have it into core too.

>> +def showtroubles(repo, ctx, **args):
>> +    """:troubles: List of strings. Evolution troubles affecting the changeset.
>> +    Evolution troubles can be "unstable", "divergent" and "bumped".
>> +    """
>
> How about:
>
>      """:troubles: List of strings. Evolution troubles affecting the changeset
>      (zero or more of "unstable", "divergent" or "bumped")."""

Nicer

> ?
>
> Also: is "Obsolescence troubles" more accurate than "Evolution
> troubles"?

The concept is called evolution. But trouble are introduced because of 
evolution. I've no strong feeling about that.
Pierre-Yves David - June 12, 2014, 10:15 p.m.
On 06/12/2014 02:53 PM, Pierre-Yves David wrote:
>
>
> On 06/11/2014 05:10 AM, Greg Ward wrote:
>> On 10 June 2014, pierre-yves.david@ens-lyon.org said:
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>>> # Date 1402445823 25200
>>> #      Tue Jun 10 17:17:03 2014 -0700
>>> # Node ID 7de3cb6ec08823d98c93c421b506504401329f25
>>> # Parent  0f73ed6293629f69aa2f01d8940e91faeded49ae
>>> template: add a ``troubles`` keyword
>>
>> Woo-hoo!
>>
>> But should this be provided by evolve? Or is that impractical?
>
> It would be possible, (and even more practical to me) to put this into
> evolve. But as core already have the related troubles revset (and all
> logic related to them). I would make sense to have it into core too.

Back pedalling on this. The revset seems added by evolve itself.

Also Matt view on this:

<mpm> pyd: re {troubles}, I'm a little concerned about finalizing that 
terminology.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -347,10 +347,16 @@  def showrev(repo, ctx, templ, **args):
 
 def showtags(**args):
     """:tags: List of strings. Any tags associated with the changeset."""
     return showlist('tag', args['ctx'].tags(), **args)
 
+def showtroubles(repo, ctx, **args):
+    """:troubles: List of strings. Evolution troubles affecting the changeset.
+    Evolution troubles can be "unstable", "divergent" and "bumped".
+    """
+    return showlist('trouble', ctx.troubles(), plural='troubles', **args)
+
 # keywords are callables like:
 # fn(repo, ctx, templ, cache, revcache, **args)
 # with:
 # repo - current repository instance
 # ctx - the changectx being displayed
@@ -384,10 +390,11 @@  keywords = {
     'p2node': showp2node,
     'phase': showphase,
     'phaseidx': showphaseidx,
     'rev': showrev,
     'tags': showtags,
+    'troubles': showtroubles,
 }
 
 def _showparents(**args):
     """:parents: List of strings. The parents of the changeset in "rev:node"
     format. If the changeset has only one "natural" parent (the predecessor
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -595,10 +595,26 @@  refuse to push unstable changeset
   pushing to ../tmpc/
   searching for changes
   abort: push includes unstable changeset: cda648ca50f5!
   [255]
 
+template can include trouble data:
+
+  $ hg log -G --template '{rev} {troubles}\n'
+  @  5 unstable
+  |
+  x  4
+  |
+  o  3
+  |
+  | o  2
+  |/
+  o  1
+  |
+  o  0
+  
+
 Test that extinct changeset are properly detected
 
   $ hg log -r 'extinct()'
 
 Don't try to push extinct changeset