Mercurial > hg-stable
changeset 39462:2815e0db4c54
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
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 21 Aug 2018 20:30:53 +0800 |
parents | 9a813e4c8406 |
children | 45d12c49c3f3 |
files | contrib/zsh_completion |
diffstat | 1 files changed, 4 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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 }