# HG changeset patch # User Anton Shestakov # Date 1534854653 -28800 # Node ID 2815e0db4c5475e23a48be78ae615268a53997f0 # Parent 9a813e4c84060e4a7e91f4014dded68cadf59956 zsh_completion: use revsets to exclude this rev from suggestions to hg merge One of the most important aspects of a completion system is its speed, so 1 call to hg is definitely better than 4. Sorting by rev (descending) is to preserve the same order as in `hg heads` output. While at it, declare branches as an array too. Differential Revision: https://phab.mercurial-scm.org/D4426 diff -r 9a813e4c8406 -r 2815e0db4c54 contrib/zsh_completion --- a/contrib/zsh_completion Tue Sep 04 10:36:34 2018 -0700 +++ b/contrib/zsh_completion Tue Aug 21 20:30:53 2018 +0800 @@ -193,21 +193,13 @@ # likely merge candidates _hg_mergerevs() { - typeset -a heads - local myrev + typeset -a heads branches + local revset='sort(head() and not ., -rev)' - heads=(${(f)"$(_hg_cmd heads --template '{rev}:{branch}\\n')"}) - # exclude own revision - myrev=$(_hg_cmd log -r . --template '{rev}:{branch}\\n') - heads=(${heads:#$myrev}) - + heads=(${(f)"$(_hg_cmd log -r '$revset' --template '{rev}:{branch}\\n')"}) (( $#heads )) && _describe -t heads 'heads' heads - branches=(${(f)"$(_hg_cmd heads --template '{branch}\\n')"}) - # exclude own revision - myrev=$(_hg_cmd log -r . --template '{branch}\\n') - branches=(${branches:#$myrev}) - + branches=(${(S)heads/#*:/}) (( $#branches )) && _describe -t branches 'branches' branches }