Mercurial > evolve
changeset 4380:c73edc31e0dd
topic: simplify #stack index check/access
Also using stack.revs instead of list(stack). It's equivalent and stack.revs is
@propertycache'd.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 28 Jan 2019 22:31:31 +0800 |
parents | 2893b127923b |
children | 5f1d0cff514d |
files | hgext3rd/topic/revset.py |
diffstat | 1 files changed, 4 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py Sun Jan 27 17:39:09 2019 +0800 +++ b/hgext3rd/topic/revset.py Mon Jan 28 22:31:31 2019 +0800 @@ -129,14 +129,11 @@ 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 = st[n] - except IndexError: + if abs(n) >= len(st.revs): + # also means stack base is not accessible with n < 0, which is + # by design continue + rev = st.revs[n] if rev == -1 and n == 0: continue if rev not in revs: