Patchwork [6,of,6,V5] summary: add evolution "troubles" information to summary output

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 6, 2017, 3:32 p.m.
Message ID <3a382f7173808665968d.1483716749@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18122/
State Accepted
Headers show

Comments

Denis Laxalde - Jan. 6, 2017, 3:32 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1483709722 -3600
#      Fri Jan 06 14:35:22 2017 +0100
# Node ID 3a382f7173808665968de416db145ade8c56672c
# Parent  1d9bdfeb0afded737513f51e75cefa11e9231fdf
# EXP-Topic evolve-ui
summary: add evolution "troubles" information to summary output

Extend the "parent: " lines in summary with the list of evolution "troubles"
in parentheses, when the parent is troubled.
Pierre-Yves David - Jan. 6, 2017, 4:09 p.m.
On 01/06/2017 04:32 PM, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1483709722 -3600
> #      Fri Jan 06 14:35:22 2017 +0100
> # Node ID 3a382f7173808665968de416db145ade8c56672c
> # Parent  1d9bdfeb0afded737513f51e75cefa11e9231fdf
> # EXP-Topic evolve-ui
> summary: add evolution "troubles" information to summary output

That series seems fine and is pushed. Thanks for the various fixes/cleanup.
Yuya Nishihara - Jan. 7, 2017, 8:53 a.m.
On Fri, 06 Jan 2017 16:32:29 +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1483709722 -3600
> #      Fri Jan 06 14:35:22 2017 +0100
> # Node ID 3a382f7173808665968de416db145ade8c56672c
> # Parent  1d9bdfeb0afded737513f51e75cefa11e9231fdf
> # EXP-Topic evolve-ui
> summary: add evolution "troubles" information to summary output

> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5991,6 +5991,15 @@ def summary(ui, repo, **opts):
>                  ui.write(_(' (empty repository)'))
>              else:
>                  ui.write(_(' (no revision checked out)'))
> +        if p.troubled():
> +            ui.write(' (')
> +            troubles = p.troubles()
> +            for idx, trouble in enumerate(troubles, 1):
> +                ui.write(trouble,
> +                         label='trouble.%s' % trouble)
> +                if idx < len(troubles):
> +                    ui.write(', ')
> +            ui.write(')')

Just fyi, you can use ui.label() to get labeled strings and join them.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5991,6 +5991,15 @@  def summary(ui, repo, **opts):
                 ui.write(_(' (empty repository)'))
             else:
                 ui.write(_(' (no revision checked out)'))
+        if p.troubled():
+            ui.write(' (')
+            troubles = p.troubles()
+            for idx, trouble in enumerate(troubles, 1):
+                ui.write(trouble,
+                         label='trouble.%s' % trouble)
+                if idx < len(troubles):
+                    ui.write(', ')
+            ui.write(')')
         ui.write('\n')
         if p.description():
             ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -242,7 +242,7 @@  Fixing "bumped" situation
 We need to create a clone of 5 and add a special marker with a flag
 
   $ hg summary
-  parent: 5:5601fb93a350 tip
+  parent: 5:5601fb93a350 tip (bumped)
    add new_3_c
   branch: default
   commit: (clean)
@@ -477,7 +477,7 @@  detect outgoing obsolete and unstable
   $ hg log -r 'obsolete()'
   4:94b33453f93b (draft) [ ] add original_d
   $ hg summary
-  parent: 5:cda648ca50f5 tip
+  parent: 5:cda648ca50f5 tip (unstable)
    add original_e
   branch: default
   commit: (clean)
@@ -825,6 +825,20 @@  test the default cmdline template
   summary:     add babar
   
 
+test summary output
+
+  $ hg up -r 'bumped() and unstable()'
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg summary
+  parent: 7:50c51b361e60  (unstable, bumped)
+   add babar
+  branch: default
+  commit: 3 unknown (clean)
+  update: 2 new changesets (update)
+  phases: 4 draft
+  unstable: 2 changesets
+  bumped: 1 changesets
+
 Test incoming/outcoming with changesets obsoleted remotely, known locally
 ===============================================================================
 
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -761,7 +761,7 @@  If a rebase is going to create divergenc
   o  0:4a2df7238c3b A
   
   $ hg summary
-  parent: 15:73568ab6879d tip
+  parent: 15:73568ab6879d tip (unstable)
    bar foo
   branch: default
   commit: (clean)