# HG changeset patch # User Anton Shestakov # Date 1551970256 -28800 # Node ID a19d8196b0c9ab6d7f1da1aad5752c20a82d09c3 # Parent 5da1d162ad5074708b9b38a63d4d0152a9a831ae 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. diff -r 5da1d162ad50 -r a19d8196b0c9 hgext3rd/topic/stack.py --- 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: