bash_completion: match more narrowly
authorBryan O'Sullivan <bryano@fb.com>
Thu, 14 Mar 2013 16:49:02 -0700
changeset 18767 69e4787b6867
parent 18766 64b5562550e2
child 18768 e3e601969ba1
bash_completion: match more narrowly This greatly helps completion performance for most commands that deal with files. In a working dir with 150,000 files, where we want to complete the name of a modified file under a path beginning with "a", from the root of the working dir: (old) hg status -nm . 1.7 sec (new) hg status -nm "glob:a**" 0.3 Even "hg add" becomes a little faster, in spite of being the worst case (matching untracked files).
contrib/bash_completion
--- a/contrib/bash_completion	Wed Mar 13 10:43:51 2013 -0700
+++ b/contrib/bash_completion	Thu Mar 14 16:49:02 2013 -0700
@@ -82,7 +82,7 @@
 
 _hg_status()
 {
-    local files="$(_hg_cmd status -n$1 .)"
+    local files="$(_hg_cmd status -n$1 "glob:$cur**")"
     local IFS=$'\n'
     compopt -o filenames 2>/dev/null
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))