# HG changeset patch # User Brodie Rao # Date 2010-07-21 21:06:00 # Node ID 91af149b5cd72dc91c1e3ae4ee018caf7203323e # Parent 88b89ace643b223e0ef99481e08361410309571f bash/zsh completion: use HGPLAIN when invoking hg (issue2297) diff --git a/contrib/bash_completion b/contrib/bash_completion --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -54,16 +54,21 @@ shopt -s extglob +_hg_cmd() +{ + HGPLAIN=1 "$hg" "$@" 2>/dev/null +} + _hg_commands() { local commands - commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands="" + commands="$(_hg_cmd debugcomplete "$cur")" || commands="" COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur")) } _hg_paths() { - local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')" + local paths="$(_hg_cmd paths | sed -e 's/ = .*$//')" COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) } @@ -77,21 +82,21 @@ shopt -s extglob _hg_status() { - local files="$("$hg" status -n$1 . 2>/dev/null)" + local files="$(_hg_cmd status -n$1 .)" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) } _hg_tags() { - local tags="$("$hg" tags -q 2>/dev/null)" + local tags="$(_hg_cmd tags -q)" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) } _hg_branches() { - local branches="$("$hg" branches -q 2>/dev/null)" + local branches="$(_hg_cmd branches -q)" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur")) } @@ -144,7 +149,7 @@ shopt -s extglob return fi - opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null) + opts=$(_hg_cmd debugcomplete --options "$cmd") COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) return @@ -175,7 +180,7 @@ shopt -s extglob fi # canonicalize the command name and try again - help=$("$hg" help "$cmd" 2>/dev/null) + help=$(_hg_cmd help "$cmd") if [ $? -ne 0 ]; then # Probably either the command doesn't exist or it's ambiguous return @@ -272,7 +277,7 @@ shopt -s extglob return 0 } -complete -o bashdefault -o default -F _hg hg 2>/dev/null \ +complete -o bashdefault -o default -F _hg hg \ || complete -o default -F _hg hg @@ -281,7 +286,7 @@ complete -o bashdefault -o default -F _h # bookmarks _hg_bookmarks() { - local bookmarks="$("$hg" bookmarks --quiet 2>/dev/null )" + local bookmarks="$(_hg_cmd bookmarks --quiet )" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur")) } @@ -298,7 +303,7 @@ complete -o bashdefault -o default -F _h _hg_ext_mq_patchlist() { local patches - patches=$("$hg" $1 2>/dev/null) + patches=$(_hg_cmd $1) if [ $? -eq 0 ] && [ "$patches" ]; then COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur")) return 0 @@ -308,7 +313,7 @@ complete -o bashdefault -o default -F _h _hg_ext_mq_queues() { - local root=$("$hg" root 2>/dev/null) + local root=$(_hg_cmd root) local n for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do # I think we're usually not interested in the regular "patches" queue @@ -379,10 +384,9 @@ complete -o bashdefault -o default -F _h _hg_cmd_qcommit() { - local root=$("$hg" root 2>/dev/null) + local root=$(_hg_cmd root) # this is run in a sub-shell, so we can't use _hg_status - local files=$(cd "$root/.hg/patches" 2>/dev/null && - "$hg" status -nmar 2>/dev/null) + local files=$(cd "$root/.hg/patches" && _hg_cmd status -nmar) COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) } @@ -412,7 +416,7 @@ complete -o bashdefault -o default -F _h _hg_ext_mq_guards() { - "$hg" qselect --series 2>/dev/null | sed -e 's/^.//' + _hg_cmd qselect --series | sed -e 's/^.//' } _hg_cmd_qselect() @@ -557,7 +561,7 @@ complete -o bashdefault -o default -F _h # shelve _hg_shelves() { - local shelves="$("$hg" unshelve -l . 2>/dev/null)" + local shelves="$(_hg_cmd unshelve -l .)" local IFS=$'\n' COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur")) } diff --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -377,8 +377,7 @@ typeset -A _hg_cmd_globals '--remotecmd[specify hg command to run on the remote side]:') _hg_cmd() { - _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \ - "$_hg_cmd_globals[@]" "$@" 2> /dev/null + _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null } _hg_cmd_add() {