Patchwork [2,of,3] cmdutil: add support for evolution "troubles" display in changeset_printer

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 10, 2016, 12:33 p.m.
Message ID <d9f7776c40b8c82bf438.1476102798@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/17020/
State Deferred
Delegated to: Yuya Nishihara
Headers show

Comments

Denis Laxalde - Oct. 10, 2016, 12:33 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1476094018 -7200
#      Mon Oct 10 12:06:58 2016 +0200
# Node ID d9f7776c40b8c82bf438322f2442d99c4e116161
# Parent  6c916ce602f5c92c5a5a4de954629670b8c7ca8c
# EXP-Topic evolve-ui
cmdutil: add support for evolution "troubles" display in changeset_printer

Add a "troubles" line in changeset header along with a couple of labels on
"log.changeset" line to indicate whether a changeset is troubled or not and
which kind trouble occurs.

Extract a _changesetlabels function to be reused in summary command.
Denis Laxalde - Oct. 10, 2016, 12:42 p.m.
Denis Laxalde a écrit :
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1476094018 -7200
> #      Mon Oct 10 12:06:58 2016 +0200
> # Node ID d9f7776c40b8c82bf438322f2442d99c4e116161
> # Parent  6c916ce602f5c92c5a5a4de954629670b8c7ca8c
> # EXP-Topic evolve-ui
> cmdutil: add support for evolution "troubles" display in changeset_printer
>
> Add a "troubles" line in changeset header along with a couple of labels on
> "log.changeset" line to indicate whether a changeset is troubled or not and
> which kind trouble occurs.

I did this during the sprint and then realized that there has been some
earlier and similar proposals. For the record:

* 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-September/087850.html 
(evolution: make troubles appear in default log)

* 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-September/087924.html 
(evolve: add template to show evolution troubles) (concerns the evolve 
extension)

In replies to the first one, 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-September/088025.html 
seems to imply that such changes adding new information bits to log (and 
maybe summary) are acceptable.
Yuya Nishihara - Oct. 15, 2016, 12:36 p.m.
On Mon, 10 Oct 2016 14:33:18 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1476094018 -7200
> #      Mon Oct 10 12:06:58 2016 +0200
> # Node ID d9f7776c40b8c82bf438322f2442d99c4e116161
> # Parent  6c916ce602f5c92c5a5a4de954629670b8c7ca8c
> # EXP-Topic evolve-ui
> cmdutil: add support for evolution "troubles" display in changeset_printer
> 
> Add a "troubles" line in changeset header along with a couple of labels on
> "log.changeset" line to indicate whether a changeset is troubled or not and
> which kind trouble occurs.
> 
> Extract a _changesetlabels function to be reused in summary command.
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1204,6 +1204,14 @@ def diffordiffstat(ui, repo, diffopts, n
>              sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
>                       stat=stat, fp=fp, prefix=prefix)
>  
> +def _changesetlabels(ctx):
> +    labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
> +    if ctx.troubled():
> +        labels.append('changeset.troubled')
> +        for trouble in ctx.troubles():
> +            labels.append('trouble.%s' % trouble)
> +    return ' '.join(labels)
> +
>  class changeset_printer(object):
>      '''show changeset information when templating not requested.'''
>  
> @@ -1264,7 +1272,7 @@ class changeset_printer(object):
>  
>          # i18n: column positioning for "hg log"
>          self.ui.write(_("changeset:   %d:%s\n") % revnode,
> -                      label='log.changeset changeset.%s' % ctx.phasestr())
> +                      label=_changesetlabels(ctx))
>  
>          # branches are shown first before any other names due to backwards
>          # compatibility
> @@ -1309,6 +1317,10 @@ class changeset_printer(object):
>          self.ui.write(_("date:        %s\n") % date,
>                        label='log.date')
>  
> +        if ctx.troubled():
> +            self.ui.write(_("troubles:    %s\n") % ', '.join(ctx.troubles()),
> +                          label='ui.note log.troubles')

The change looks good, but I have no idea if we can expose "troubles",
"troubled", etc. as a public API. I have a vague memory someone saying
"trouble" sounds trange to native speakers.

