12 |
12 |
13 def getstack(repo, topic): |
13 def getstack(repo, topic): |
14 # XXX need sorting |
14 # XXX need sorting |
15 trevs = repo.revs("topic(%s) - obsolete()", topic) |
15 trevs = repo.revs("topic(%s) - obsolete()", topic) |
16 return _orderrevs(repo, trevs) |
16 return _orderrevs(repo, trevs) |
|
17 |
|
18 def labelsgen(prefix, labelssuffix): |
|
19 """ Takes a label prefix and a list of suffixes. Returns a string of the prefix |
|
20 formatted with each suffix separated with a space. |
|
21 """ |
|
22 return ' '.join(prefix % suffix for suffix in labelssuffix) |
17 |
23 |
18 def showstack(ui, repo, topic, opts): |
24 def showstack(ui, repo, topic, opts): |
19 fm = ui.formatter('topicstack', opts) |
25 fm = ui.formatter('topicstack', opts) |
20 prev = None |
26 prev = None |
21 entries = [] |
27 entries = [] |
57 idxmap[ctx.rev()] = idx |
63 idxmap[ctx.rev()] = idx |
58 prev = r |
64 prev = r |
59 |
65 |
60 # super crude initial version |
66 # super crude initial version |
61 for idx, isentry, ctx in entries[::-1]: |
67 for idx, isentry, ctx in entries[::-1]: |
|
68 |
|
69 states = [] |
|
70 iscurrentrevision = repo.revs('%d and parents()', ctx.rev()) |
|
71 |
|
72 if iscurrentrevision: |
|
73 states.append('current') |
|
74 |
62 if not isentry: |
75 if not isentry: |
63 symbol = '^' |
76 symbol = '^' |
64 state = 'base' |
77 # "base" is kind of a "ghost" entry |
65 elif repo.revs('%d and parents()', ctx.rev()): |
78 # skip other label for them (no current, no unstable) |
|
79 states = ['base'] |
|
80 elif iscurrentrevision: |
66 symbol = '@' |
81 symbol = '@' |
67 state = 'current' |
|
68 elif repo.revs('%d and unstable()', ctx.rev()): |
82 elif repo.revs('%d and unstable()', ctx.rev()): |
69 symbol = '$' |
83 symbol = '$' |
70 state = 'unstable' |
84 states.append('unstable') |
71 else: |
85 else: |
72 symbol = ':' |
86 symbol = ':' |
73 state = 'clean' |
87 states.append('clean') |
74 fm.startitem() |
88 fm.startitem() |
75 fm.data(isentry=isentry) |
89 fm.data(isentry=isentry) |
|
90 |
76 if idx is None: |
91 if idx is None: |
77 fm.plain(' ') |
92 fm.plain(' ') |
78 else: |
93 else: |
79 fm.write('topic.stack.index', 't%d', idx, |
94 fm.write('topic.stack.index', 't%d', idx, |
80 label='topic.stack.index topic.stack.index.%s' % state) |
95 label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states)) |
81 fm.write('topic.stack.state.symbol', '%s', symbol, |
96 fm.write('topic.stack.state.symbol', '%s', symbol, |
82 label='topic.stack.state topic.stack.state.%s' % state) |
97 label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) |
83 fm.plain(' ') |
98 fm.plain(' ') |
84 fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], |
99 fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], |
85 label='topic.stack.desc topic.stack.desc.%s' % state) |
100 label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states)) |
86 fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state', |
101 fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state', |
87 ' (%s)', state, |
102 ' (%s)', fm.formatlist(states, 'topic.stack.state'), |
88 label='topic.stack.state topic.stack.state.%s' % state) |
103 label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) |
89 fm.plain('\n') |
104 fm.plain('\n') |
90 fm.end() |
105 fm.end() |
91 |
106 |
92 def stackdata(repo, topic): |
107 def stackdata(repo, topic): |
93 """get various data about a stack |
108 """get various data about a stack |