Patchwork [2,of,2] summary: use ui.label and join to write evolution troubles

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 7, 2017, 11:29 a.m.
Message ID <246563462fd6b907b4ba.1483788551@marimba>
Download mbox | patch
Permalink /patch/18132/
State Accepted
Headers show

Comments

Denis Laxalde - Jan. 7, 2017, 11:29 a.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1483788255 -3600
#      Sat Jan 07 12:24:15 2017 +0100
# Node ID 246563462fd6b907b4ba215d200e0486ac10a535
# Parent  e9057e86529463d4f4f0414bac8bf4dd2a290b0f
summary: use ui.label and join to write evolution troubles

Follow-up on 7b526670f540 to avoid a convoluted loop.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5992,14 +5992,10 @@  def summary(ui, repo, **opts):
             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(' ('
+                     + ', '.join(ui.label(trouble, 'trouble.%s' % trouble)
+                                 for trouble in p.troubles())
+                     + ')')
         ui.write('\n')
         if p.description():
             ui.status(' ' + p.description().splitlines()[0].strip() + '\n',