Mercurial > evolve
diff 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 |
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py Tue Jul 04 00:15:36 2017 +0530 +++ b/hgext3rd/topic/stack.py Tue Jul 04 01:30:14 2017 +0530 @@ -20,7 +20,13 @@ trevs = repo.revs("branch(%s) - public() - obsolete() - topic()", branch) else: raise error.ProgrammingError('neither branch and topic specified (not defined yet)') - return _orderrevs(repo, trevs) + revs = _orderrevs(repo, trevs) + if revs: + pt1 = repo[revs[0]].p1() + if pt1.obsolete(): + pt1 = repo[_singlesuccessor(repo, pt1)] + revs.insert(0, pt1.rev()) + return revs def labelsgen(prefix, labelssuffix): """ Takes a label prefix and a list of suffixes. Returns a string of the prefix @@ -84,8 +90,16 @@ fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount') fm.plain('\n') - for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 1): + for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 0): ctx = repo[r] + # special case for t0, b0 as it's hard to plugin into rest of the logic + if idx == 0: + # t0, b0 can be None + if r == -1: + continue + entries.append((idx, False, ctx)) + prev = ctx.rev() + continue p1 = ctx.p1() if p1.obsolete(): p1 = repo[_singlesuccessor(repo, p1)] @@ -148,7 +162,7 @@ :behindcount: number of changeset on rebase destination """ data = {} - revs = getstack(repo, branch, topic) + revs = getstack(repo, branch, topic)[1:] data['changesetcount'] = len(revs) data['troubledcount'] = len([r for r in revs if repo[r].troubled()]) deps, rdeps = builddependencies(repo, revs)