Mercurial > evolve
comparison hgext3rd/topic/stack.py @ 1909:36112e361ee4
stack: display the base of the stack
Displaying the first parent of the stack seems useful. I'm even tempted to call
it 't0' and have the topic still active when 'hg up t0' is used to move to the
base.
As a side effect we gain a way to denote that the stack is not linear. I'm not
super convinced that it is the right way to display it, but this is better than
no information.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 14 Mar 2016 23:37:58 +0000 |
parents | 95874e8fc5f2 |
children | 17782631d7e8 |
comparison
equal
deleted
inserted
replaced
1908:dbd6d51e63f1 | 1909:36112e361ee4 |
---|---|
17 if not topic: | 17 if not topic: |
18 topic = repo.currenttopic | 18 topic = repo.currenttopic |
19 if not topic: | 19 if not topic: |
20 raise error.Abort(_('no active topic to list')) | 20 raise error.Abort(_('no active topic to list')) |
21 fm = ui.formatter('topicstack', opts) | 21 fm = ui.formatter('topicstack', opts) |
22 prev = None | |
22 for idx, r in enumerate(getstack(repo, topic)): | 23 for idx, r in enumerate(getstack(repo, topic)): |
24 ctx = repo[r] | |
25 p1 = ctx.p1() | |
26 if p1.obsolete(): | |
27 p1 = repo[_singlesuccessor(repo, p1)] | |
28 if p1.rev() != prev: | |
29 # display the parent of the chanset | |
30 state = 'base' | |
31 symbol= '_' | |
32 fm.startitem() | |
33 fm.plain(' ') # XXX 2 is the right padding by chance | |
34 fm.write('topic.stack.state', '%s', symbol, | |
35 label='topic.stack.state topic.stack.state.%s' % state) | |
36 fm.plain(' ') | |
37 fm.write('topic.stack.desc', '%s', | |
38 p1.description().splitlines()[0], | |
39 label='topic.stack.desc topic.stack.desc.%s' % state) | |
40 fm.plain('\n') | |
41 fm.end() | |
23 # super crude initial version | 42 # super crude initial version |
24 symbol = ':' | 43 symbol = ':' |
25 state = 'clean' | 44 state = 'clean' |
26 if repo.revs('%d and parents()', r): | 45 if repo.revs('%d and parents()', r): |
27 symbol = '@' | 46 symbol = '@' |
33 fm.write('topic.stack.index', 't%d', idx, | 52 fm.write('topic.stack.index', 't%d', idx, |
34 label='topic.stack.index topic.stack.index.%s' % state) | 53 label='topic.stack.index topic.stack.index.%s' % state) |
35 fm.write('topic.stack.state.symbol', '%s', symbol, | 54 fm.write('topic.stack.state.symbol', '%s', symbol, |
36 label='topic.stack.state topic.stack.state.%s' % state) | 55 label='topic.stack.state topic.stack.state.%s' % state) |
37 fm.plain(' ') | 56 fm.plain(' ') |
38 fm.write('topic.stack.desc', '%s', repo[r].description().splitlines()[0], | 57 fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], |
39 label='topic.stack.desc topic.stack.desc.%s' % state) | 58 label='topic.stack.desc topic.stack.desc.%s' % state) |
40 fm.condwrite(state != 'clean', 'topic.stack.state', ' (%s)', state, | 59 fm.condwrite(state != 'clean', 'topic.stack.state', ' (%s)', state, |
41 label='topic.stack.state topic.stack.state.%s' % state) | 60 label='topic.stack.state topic.stack.state.%s' % state) |
42 fm.plain('\n') | 61 fm.plain('\n') |
43 fm.end() | 62 fm.end() |
63 prev = r | |
44 | 64 |
45 # Copied from evolve 081605c2e9b6 | 65 # Copied from evolve 081605c2e9b6 |
46 | 66 |
47 def _orderrevs(repo, revs): | 67 def _orderrevs(repo, revs): |
48 """Compute an ordering to solve instability for the given revs | 68 """Compute an ordering to solve instability for the given revs |
62 # Remove the revisions with no dependency(A) and add them to the ordering. | 82 # Remove the revisions with no dependency(A) and add them to the ordering. |
63 # Removing these revisions leads to new revisions with no dependency (the | 83 # Removing these revisions leads to new revisions with no dependency (the |
64 # one depending on A) that we can remove from the dependency graph and add | 84 # one depending on A) that we can remove from the dependency graph and add |
65 # to the ordering. We progress in a similar fashion until the ordering is | 85 # to the ordering. We progress in a similar fashion until the ordering is |
66 # built | 86 # built |
67 solvablerevs = collections.deque([r for r in sorted(dependencies.keys()) | 87 solvablerevs = [r for r in sorted(dependencies.keys()) |
68 if not dependencies[r]]) | 88 if not dependencies[r]] |
69 ordering = [] | 89 ordering = [] |
70 while solvablerevs: | 90 while solvablerevs: |
71 rev = solvablerevs.popleft() | 91 rev = solvablerevs.pop() |
72 for dependent in rdependencies[rev]: | 92 for dependent in rdependencies[rev]: |
73 dependencies[dependent].remove(rev) | 93 dependencies[dependent].remove(rev) |
74 if not dependencies[dependent]: | 94 if not dependencies[dependent]: |
75 solvablerevs.append(dependent) | 95 solvablerevs.append(dependent) |
76 del dependencies[rev] | 96 del dependencies[rev] |