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

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 3, 2017, 12:54 p.m.
Message ID <7a01933ed8be3b286a0b.1483448076@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18085/
State Accepted
Headers show

Comments

Denis Laxalde - Jan. 3, 2017, 12:54 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 7a01933ed8be3b286a0bbd666d46e7de3efa2d67
# Parent  ca42aac155d48ccd89fcf1c9fac46579c2a56378
# EXP-Topic evolve-ui
cmdutil: add support for evolution "troubles" display in changeset_printer

Add a "trouble" 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.
Yuya Nishihara - Jan. 5, 2017, 3:10 p.m.
On Tue, 03 Jan 2017 13:54:36 +0100, 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 7a01933ed8be3b286a0bbd666d46e7de3efa2d67
> # Parent  ca42aac155d48ccd89fcf1c9fac46579c2a56378
> # EXP-Topic evolve-ui
> cmdutil: add support for evolution "troubles" display in changeset_printer

> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1230,6 +1230,10 @@ def diffordiffstat(ui, repo, diffopts, n
>  
>  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):
> @@ -1337,6 +1341,10 @@ class changeset_printer(object):
>          self.ui.write(_("date:        %s\n") % date,
>                        label='log.date')
>  
> +        if ctx.troubled():
> +            self.ui.write(_("trouble:     %s\n") % ', '.join(ctx.troubles()),
> +                          label='ui.note log.trouble')

A small nit: please copy-paste the '# i18n: column positioning for "hg log"'
comment so translators can take extra care in spacing.
Pierre-Yves David - Jan. 5, 2017, 7:52 p.m.
On 01/05/2017 04:10 PM, Yuya Nishihara wrote:
> On Tue, 03 Jan 2017 13:54:36 +0100, 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 7a01933ed8be3b286a0bbd666d46e7de3efa2d67
>> # Parent  ca42aac155d48ccd89fcf1c9fac46579c2a56378
>> # EXP-Topic evolve-ui
>> cmdutil: add support for evolution "troubles" display in changeset_printer
>
>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py
>> +++ b/mercurial/cmdutil.py
>> @@ -1230,6 +1230,10 @@ def diffordiffstat(ui, repo, diffopts, n
>>
>>  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):
>> @@ -1337,6 +1341,10 @@ class changeset_printer(object):
>>          self.ui.write(_("date:        %s\n") % date,
>>                        label='log.date')
>>
>> +        if ctx.troubled():
>> +            self.ui.write(_("trouble:     %s\n") % ', '.join(ctx.troubles()),
>> +                          label='ui.note log.trouble')
>
> A small nit: please copy-paste the '# i18n: column positioning for "hg log"'
> comment so translators can take extra care in spacing.

That one is public now :-/ Denis can you follow up with a fix?

Cheers,

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1230,6 +1230,10 @@  def diffordiffstat(ui, repo, diffopts, n
 
 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):
@@ -1337,6 +1341,10 @@  class changeset_printer(object):
         self.ui.write(_("date:        %s\n") % date,
                       label='log.date')
 
+        if ctx.troubled():
+            self.ui.write(_("trouble:     %s\n") % ', '.join(ctx.troubles()),
+                          label='ui.note log.trouble')
+
         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
+  trouble:     unstable
   summary:     babar