comparison hgext3rd/topic/stack.py @ 2712:f19b314d8475

topics: add t0 and b0 to the stack t0 or b0 will be the base of the stack and it's the parent of t1 or b1. The cool thing about this is that if you update to t0 using `hg up t0` or do `hg prev` on t1, you will be updated to t0 with the current topic preserved. This patch adds t0 to stack and implement the preserving topic case for t0 while using `hg update`.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 04 Jul 2017 01:30:14 +0530
parents 90e11985d0cc
children bd3824d1b795
comparison
equal deleted inserted replaced
2711:8c938e9af113 2712:f19b314d8475
18 trevs = repo.revs("topic(%s) - obsolete()", topic) 18 trevs = repo.revs("topic(%s) - obsolete()", topic)
19 elif branch is not None: 19 elif branch is not None:
20 trevs = repo.revs("branch(%s) - public() - obsolete() - topic()", branch) 20 trevs = repo.revs("branch(%s) - public() - obsolete() - topic()", branch)
21 else: 21 else:
22 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') 22 raise error.ProgrammingError('neither branch and topic specified (not defined yet)')
23 return _orderrevs(repo, trevs) 23 revs = _orderrevs(repo, trevs)
24 if revs:
25 pt1 = repo[revs[0]].p1()
26 if pt1.obsolete():
27 pt1 = repo[_singlesuccessor(repo, pt1)]
28 revs.insert(0, pt1.rev())
29 return revs
24 30
25 def labelsgen(prefix, labelssuffix): 31 def labelsgen(prefix, labelssuffix):
26 """ Takes a label prefix and a list of suffixes. Returns a string of the prefix 32 """ Takes a label prefix and a list of suffixes. Returns a string of the prefix
27 formatted with each suffix separated with a space. 33 formatted with each suffix separated with a space.
28 """ 34 """
82 elif data['behindcount']: 88 elif data['behindcount']:
83 fm.plain(', ') 89 fm.plain(', ')
84 fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount') 90 fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
85 fm.plain('\n') 91 fm.plain('\n')
86 92
87 for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 1): 93 for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 0):
88 ctx = repo[r] 94 ctx = repo[r]
95 # special case for t0, b0 as it's hard to plugin into rest of the logic
96 if idx == 0:
97 # t0, b0 can be None
98 if r == -1:
99 continue
100 entries.append((idx, False, ctx))
101 prev = ctx.rev()
102 continue
89 p1 = ctx.p1() 103 p1 = ctx.p1()
90 if p1.obsolete(): 104 if p1.obsolete():
91 p1 = repo[_singlesuccessor(repo, p1)] 105 p1 = repo[_singlesuccessor(repo, p1)]
92 if p1.rev() != prev and p1.node() != node.nullid: 106 if p1.rev() != prev and p1.node() != node.nullid:
93 entries.append((idxmap.get(p1.rev()), False, p1)) 107 entries.append((idxmap.get(p1.rev()), False, p1))
146 :troubledcount: number on troubled changesets 160 :troubledcount: number on troubled changesets
147 :headcount: number of heads on the topic 161 :headcount: number of heads on the topic
148 :behindcount: number of changeset on rebase destination 162 :behindcount: number of changeset on rebase destination
149 """ 163 """
150 data = {} 164 data = {}
151 revs = getstack(repo, branch, topic) 165 revs = getstack(repo, branch, topic)[1:]
152 data['changesetcount'] = len(revs) 166 data['changesetcount'] = len(revs)
153 data['troubledcount'] = len([r for r in revs if repo[r].troubled()]) 167 data['troubledcount'] = len([r for r in revs if repo[r].troubled()])
154 deps, rdeps = builddependencies(repo, revs) 168 deps, rdeps = builddependencies(repo, revs)
155 data['headcount'] = len([r for r in revs if not rdeps[r]]) 169 data['headcount'] = len([r for r in revs if not rdeps[r]])
156 data['behindcount'] = 0 170 data['behindcount'] = 0