# HG changeset patch # User Anton Shestakov # Date 2018-08-21 12:30:53 # 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 --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -193,21 +193,13 @@ typeset -A _hg_cmd_globals # 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 }