[PATCH] zsh_completion: make use of `debuglabelcomplete` command

Nikolaj Sjujskij sterkrig at myopera.com
Fri Apr 12 08:14:27 CDT 2013


# HG changeset patch
# User Nikolaj Sjujskij <sterkrig at myopera.com>
# Date 1365425498 -14400
#      Mon Apr 08 16:51:38 2013 +0400
# Node ID 35111d556de83375db9b5a5231e95c0df925fab3
# Parent  8c0a7eeda06d2773ec92b14527280db3e0167588
zsh_completion: make use of `debuglabelcomplete` command

Use `debuglabelcomplete` command when populating labels list, instead of
calling `hg` three times: for branches, bookmarks and tags. Do not pass string
being completed to `hg debuglabelcomplete` (as `$words[$CURRENT]`), since it
breaks `_hg_revrange` completion (`--rev 2.5:2.5.<Tab>`) for no apparent
benefit.
Also complete `hg view` with labels, not just tags, and drop unused `_hg_tags`.

diff --git a/contrib/zsh_completion b/contrib/zsh_completion
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -163,21 +163,10 @@
 }
 
 _hg_labels() {
-  _hg_tags "$@"
-  _hg_bookmarks "$@"
-  _hg_branches "$@"
+  labels=("${(f)$(_hg_cmd debuglabelcomplete)}")
+  (( $#labels )) && _describe -t labels 'labels' labels
 }
 
-_hg_tags() {
-  typeset -a tags
-  local tag rev
-
-  _hg_cmd tags | while read tag
-  do
-    tags+=(${tag/ #[0-9]#:*})
-  done
-  (( $#tags )) && _describe -t tags 'tags' tags
-}
 _hg_bookmarks() {
   typeset -a bookmark bookmarks
 
@@ -940,7 +929,7 @@
 _hg_cmd_view() {
   _arguments -s -w : $_hg_global_opts \
   '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
-  ':revision range:_hg_tags'
+  ':revision range:_hg_labels'
 }
 
 # MQ


More information about the Mercurial-devel mailing list