Show More
@@ -76,9 +76,17 b' typeset -A _hg_cmd_globals' | |||
|
76 | 76 | fi |
|
77 | 77 | fi |
|
78 | 78 | |
|
79 | curcontext="${curcontext%:*:*}:hg-${cmd}:" | |
|
80 | ||
|
81 | zstyle -s ":completion:$curcontext:" cache-policy update_policy | |
|
82 | ||
|
83 | if [[ -z "$update_policy" ]] | |
|
84 | then | |
|
85 | zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy | |
|
86 | fi | |
|
87 | ||
|
79 | 88 | if (( $+functions[_hg_cmd_${cmd}] )) |
|
80 | 89 | then |
|
81 | curcontext="${curcontext%:*:*}:hg-${cmd}:" | |
|
82 | 90 | _hg_cmd_${cmd} |
|
83 | 91 | else |
|
84 | 92 | # complete unknown commands normally |
@@ -87,6 +95,16 b' typeset -A _hg_cmd_globals' | |||
|
87 | 95 | fi |
|
88 | 96 | } |
|
89 | 97 | |
|
98 | _hg_cache_policy() { | |
|
99 | typeset -a old | |
|
100 | ||
|
101 | # cache for a minute | |
|
102 | old=( "$1"(mm+10) ) | |
|
103 | (( $#old )) && return 0 | |
|
104 | ||
|
105 | return 1 | |
|
106 | } | |
|
107 | ||
|
90 | 108 | _hg_get_commands() { |
|
91 | 109 | typeset -ga _hg_cmd_list |
|
92 | 110 | typeset -gA _hg_alias_list |
@@ -172,8 +190,13 b' typeset -A _hg_cmd_globals' | |||
|
172 | 190 | typeset -a remdirs |
|
173 | 191 | compset -p $(( $#host + 1 )) |
|
174 | 192 | local rempath=${(M)PREFIX##*/} |
|
193 | local cacheid="hg_${host}_${rempath//\//_}" | |
|
175 | 194 | compset -P '*/' |
|
176 | remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/}) | |
|
195 | if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" | |
|
196 | then | |
|
197 | remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/}) | |
|
198 | _store_cache "$cacheid" remdirs | |
|
199 | fi | |
|
177 | 200 | _describe -t directories 'remote directory' remdirs -S/ |
|
178 | 201 | else |
|
179 | 202 | _message 'remote directory' |
General Comments 0
You need to be logged in to leave comments.
Login now