Mercurial > evolve
changeset 4653:fd4f422b0b57
stack: leverage labelsgen() to produce all needed labels for fm.write()
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 11 May 2019 17:14:32 +0800 |
parents | b72cd597a887 |
children | 0d05dcb8dd37 |
files | hgext3rd/topic/stack.py |
diffstat | 1 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py Wed May 08 16:00:34 2019 +0800 +++ b/hgext3rd/topic/stack.py Sat May 11 17:14:32 2019 +0800 @@ -215,11 +215,9 @@ branches = set([self._repo[None].branch()]) return branches -def labelsgen(prefix, labelssuffix): - """ Takes a label prefix and a list of suffixes. Returns a string of the prefix - formatted with each suffix separated with a space. - """ - return ' '.join(prefix % suffix.replace(' ', '-') for suffix in labelssuffix) +def labelsgen(prefix, parts): + fmt = prefix + '.%s' + return prefix + ' ' + ' '.join(fmt % p.replace(' ', '-') for p in parts) def showstack(ui, repo, branch=None, topic=None, opts=None): if opts is None: @@ -364,17 +362,17 @@ fm.plain(' ') else: fm.write('topic.stack.index', '%s%%d' % prefix, idx, - label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states)) + label=labelsgen('topic.stack.index', states)) if ui.verbose: fm.write('topic.stack.shortnode', '(%s)', short(ctx.node()), - label='topic.stack.shortnode ' + labelsgen('topic.stack.shortnode.%s', states)) + label=labelsgen('topic.stack.shortnode', states)) fm.write('topic.stack.state.symbol', '%s', symbol, - label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) + label=labelsgen('topic.stack.state', states)) fm.plain(' ') fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], - label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states)) + label=labelsgen('topic.stack.desc', states)) fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state', ' (%s)', fm.formatlist(states, 'topic.stack.state'), - label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) + label=labelsgen('topic.stack.state', states)) fm.plain('\n') fm.end()