# HG changeset patch # User Pierre-Yves David # Date 1471354986 -7200 # Node ID d427fd97c9d5adc9fa2d236c60b30c94338f7652 # Parent 042356d5ba595b6ceaa7598ebb1de7a4ecc3675f topic: properly justify the verbose data when listing topic We align all data to the widest topic. diff -r 042356d5ba59 -r d427fd97c9d5 hgext3rd/topic/__init__.py --- 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']: diff -r 042356d5ba59 -r d427fd97c9d5 tests/test-topic-list.t --- 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