topic: properly justify the verbose data when listing topic
We align all data to the widest topic.
--- a/hgext3rd/topic/__init__.py Tue Aug 16 15:32:54 2016 +0200
+++ b/hgext3rd/topic/__init__.py Tue Aug 16 15:43:06 2016 +0200
@@ -280,6 +280,10 @@
def _listtopics(ui, repo, opts):
fm = ui.formatter('bookmarks', opts)
activetopic = repo.currenttopic
+ namemask = '%s'
+ if repo.topics and ui.verbose:
+ maxwidth = max(len(t) for t in repo.topics)
+ namemask = '%%-%is' % maxwidth
for topic in sorted(repo.topics):
fm.startitem()
marker = ' '
@@ -291,12 +295,12 @@
if not ui.quiet:
# registering the active data is made explicitly later
fm.plain(' %s ' % marker, label=label)
- fm.write('topic', '%s', topic, label=label)
+ fm.write('topic', namemask, topic, label=label)
fm.data(active=active)
if ui.verbose:
# XXX we should include the data even when not verbose
data = stack.stackdata(repo, topic)
- fm.plain('\t(')
+ fm.plain(' (')
fm.write('changesetcount', '%d changesets', data['changesetcount'],
label='topic.list.changesetcount')
if data['troubledcount']:
--- a/tests/test-topic-list.t Tue Aug 16 15:32:54 2016 +0200
+++ b/tests/test-topic-list.t Tue Aug 16 15:43:06 2016 +0200
@@ -173,10 +173,10 @@
verbose
$ hg topic --verbose
- bar (5 changesets, 1 troubled, 2 heads)
- baz (2 changesets, 2 behind)
- * foo (2 changesets, ambiguous destination)
- fuz (3 changesets, 2 troubled, 1 behind)
+ bar (5 changesets, 1 troubled, 2 heads)
+ baz (2 changesets, 2 behind)
+ * foo (2 changesets, ambiguous destination)
+ fuz (3 changesets, 2 troubled, 1 behind)
json