Mercurial > evolve
changeset 4323:482992803db6
topic: make revsets like foo#stack[-1] work too
We remove base commit when n < 0 because it's confusing to see base (which
technically isn't a commit inside the stack) at both 0 and -n.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 26 Dec 2018 22:14:23 +0800 |
parents | 41f38bf15b4c |
children | e913546b9d79 |
files | hgext3rd/topic/revset.py tests/test-topic.t |
diffstat | 2 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py Sun Dec 16 11:22:04 2018 +0800 +++ b/hgext3rd/topic/revset.py Wed Dec 26 22:14:23 2018 +0800 @@ -116,8 +116,6 @@ (e.g. when stack index is too high), this returns empty set to be more revset-friendly. """ - if n < 0: - return revset.baseset() s = revset.getset(repo, revset.fullreposet(repo), x) if not s: return revset.baseset() @@ -128,8 +126,12 @@ st = stack.stack(repo, topic=topic) else: st = stack.stack(repo, branch=repo[r].branch()) + if n < 0: + st = list(st)[1:] + else: + st = list(st) try: - rev = list(st)[n] + rev = st[n] except IndexError: continue if rev == -1 and n == 0:
--- a/tests/test-topic.t Sun Dec 16 11:22:04 2018 +0800 +++ b/tests/test-topic.t Wed Dec 26 22:14:23 2018 +0800 @@ -865,6 +865,10 @@ 0: $ tlog 'tip#stack[2]' 4: + $ tlog 'tip#stack[-1]' + 4: + $ tlog 'tip#stack[-2]' + 0: $ hg stack featureA ### topic: featureA @@ -876,20 +880,24 @@ $ tlog 'featureA#s[0]' 0: - $ tlog 'featureA#s[1]' + $ tlog 'featureA#s[1] and featureA#s[-3]' 1: featureA - $ tlog 'featureA#s[2]' + $ tlog 'featureA#s[2] and featureA#s[-2]' 2: featureA - $ tlog 'featureA#s[3]' + $ tlog 'featureA#s[3] and featureA#s[-1]' 3: featureA + $ tlog 'featureA#s[-4]' $ tlog 'all()#s[-1]' + 3: featureA + 4: $ tlog 'all()#s[0]' 0: $ tlog 'all()#s[1]' 0: 1: featureA $ tlog 'all()#s[9999]' + $ tlog 'all()#s[-9999]' $ hg topic featureB marked working directory as topic: featureB