# HG changeset patch # User Anton Shestakov # Date 1548685891 -28800 # Node ID c73edc31e0dd1baafd321a3fc02200bc6ca36473 # Parent 2893b127923beda61c2e9f32811a42208253402a topic: simplify #stack index check/access Also using stack.revs instead of list(stack). It's equivalent and stack.revs is @propertycache'd. diff -r 2893b127923b -r c73edc31e0dd hgext3rd/topic/revset.py --- 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: