hgext3rd/topic/stack.py
changeset 4653 fd4f422b0b57
parent 4652 b72cd597a887
child 4654 0d05dcb8dd37
equal deleted inserted replaced
4652:b72cd597a887 4653:fd4f422b0b57
   213         branches = sorted(set(self._repo[r].branch() for r in self._revs))
   213         branches = sorted(set(self._repo[r].branch() for r in self._revs))
   214         if not branches:
   214         if not branches:
   215             branches = set([self._repo[None].branch()])
   215             branches = set([self._repo[None].branch()])
   216         return branches
   216         return branches
   217 
   217 
   218 def labelsgen(prefix, labelssuffix):
   218 def labelsgen(prefix, parts):
   219     """ Takes a label prefix and a list of suffixes. Returns a string of the prefix
   219     fmt = prefix + '.%s'
   220     formatted with each suffix separated with a space.
   220     return prefix + ' ' + ' '.join(fmt % p.replace(' ', '-') for p in parts)
   221     """
       
   222     return ' '.join(prefix % suffix.replace(' ', '-') for suffix in labelssuffix)
       
   223 
   221 
   224 def showstack(ui, repo, branch=None, topic=None, opts=None):
   222 def showstack(ui, repo, branch=None, topic=None, opts=None):
   225     if opts is None:
   223     if opts is None:
   226         opts = {}
   224         opts = {}
   227 
   225 
   362             fm.plain('  ')
   360             fm.plain('  ')
   363             if ui.verbose:
   361             if ui.verbose:
   364                 fm.plain('              ')
   362                 fm.plain('              ')
   365         else:
   363         else:
   366             fm.write('topic.stack.index', '%s%%d' % prefix, idx,
   364             fm.write('topic.stack.index', '%s%%d' % prefix, idx,
   367                      label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states))
   365                      label=labelsgen('topic.stack.index', states))
   368             if ui.verbose:
   366             if ui.verbose:
   369                 fm.write('topic.stack.shortnode', '(%s)', short(ctx.node()),
   367                 fm.write('topic.stack.shortnode', '(%s)', short(ctx.node()),
   370                          label='topic.stack.shortnode ' + labelsgen('topic.stack.shortnode.%s', states))
   368                          label=labelsgen('topic.stack.shortnode', states))
   371         fm.write('topic.stack.state.symbol', '%s', symbol,
   369         fm.write('topic.stack.state.symbol', '%s', symbol,
   372                  label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states))
   370                  label=labelsgen('topic.stack.state', states))
   373         fm.plain(' ')
   371         fm.plain(' ')
   374         fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0],
   372         fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0],
   375                  label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states))
   373                  label=labelsgen('topic.stack.desc', states))
   376         fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state',
   374         fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state',
   377                      ' (%s)', fm.formatlist(states, 'topic.stack.state'),
   375                      ' (%s)', fm.formatlist(states, 'topic.stack.state'),
   378                      label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states))
   376                      label=labelsgen('topic.stack.state', states))
   379         fm.plain('\n')
   377         fm.plain('\n')
   380     fm.end()
   378     fm.end()