comparison contrib/bash_completion @ 18790:1e28a7f58f33

completion: add a debuglabelcomplete command When completing a "label" (a symbolic name for a commit), the bash_completion script currently has to invoke hg three times. For a large repository, the cost of starting up and loading all the necessary context over and over is very high. For instance, in mozilla-central: time (export HGPLAIN=1; hg tags -q; hg bookmarks -q; hg branches) >/dev/null 0.446 sec Compare with the debuglabelcomplete command that this commit adds: time hg debuglabelcomplete >/dev/null 0.148 sec This greatly helps responsiveness.
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 21 Mar 2013 10:51:18 -0700
parents fff3a8114510
children a821ec835223
comparison
equal deleted inserted replaced
18789:fff3a8114510 18790:1e28a7f58f33
86 local IFS=$'\n' 86 local IFS=$'\n'
87 compopt -o filenames 2>/dev/null 87 compopt -o filenames 2>/dev/null
88 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) 88 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
89 } 89 }
90 90
91 _hg_tags()
92 {
93 local tags="$(_hg_cmd tags -q)"
94 local IFS=$'\n'
95 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
96 }
97
98 _hg_branches()
99 {
100 local branches="$(_hg_cmd branches -q)"
101 local IFS=$'\n'
102 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
103 }
104
105 _hg_bookmarks() 91 _hg_bookmarks()
106 { 92 {
107 local bookmarks="$(_hg_cmd bookmarks -q)" 93 local bookmarks="$(_hg_cmd bookmarks -q)"
108 local IFS=$'\n' 94 local IFS=$'\n'
109 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur")) 95 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur"))
110 } 96 }
111 97
112 _hg_labels() 98 _hg_labels()
113 { 99 {
114 _hg_tags 100 local labels="$(_hg_cmd debuglabelcomplete "$cur")"
115 _hg_branches 101 local IFS=$'\n'
116 _hg_bookmarks 102 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$labels' -- "$cur"))
117 } 103 }
118 104
119 # this is "kind of" ugly... 105 # this is "kind of" ugly...
120 _hg_count_non_option() 106 _hg_count_non_option()
121 { 107 {