From patchwork Mon Nov 25 17:42:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [10, of, 11, V3] bash_completion: add global support for bookmarks and branches From: Sean Farley X-Patchwork-Id: 3130 Message-Id: <069222d00ab0940e2afc.1385401343@dyn-160-39-236-172.dyn.columbia.edu> To: mercurial-devel@selenic.com Date: Mon, 25 Nov 2013 12:42:23 -0500 # HG changeset patch # User Sean Farley # 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 ' 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