hgext3rd/topic/revset.py
changeset 4323 482992803db6
parent 4322 41f38bf15b4c
child 4339 0f015fe4f71f
--- 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: