hgext3rd/topic/stack.py
changeset 1955 5452a575b4e5
parent 1954 61f36480740f
child 1956 d8f1e432b16a
equal deleted inserted replaced
1954:61f36480740f 1955:5452a575b4e5
    19         topic = repo.currenttopic
    19         topic = repo.currenttopic
    20     if not topic:
    20     if not topic:
    21         raise error.Abort(_('no active topic to list'))
    21         raise error.Abort(_('no active topic to list'))
    22     fm = ui.formatter('topicstack', opts)
    22     fm = ui.formatter('topicstack', opts)
    23     prev = None
    23     prev = None
       
    24     entries = []
    24     for idx, r in enumerate(getstack(repo, topic), 1):
    25     for idx, r in enumerate(getstack(repo, topic), 1):
    25         ctx = repo[r]
    26         ctx = repo[r]
    26         p1 = ctx.p1()
    27         p1 = ctx.p1()
    27         if p1.obsolete():
    28         if p1.obsolete():
    28             p1 = repo[_singlesuccessor(repo, p1)]
    29             p1 = repo[_singlesuccessor(repo, p1)]
    29         if p1.rev() != prev:
    30         if p1.rev() != prev:
    30             # display the parent of the changeset
    31             entries.append((None, p1))
       
    32         entries.append((idx, ctx))
       
    33         prev = r
       
    34 
       
    35     # super crude initial version
       
    36     for idx, ctx in entries:
       
    37         if idx is None:
       
    38             symbol = '_'
    31             state = 'base'
    39             state = 'base'
    32             symbol = '_'
    40         elif repo.revs('%d and parents()', ctx.rev()):
    33             fm.startitem()
       
    34             fm.plain('  ') # XXX 2 is the right padding by chance
       
    35             fm.write('topic.stack.state', '%s', symbol,
       
    36                      label='topic.stack.state topic.stack.state.%s' % state)
       
    37             fm.plain(' ')
       
    38             fm.write('topic.stack.desc', '%s',
       
    39                      p1.description().splitlines()[0],
       
    40                      label='topic.stack.desc topic.stack.desc.%s' % state)
       
    41             fm.plain('\n')
       
    42             fm.end()
       
    43         # super crude initial version
       
    44         symbol = ':'
       
    45         state = 'clean'
       
    46         if repo.revs('%d and parents()', r):
       
    47             symbol = '@'
    41             symbol = '@'
    48             state = 'current'
    42             state = 'current'
    49         if repo.revs('%d and unstable()', r):
    43         elif repo.revs('%d and unstable()', ctx.rev()):
    50             symbol = '$'
    44             symbol = '$'
    51             state = 'unstable'
    45             state = 'unstable'
       
    46         else:
       
    47             symbol = ':'
       
    48             state = 'clean'
    52         fm.startitem()
    49         fm.startitem()
    53         fm.write('topic.stack.index', 't%d', idx,
    50         if idx is None:
    54                  label='topic.stack.index topic.stack.index.%s' % state)
    51             fm.plain('  ')
       
    52         else:
       
    53             fm.write('topic.stack.index', 't%d', idx,
       
    54                      label='topic.stack.index topic.stack.index.%s' % state)
    55         fm.write('topic.stack.state.symbol', '%s', symbol,
    55         fm.write('topic.stack.state.symbol', '%s', symbol,
    56                  label='topic.stack.state topic.stack.state.%s' % state)
    56                  label='topic.stack.state topic.stack.state.%s' % state)
    57         fm.plain(' ')
    57         fm.plain(' ')
    58         fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0],
    58         fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0],
    59                  label='topic.stack.desc topic.stack.desc.%s' % state)
    59                  label='topic.stack.desc topic.stack.desc.%s' % state)
    60         fm.condwrite(state != 'clean', 'topic.stack.state', ' (%s)', state,
    60         fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state',
       
    61                      ' (%s)', state,
    61                      label='topic.stack.state topic.stack.state.%s' % state)
    62                      label='topic.stack.state topic.stack.state.%s' % state)
    62         fm.plain('\n')
    63         fm.plain('\n')
    63         fm.end()
    64         fm.end()
    64         prev = r
       
    65 
    65 
    66 # Copied from evolve 081605c2e9b6
    66 # Copied from evolve 081605c2e9b6
    67 
    67 
    68 def _orderrevs(repo, revs):
    68 def _orderrevs(repo, revs):
    69     """Compute an ordering to solve instability for the given revs
    69     """Compute an ordering to solve instability for the given revs