Show More
@@ -76,9 +76,17 typeset -A _hg_cmd_globals | |||||
76 | fi |
|
76 | fi | |
77 | fi |
|
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 | if (( $+functions[_hg_cmd_${cmd}] )) |
|
88 | if (( $+functions[_hg_cmd_${cmd}] )) | |
80 | then |
|
89 | then | |
81 | curcontext="${curcontext%:*:*}:hg-${cmd}:" |
|
|||
82 | _hg_cmd_${cmd} |
|
90 | _hg_cmd_${cmd} | |
83 | else |
|
91 | else | |
84 | # complete unknown commands normally |
|
92 | # complete unknown commands normally | |
@@ -87,6 +95,16 typeset -A _hg_cmd_globals | |||||
87 | fi |
|
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 | _hg_get_commands() { |
|
108 | _hg_get_commands() { | |
91 | typeset -ga _hg_cmd_list |
|
109 | typeset -ga _hg_cmd_list | |
92 | typeset -gA _hg_alias_list |
|
110 | typeset -gA _hg_alias_list | |
@@ -172,8 +190,13 typeset -A _hg_cmd_globals | |||||
172 | typeset -a remdirs |
|
190 | typeset -a remdirs | |
173 | compset -p $(( $#host + 1 )) |
|
191 | compset -p $(( $#host + 1 )) | |
174 | local rempath=${(M)PREFIX##*/} |
|
192 | local rempath=${(M)PREFIX##*/} | |
|
193 | local cacheid="hg_${host}_${rempath//\//_}" | |||
175 | compset -P '*/' |
|
194 | compset -P '*/' | |
|
195 | if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" | |||
|
196 | then | |||
176 | remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/}) |
|
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 | _describe -t directories 'remote directory' remdirs -S/ |
|
200 | _describe -t directories 'remote directory' remdirs -S/ | |
178 | else |
|
201 | else | |
179 | _message 'remote directory' |
|
202 | _message 'remote directory' |
General Comments 0
You need to be logged in to leave comments.
Login now