And we'll need to update templates/map-cmdline.default to reflect this change.
Pierre-Yves David - Oct. 16, 2016, 1:16 p.m.
On 10/15/2016 02:36 PM, Yuya Nishihara wrote:
> On Mon, 10 Oct 2016 14:33:18 +0200, Denis Laxalde wrote:
>> # HG changeset patch
>> # User Denis Laxalde <denis.laxalde@logilab.fr>
>> # Date 1476094018 -7200
>> #      Mon Oct 10 12:06:58 2016 +0200
>> # Node ID d9f7776c40b8c82bf438322f2442d99c4e116161
>> # Parent  6c916ce602f5c92c5a5a4de954629670b8c7ca8c
>> # EXP-Topic evolve-ui
>> cmdutil: add support for evolution "troubles" display in changeset_printer
>>
>> Add a "troubles" line in changeset header along with a couple of labels on
>> "log.changeset" line to indicate whether a changeset is troubled or not and
>> which kind trouble occurs.
>>
>> Extract a _changesetlabels function to be reused in summary command.
>>
>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py
>> +++ b/mercurial/cmdutil.py
>> @@ -1204,6 +1204,14 @@ def diffordiffstat(ui, repo, diffopts, n
>>              sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
>>                       stat=stat, fp=fp, prefix=prefix)
>>
>> +def _changesetlabels(ctx):
>> +    labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
>> +    if ctx.troubled():
>> +        labels.append('changeset.troubled')
>> +        for trouble in ctx.troubles():
>> +            labels.append('trouble.%s' % trouble)
>> +    return ' '.join(labels)
>> +
>>  class changeset_printer(object):
>>      '''show changeset information when templating not requested.'''
>>
>> @@ -1264,7 +1272,7 @@ class changeset_printer(object):
>>
>>          # i18n: column positioning for "hg log"
>>          self.ui.write(_("changeset:   %d:%s\n") % revnode,
>> -                      label='log.changeset changeset.%s' % ctx.phasestr())
>> +                      label=_changesetlabels(ctx))
>>
>>          # branches are shown first before any other names due to backwards
>>          # compatibility
>> @@ -1309,6 +1317,10 @@ class changeset_printer(object):
>>          self.ui.write(_("date:        %s\n") % date,
>>                        label='log.date')
>>
>> +        if ctx.troubled():
>> +            self.ui.write(_("troubles:    %s\n") % ', '.join(ctx.troubles()),
>> +                          label='ui.note log.troubles')
>
> The change looks good, but I have no idea if we can expose "troubles",
> "troubled", etc. as a public API. I have a vague memory someone saying
> "trouble" sounds trange to native speakers.

There have been discussion about the name of the trouble them-self too.

My personal opinion about this is:

- concerns have been expressed for years without actual progress made, 
so I think we should take this change at the beginning of the 4.1 cycle. 
This should give time to adjust naming if necessary.

- As long as Evolution and its bits are flagged as experimental we have 
some room to make change there.

> And we'll need to update templates/map-cmdline.default to reflect this change.

+1, we could have some special mode that use the default cmdline 
template instead of the dedicated code and run the tests for it in a 
buildbot.
timeless - Oct. 26, 2016, 7:36 p.m.
If someone could try to grab my attention on irc for a couple of hours
sometime soon I could try to work through this w/ whomever is
alive....

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1204,6 +1204,14 @@  def diffordiffstat(ui, repo, diffopts, n
             sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
                      stat=stat, fp=fp, prefix=prefix)
 
+def _changesetlabels(ctx):
+    labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
+    if ctx.troubled():
+        labels.append('changeset.troubled')
+        for trouble in ctx.troubles():
+            labels.append('trouble.%s' % trouble)
+    return ' '.join(labels)
+
 class changeset_printer(object):
     '''show changeset information when templating not requested.'''
 
@@ -1264,7 +1272,7 @@  class changeset_printer(object):
 
         # i18n: column positioning for "hg log"
         self.ui.write(_("changeset:   %d:%s\n") % revnode,
-                      label='log.changeset changeset.%s' % ctx.phasestr())
+                      label=_changesetlabels(ctx))
 
         # branches are shown first before any other names due to backwards
         # compatibility
@@ -1309,6 +1317,10 @@  class changeset_printer(object):
         self.ui.write(_("date:        %s\n") % date,
                       label='log.date')
 
+        if ctx.troubled():
+            self.ui.write(_("troubles:    %s\n") % ', '.join(ctx.troubles()),
+                          label='ui.note log.troubles')
+
         if self.ui.debugflag:
             files = ctx.p1().status(ctx)[:3]
             for key, value in zip([# i18n: column positioning for "hg log"
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -614,6 +614,7 @@  Test that rewriting leaving instability 
   parent:      11:3334b7925910
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
+  troubles:    unstable
   summary:     babar