Patchwork [14,of,15,V5] bash_completion: add global support for -b|--branch

login
register
mail settings
Submitter Sean Farley
Date Nov. 26, 2013, 7:54 p.m.
Message ID <7908c45ed714ef93803c.1385499293@laptop.local>
Download mbox | patch
Permalink /patch/3168/
State Accepted
Commit e39bd4b7be7880b613091f815059ac40ca2ee47e
Headers show

Comments

Sean Farley - Nov. 26, 2013, 7:54 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1385497998 21600
#      Tue Nov 26 14:33:18 2013 -0600
# Node ID 7908c45ed714ef93803c7fdd7cf408be84d1d3f7
# Parent  9978ec49c0eb4a9fbfd0ce6f973da184a0053037
bash_completion: add global support for -b|--branch

Previously, only -r|--rev was parsed globally which meant 'hg push -b <tab>'
would try to complete a path instead of a branch.

Patch

diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -253,10 +253,17 @@ 
                     _hg_bookmarks
                     return 0
                 fi
                 return 1
             ;;
+            -b|--branch)
+                if [[ $canonical = 1 || status != "$cmd"* ]]; then
+                    _hg_branches
+                    return 0
+                fi
+                return 1
+            ;;
         esac
     fi
 
     local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}')
     [ -n "$aliascmd" ] && cmd=$aliascmd