changeset 4433:a19d8196b0c9

stack: optimize revset used for stack --children Since that option needs to exclude changesets on the current stack, let's just use stack.revs (that are cached) for that and skip branch() or topic() revset. st.revs[0] is the stack base, we don't consider it actual part of stack.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 07 Mar 2019 22:50:56 +0800
parents 5da1d162ad50
children 432f2155d106
files hgext3rd/topic/stack.py
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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: