hgext3rd/topic/stack.py
changeset 4433 a19d8196b0c9
parent 4432 5da1d162ad50
child 4434 432f2155d106
--- a/hgext3rd/topic/stack.py	Thu Mar 07 19:13:45 2019 +0800
+++ b/hgext3rd/topic/stack.py	Thu Mar 07 22:50:56 2019 +0800
@@ -284,7 +284,8 @@
     if empty:
         fm.plain(_("(stack is empty)\n"))
 
-    for idx, r in enumerate(stack(repo, branch=branch, topic=topic), 0):
+    st = stack(repo, branch=branch, topic=topic)
+    for idx, r in enumerate(st, 0):
         ctx = repo[r]
         # special case for t0, b0 as it's hard to plugin into rest of the logic
         if idx == 0:
@@ -323,14 +324,9 @@
         msg = ''
         iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
         if opts.get('children'):
-            if branch:
-                t_msg = '-branch("%s")' % branch
-            if topic:
-                t_msg = '-topic("%s")' % topic
-            rev_msg = 'children(%s) and merge() %s'
-            revisions = repo.revs(rev_msg % (ctx.rev(), t_msg))
-            len_rev = len(revisions)
-            if len_rev > 0:
+            expr = 'children(%d) and merge() - %ld'
+            revisions = repo.revs(expr, ctx.rev(), st.revs[1:])
+            if len(revisions) > 0:
                 msg = 'external-children'
 
         if iscurrentrevision: