[PATCH 10 of 11 V3] bash_completion: add global support for bookmarks and branches
Sean Farley
sean.michael.farley at gmail.com
Tue Nov 26 01:23:07 UTC 2013
On Mon, Nov 25, 2013 at 12:42 PM, Sean Farley
<sean.michael.farley at gmail.com> wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1385398743 18000
> # Mon Nov 25 11:59:03 2013 -0500
> # Node ID 069222d00ab0940e2afce45a7c9bfcd907e7ca44
> # Parent 8284d077161322221f0df02690107b5f70c31138
> bash_completion: add global support for bookmarks and branches
>
> Previously, only -r|--rev was parsed globally which meant 'hg push -B <tab>'
> would try to complete a path instead of a bookmark. Similar error for -b for
> branches. Now we tab complete bookmarks and branches globally so that this
> works.
>
> diff --git a/contrib/bash_completion b/contrib/bash_completion
> --- a/contrib/bash_completion
> +++ b/contrib/bash_completion
> @@ -237,16 +237,27 @@
> if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then
> "_hg_cmd_$cmd"
> return 0
> fi
>
> - if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
> - if [ $canonical = 1 ]; then
> - _hg_labels
> - return 0
> - elif [[ status != "$cmd"* ]]; then
> - _hg_labels
> + if [ "$cmd" != status ]; then
> + if [[ $canonical = 1 || status != "$cmd"* ]]; then
> + case "$prev" in
> + -r|--rev)
> + _hg_labels
> + ;;
> + -B|--bookmark)
> + _hg_bookmarks
> + ;;
> + -b|--branch)
> + _hg_branches
> + ;;
> + *)
> + return 1
> + ;;
> + esac
> +
> return 0
> else
> return 1
> fi
> fi
I was trying to be cool and use a 'case' here but it breaks the logic.
Sad trombone. Please drop this series and I'll try again.
More information about the Mercurial-devel
mailing list