2 # Fichier contenant les fonctions pour repérer les dépôts VCS
5 # The following code is imported from the file 'zsh/functions/vcs_info'
6 # from <http://ft.bewatermyfriend.org/comp/zsh/zsh-dotfiles.tar.bz2>,
7 # which distributed under the same terms as zsh itself.
9 # we will be using two variables, so let the code know now.
10 zstyle
':vcs_info:*' max-exports
2
11 zstyle
":vcs_info:init:*" "disable" "bzr" "hg" "svk" "cdv" "cvs" "mtn" "tla"
13 # vcs_info() documentation:
17 # This functionality requires zsh version >= 4.1.*.
22 # To load vcs_info(), copy this file to your $fpath[] and do:
23 # % autoload -Uz vcs_info && vcs_info
25 # To work, vcs_info() needs 'setopt prompt_subst' in your setup.
30 # To get vcs_info() working quickly (including colors), you can do the
31 # following (assuming, you loaded vcs_info() properly - see above):
39 # % zstyle ':vcs_info:*' actionformats \
40 # "${MA}(${NC}%s${MA})${YE}-${MA}[${GR}%b${YE}|${RED}%a${MA}]${NC} "
42 # % zstyle ':vcs_info:*' formats \
43 # "${MA}(${NC}%s${MA})${Y}-${MA}[${GR}%b${MA}]${NC}%} "
45 # % zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat "%b${RED}:${YE}%r"
47 # % precmd () { vcs_info }
48 # % PS1='${MA}[${GR}%n${MA}] ${MA}(${RED}%!${MA}) ${YE}%3~ ${VCS_INFO_message_0_}${NC}%# '
50 # Obviously, the las two lines are there for demonstration: You need to
51 # call vcs_info() from your precmd() function (see 'SPECIAL FUNCTIONS' in
52 # 'man zshmisc'). Once that is done you need a *single* quoted
53 # '${VCS_INFO_message_0_}' in your prompt.
55 # Now call the 'vcs_info_printsys' utility from the command line:
58 # # list of supported version control backends:
59 # # disabled systems are prefixed by a hash sign (#)
70 # # flavours (cannot be used in the disable style; they
71 # # are disabled with their master [git-svn -> git]):
75 # Ten version control backends as you can see. You may not want all
76 # of these. Because there is no point in running the code to detect
77 # systems you do not use. ever. So, there is a way to disable some
78 # backends altogether:
80 # % zstyle ':vcs_info:*' disable bzr cdv darcs mtn svk tla
82 # If you rerun 'vcs_info_printsys' now, you will see the backends listed
83 # in the 'disable' style marked as diabled by a hash sign. That means the
84 # detection of these systems is skipped *completely*. No wasted time there.
86 # For more control, read the reference below.
91 # The vcs_info() feature can be configured via zstyle.
93 # First, the context in which we are working:
94 # :vcs_info:<vcs-string>:<user-context>
96 # ...where <vcs-string> is one of:
97 # - git, git-svn, git-p4, hg, darcs, bzr, cdv, mtn, svn, cvs, svk or tla.
99 # ...and <user-context> is a freely configurable string, assignable by the
100 # user as the first argument to vcs_info() (see its description below).
102 # There is are three special values for <vcs-string>: The first is named
103 # 'init', that is in effect as long as there was no decision what vcs
104 # backend to use. The second is 'preinit; it is used *before* vcs_info()
105 # is run, when initializing the data exporting variables. The third
106 # special value is 'formats' and is used by the 'vcs_info_lastmsg' for
107 # looking up its styles.
109 # There are two pre-defined values for <user-context>:
110 # default - the one used if none is specified
111 # command - used by vcs_info_lastmsg to lookup its styles.
113 # You may *not* use 'print_systems_' as a user-context string, because it
114 # is used internally.
116 # You can of course use ':vcs_info:*' to match all VCSs in all
117 # user-contexts at once.
119 # Another special context is 'formats', which is used by the
120 # vcs_info_lastmsg() utility function (see below).
123 # This is a description of all styles, that are looked up:
124 # formats - A list of formats, used when actionformats is not
125 # used (which is most of the time).
126 # actionformats - A list of formats, used if a there is a special
127 # action going on in your current repository;
128 # (like an interactive rebase or a merge conflict)
129 # branchformat - Some backends replace %b in the formats and
130 # actionformats styles above, not only by a branch
131 # name but also by a revision number. This style
132 # let's you modify how that string should look like.
133 # nvcsformats - These "formats" are exported, when we didn't detect
134 # a version control system for the current directory.
135 # This is useful, if you want vcs_info() to completely
136 # take over the generation of your prompt.
137 # You would do something like
138 # PS1='${VCS_INFO_message_0_}'
139 # to accomplish that.
140 # max-exports - Defines the maximum number if VCS_INFO_message_*_
141 # variables vcs_info() will export.
142 # enable - Checked in the 'init' context. If set to false,
143 # vcs_info() will do nothing.
144 # disable - Provide a list of systems, you don't want
145 # the vcs_info() to check for repositories
146 # (checked in the 'init' context, too).
147 # disable-patterns - A list of patterns that are checked against $PWD.
148 # If the pattern matches, vcs_info will be disabled.
149 # Say, ~/.zsh is a directory under version control,
150 # in which you do not want vcs_info to be active, do:
151 # zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh+(|/*)"
152 # use-simple - If there are two different ways of gathering
153 # information, you can select the simpler one
154 # by setting this style to true; the default
155 # is to use the not-that-simple code, which is
156 # potentially a lot slower but might be more
157 # accurate in all possible cases.
158 # use-prompt-escapes - determines if we assume that the assembled
159 # string from vcs_info() includes prompt escapes.
160 # (Used by vcs_info_lastmsg().
162 # The use-simple style is only available for the bzr backend.
164 # The default values for these in all contexts are:
165 # formats " (%s)-[%b|%a]-"
166 # actionformats " (%s)-[%b]-"
167 # branchformat "%b:%r" (for bzr, svn and svk)
171 # disable (empty list)
172 # disable-patterns (empty list)
174 # use-prompt-escapes true
177 # In normal formats and actionformats, the following replacements
179 # %s - The vcs in use (git, hg, svn etc.)
180 # %b - Information about the current branch.
181 # %a - An identifier, that describes the action.
182 # Only makes sense in actionformats.
183 # %R - base directory of the repository.
184 # %r - repository name
185 # If %R is '/foo/bar/repoXY', %r is 'repoXY'.
186 # %S - subdirectory within a repository. if $PWD is
187 # '/foo/bar/reposXY/beer/tasty', %S is 'beer/tasty'.
190 # In branchformat these replacements are done:
191 # %b - the branch name
192 # %r - the current revision number
194 # Not all vcs backends have to support all replacements.
195 # nvcsformat does not perform *any* replacements. It is just a string.
200 # If you want to use the %b (bold off) prompt expansion in 'formats', which
201 # expands %b itself, use %%b. That will cause the vcs_info() expansion to
202 # replace %%b with %b. So zsh's prompt expansion mechanism can handle it.
203 # Similarly, to hand down %b from branchformat, use %%%%b. Sorry for this
204 # inconvenience, but it cannot be easily avoided. Luckily we do not clash
205 # with a lot of prompt expansions and this only needs to be done for those.
206 # See 'man zshmisc' for details about EXPANSION OF PROMPT SEQUENCES.
209 # FUNCTION DESCRIPTIONS (public API):
212 # The main function, that runs all backends and assembles
213 # all data into ${VCS_INFO_message_*_}. This is the function
214 # you want to call from precmd() if you want to include
215 # up-to-date information in your prompt (see VARIABLE
216 # DESCRIPTION below).
218 # vcs_info_printsys()
219 # Prints a list of all supported version control systems.
220 # Useful to find out possible contexts (and which of them are enabled)
221 # or values for the 'disable' style.
224 # Outputs the last ${VCS_INFO_message_*_} value. Takes into account
225 # the value of the use-prompt-escapes style in ':vcs_info:formats'.
226 # It also only prints max-exports values.
228 # All functions named VCS_INFO_* are for internal use only.
231 # VARIABLE DESCRIPTION:
233 # ${VCS_INFO_message_N_} (Note the trailing underscore)
234 # Where 'N' is an integer, eg: VCS_INFO_message_0_
235 # These variables are the storage for the informational message the
236 # last vcs_info() call has assembled. These are strongly connected
237 # to the formats, actionformats and nvcsformats styles described
238 # above. Those styles are lists. the first member of that list gets
239 # expanded into ${VCS_INFO_message_0_}, the second into
240 # ${VCS_INFO_message_1_} and the Nth into ${VCS_INFO_message_N-1_}.
241 # These parameters are exported into the environment.
242 # (See the max-exports style above.)
247 # Don't use vcs_info at all (even though it's in your prompt):
248 # % zstyle ':vcs_info:*' enable false
250 # Disable the backends for bzr and svk:
251 # % zstyle ':vcs_info:*' disable bzr svk
253 # Provide a special formats for git:
254 # % zstyle ':vcs_info:git:*' formats ' GIT, BABY! [%b]'
255 # % zstyle ':vcs_info:git:*' actionformats ' GIT ACTION! [%b|%a]'
257 # Use the quicker bzr backend (if you do, please report if it does
258 # the-right-thing[tm] - thanks):
259 # % zstyle ':vcs_info:bzr:*' use-simple true
261 # Display the revision number in yellow for bzr and svn:
262 # % zstyle ':vcs_info:(svn|bzr):*' branchformat '%b%{'${fg[yellow]}'%}:%r'
264 # If you want colors, make sure you enclose the color codes in %{...%},
265 # if you want to use the string provided by vcs_info() in prompts.
267 # Here is how to print the vcs infomation as a command:
268 # % alias vcsi='vcs_info command; vcs_info_lastmsg'
270 # This way, you can even define different formats for output via
271 # vcs_info_lastmsg() in the ':vcs_info:command:*' namespace.
274 VCS_INFO_adjust
() { #{{{
275 [[ -n ${vcs_comm[overwrite_name]} ]] && vcs
=${vcs_comm[overwrite_name]}
279 VCS_INFO_check_com
() { #{{{
280 (( ${+commands[$1]} )) && [[ -x ${commands[$1]} ]] && return 0
284 VCS_INFO_formats
() { # {{{
285 setopt localoptions noksharrays
286 local action
=$1 branch
=$2 base
=$3
290 if [[ -n ${action} ]] ; then
291 zstyle
-a ":vcs_info:${vcs}:${usercontext}" actionformats msgs
292 (( ${#msgs} < 1 )) && msgs
[1]=' (%s)-[%b|%a]-'
294 zstyle
-a ":vcs_info:${vcs}:${usercontext}" formats msgs
295 (( ${#msgs} < 1 )) && msgs
[1]=' (%s)-[%b]-'
298 (( ${#msgs} > maxexports
)) && msgs
[$
(( maxexports
+ 1 )),-1]=()
299 for i
in {1..
${#msgs}} ; do
300 zformat
-f msg
${msgs[$i]} \
306 S
:"$(VCS_INFO_reposub ${base})"
312 VCS_INFO_maxexports
() { #{{{
313 zstyle
-s ":vcs_info:${vcs}:${usercontext}" "max-exports" maxexports || maxexports
=2
314 if [[ ${maxexports} != <-> ]] ||
(( maxexports
< 1 )); then
315 printf 'vcs_info(): expecting numeric arg >= 1 for max-exports (got %s).\n' ${maxexports}
316 printf 'Defaulting to 2.\n'
321 VCS_INFO_nvcsformats
() { #{{{
322 setopt localoptions noksharrays
325 if [[ $1 == 'preinit' ]] ; then
329 zstyle
-a ":vcs_info:${v:-$vcs}:${c:-$usercontext}" nvcsformats msgs
330 (( ${#msgs} > maxexports
)) && msgs
[${maxexports},-1]=()
333 VCS_INFO_realpath
() { #{{{
334 # a portable 'readlink -f'
335 # forcing a subshell, to ensure chpwd() is not removed
336 # from the calling shell (if VCS_INFO_realpath() is called
339 (( ${+functions[chpwd]} )) && unfunction chpwd
341 cd $1 2>/dev
/null
&& pwd
345 VCS_INFO_reposub
() { #{{{
346 setopt localoptions extendedglob
349 [[ ${PWD} == ${base}/* ]] ||
{
353 printf '%s' ${PWD#$base/}
357 VCS_INFO_set
() { #{{{
358 setopt localoptions noksharrays
361 if [[ $1 == '--clear' ]] ; then
363 unset VCS_INFO_message_
${i}_
366 if [[ $1 == '--nvcs' ]] ; then
367 [[ $2 == 'preinit' ]] && (( maxexports
== 0 )) && (( maxexports
= 1 ))
368 for i
in {0..$
((maxexports
- 1))} ; do
369 typeset
-gx VCS_INFO_message_
${i}_
=
371 VCS_INFO_nvcsformats
$2
374 (( ${#msgs} - 1 < 0 )) && return 0
375 for i
in {0..$
(( ${#msgs} - 1 ))} ; do
377 typeset
-gx VCS_INFO_message_
${i}_
=${msgs[$j]}
382 # information gathering
383 VCS_INFO_bzr_get_data
() { # {{{
384 setopt localoptions noksharrays
388 if zstyle
-t ":vcs_info:${vcs}:${usercontext}" "use-simple" ; then
389 bzrbase
=${vcs_comm[basedir]}
390 bzrinfo
[2]=${bzrbase:t}
391 if [[ -f ${bzrbase}/.bzr
/branch
/last-revision
]] ; then
392 bzrinfo
[1]=$
(< ${bzrbase}/.bzr
/branch
/last-revision
)
393 bzrinfo
[1]=${${bzrinfo[1]}%% *}
396 bzrbase
=${${(M)${(f)"$( bzr info )"}:# ##branch\ root:*}/*: ##/}
397 bzrinfo
=( ${${${(M)${(f)"$( bzr version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\
//} )
398 bzrbase
="$(VCS_INFO_realpath ${bzrbase})"
401 zstyle
-s ":vcs_info:${vcs}:${usercontext}" branchformat bzrbr || bzrbr
="%b:%r"
402 zformat
-f bzrbr
"${bzrbr}" "b:${bzrinfo[2]}" "r:${bzrinfo[1]}"
403 VCS_INFO_formats
'' "${bzrbr}" "${bzrbase}"
407 VCS_INFO_cdv_get_data
() { # {{{
410 cdvbase
=${vcs_comm[basedir]}
411 VCS_INFO_formats
'' "${cdvbase:t}" "${cdvbase}"
415 VCS_INFO_cvs_get_data
() { # {{{
416 local cvsbranch cvsbase
basename
419 while [[ -d "${cvsbase}/../CVS" ]]; do
420 cvsbase
="${cvsbase}/.."
422 cvsbase
="$(VCS_INFO_realpath ${cvsbase})"
423 cvsbranch
=$
(< .
/CVS
/Repository
)
424 basename=${cvsbase:t}
425 cvsbranch
=${cvsbranch##${basename}/}
426 [[ -z ${cvsbranch} ]] && cvsbranch
=${basename}
427 VCS_INFO_formats
'' "${cvsbranch}" "${cvsbase}"
431 VCS_INFO_darcs_get_data
() { # {{{
434 darcsbase
=${vcs_comm[basedir]}
435 VCS_INFO_formats
'' "${darcsbase:t}" "${darcsbase}"
439 VCS_INFO_git_getaction
() { #{{{
440 local gitaction
='' gitdir
=$1
443 for tmp
in "${gitdir}/rebase-apply" \
445 "${gitdir}/../.dotest" ; do
446 if [[ -d ${tmp} ]] ; then
447 if [[ -f "${tmp}/rebasing" ]] ; then
449 elif [[ -f "${tmp}/applying" ]] ; then
452 gitaction
="am/rebase"
454 printf '%s' ${gitaction}
459 for tmp
in "${gitdir}/rebase-merge/interactive" \
460 "${gitdir}/.dotest-merge/interactive" ; do
461 if [[ -f "${tmp}" ]] ; then
462 printf '%s' "rebase-i"
467 for tmp
in "${gitdir}/rebase-merge" \
468 "${gitdir}/.dotest-merge" ; do
469 if [[ -d "${tmp}" ]] ; then
470 printf '%s' "rebase-m"
475 if [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
480 if [[ -f "${gitdir}/BISECT_LOG" ]] ; then
487 VCS_INFO_git_getbranch
() { #{{{
488 local gitbranch gitdir
=$1 tmp actiondir
489 local gitsymref
='git symbolic-ref HEAD'
492 for tmp
in "${gitdir}/rebase-apply" \
494 "${gitdir}/../.dotest"; do
495 if [[ -d ${tmp} ]]; then
500 if [[ -n ${actiondir} ]]; then
501 gitbranch
="$(${(z)gitsymref} 2> /dev/null)"
502 [[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name
]] \
503 && gitbranch
="$(< ${actiondir}/head-name)"
505 elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
506 gitbranch
="$(${(z)gitsymref} 2> /dev/null)"
507 [[ -z ${gitbranch} ]] && gitbranch
="$(< ${gitdir}/MERGE_HEAD)"
509 elif [[ -d "${gitdir}/rebase-merge" ]] ; then
510 gitbranch
="$(< ${gitdir}/rebase-merge/head-name)"
512 elif [[ -d "${gitdir}/.dotest-merge" ]] ; then
513 gitbranch
="$(< ${gitdir}/.dotest-merge/head-name)"
516 gitbranch
="$(${(z)gitsymref} 2> /dev/null)"
518 if [[ $?
-ne 0 ]] ; then
519 gitbranch
="refs/tags/$(git describe --exact-match HEAD 2>/dev/null)"
521 if [[ $?
-ne 0 ]] ; then
522 gitbranch
="${${"$(< $gitdir/HEAD)"}[1,7]}..."
527 printf '%s' "${gitbranch##refs/[^/]##/}"
531 VCS_INFO_git_get_data
() { # {{{
532 setopt localoptions extendedglob
533 local gitdir gitbase gitbranch gitaction
535 gitdir
=${vcs_comm[gitdir]}
536 gitbranch
="$(VCS_INFO_git_getbranch ${gitdir})"
538 if [[ -z ${gitdir} ]] ||
[[ -z ${gitbranch} ]] ; then
543 gitaction
="$(VCS_INFO_git_getaction ${gitdir})"
544 gitbase
=${PWD%/${$( git rev-parse --show-prefix )%/##}}
545 VCS_INFO_formats
"${gitaction}" "${gitbranch}" "${gitbase}"
549 VCS_INFO_hg_get_data
() { # {{{
550 local hgbranch hgbase
file
552 hgbase
=${vcs_comm[basedir]}
554 file="${hgbase}/.hg/branch"
555 if [[ -r ${file} ]] ; then
556 hgbranch
=$
(< ${file})
561 VCS_INFO_formats
'' "${hgbranch}" "${hgbase}"
565 VCS_INFO_mtn_get_data
() { # {{{
566 local mtnbranch mtnbase
568 mtnbase
=${vcs_comm[basedir]}
569 mtnbranch
=${${(M)${(f)"$( mtn status )"}:#(#s)Current branch:*}/*: /}
570 VCS_INFO_formats
'' "${mtnbranch}" "${mtnbase}"
574 VCS_INFO_svk_get_data
() { # {{{
575 local svkbranch svkbase
577 svkbase
=${vcs_comm[basedir]}
578 zstyle
-s ":vcs_info:${vcs}:${usercontext}" branchformat svkbranch || svkbranch
="%b:%r"
579 zformat
-f svkbranch
"${svkbranch}" "b:${vcs_comm[branch]}" "r:${vcs_comm[revision]}"
580 VCS_INFO_formats
'' "${svkbranch}" "${svkbase}"
584 VCS_INFO_svn_get_data
() { # {{{
585 setopt localoptions noksharrays
586 local svnbase svnbranch
590 while [[ -d "${svnbase}/../.svn" ]]; do
591 svnbase
="${svnbase}/.."
593 svnbase
="$(VCS_INFO_realpath ${svnbase})"
594 svninfo
=( ${${${(M)${(f)"$( svn info )"}:#(#s)(URL|Révision)*}/*: /}/*\
//} ) # Beware language!
596 zstyle
-s ":vcs_info:${vcs}:${usercontext}" branchformat svnbranch || svnbranch
="%b:%r"
597 zformat
-f svnbranch
"${svnbranch}" "b:${svninfo[1]}" "r:${svninfo[2]}"
598 VCS_INFO_formats
'' "${svnbranch}" "${svnbase}"
602 VCS_INFO_tla_get_data
() { # {{{
603 local tlabase tlabranch
605 tlabase
="$(VCS_INFO_realpath ${vcs_comm[basedir]})"
606 # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so:
607 tlabranch
=${${"$( tla tree-id )"}/*\
//}
608 VCS_INFO_formats
'' "${tlabranch}" "${tlabase}"
613 VCS_INFO_detect_by_dir
() { #{{{
615 local basedir
="." realbasedir
617 realbasedir
="$(VCS_INFO_realpath ${basedir})"
618 while [[ ${realbasedir} != '/' ]]; do
619 [[ -r ${realbasedir} ]] ||
return 1
620 if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
621 [[ -d ${basedir}/${dirname} ]] && \
622 [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
625 [[ -d ${basedir}/${dirname} ]] && break
628 basedir
=${basedir}/..
629 realbasedir
="$(VCS_INFO_realpath ${basedir})"
632 [[ ${realbasedir} == "/" ]] && return 1
633 vcs_comm
[basedir
]=${realbasedir}
637 VCS_INFO_bzr_detect
() { #{{{
638 VCS_INFO_check_com bzr ||
return 1
639 vcs_comm
[detect_need_file
]=branch
/format
640 VCS_INFO_detect_by_dir
'.bzr'
644 VCS_INFO_cdv_detect
() { #{{{
645 VCS_INFO_check_com cdv ||
return 1
646 vcs_comm
[detect_need_file
]=format
647 VCS_INFO_detect_by_dir
'.cdv'
651 VCS_INFO_cvs_detect
() { #{{{
652 VCS_INFO_check_com svn ||
return 1
653 [[ -d "./CVS" ]] && [[ -r "./CVS/Repository" ]] && return 0
657 VCS_INFO_darcs_detect
() { #{{{
658 VCS_INFO_check_com darcs ||
return 1
659 vcs_comm
[detect_need_file
]=format
660 VCS_INFO_detect_by_dir
'_darcs'
664 VCS_INFO_git_detect
() { #{{{
665 if VCS_INFO_check_com git
&& git rev-parse
--is-inside-work-tree &> /dev
/null
; then
666 vcs_comm
[gitdir
]="$(git rev-parse --git-dir 2> /dev/null)" ||
return 1
667 if [[ -d ${vcs_comm[gitdir]}/svn
]] ; then vcs_comm
[overwrite_name
]='git-svn'
668 elif [[ -d ${vcs_comm[gitdir]}/refs
/remotes
/p4
]] ; then vcs_comm
[overwrite_name
]='git-p4' ; fi
674 VCS_INFO_hg_detect
() { #{{{
675 VCS_INFO_check_com hg ||
return 1
676 # vcs_comm[basedir]=$(hg root 2>/dev/null) || return 1
677 vcs_comm
[detect_need_file
]=store
678 VCS_INFO_detect_by_dir
'.hg'
682 VCS_INFO_mtn_detect
() { #{{{
683 VCS_INFO_check_com mtn ||
return 1
684 vcs_comm
[detect_need_file
]=revision
685 VCS_INFO_detect_by_dir
'_MTN'
689 VCS_INFO_svk_detect
() { #{{{
690 setopt localoptions noksharrays extendedglob
695 VCS_INFO_check_com svk ||
return 1
696 [[ -f ~
/.svk
/config
]] ||
return 1
698 # This detection function is a bit different from the others.
699 # We need to read svk's config file to detect a svk repository
700 # in the first place. Therefore, we'll just proceed and read
701 # the other information, too. This is more then any of the
702 # other detections do but this takes only one file open for
703 # svk at most. VCS_INFO_svk_get_data() get simpler, too. :-)
704 while IFS
= read -r line
; do
705 if [[ -n ${vcs_comm[basedir]} ]] ; then
707 [[ ${line} == depotpath
:* ]] && vcs_comm
[branch
]=${line##*/}
708 [[ ${line} == revision
:* ]] && vcs_comm
[revision
]=${line##*[[:space:]]##}
709 [[ -n ${vcs_comm[branch]} ]] && [[ -n ${vcs_comm[revision]} ]] && break
712 (( fhash
> 0 )) && [[ ${line} == ' '[^
[:space
:]]*:* ]] && break
713 [[ ${line} == ' hash:'* ]] && fhash
=1 && continue
714 (( fhash
== 0 )) && continue
715 [[ ${PWD}/ == ${${line## ##}%:*}/* ]] && vcs_comm[basedir]=${${line## ##}%:*}
718 [[ -n ${vcs_comm[basedir]} ]] && \
719 [[ -n ${vcs_comm[branch]} ]] && \
720 [[ -n ${vcs_comm[revision]} ]] && return 0
724 VCS_INFO_svn_detect
() { #{{{
725 VCS_INFO_check_com svn ||
return 1
726 [[ -d ".svn" ]] && return 0
730 VCS_INFO_tla_detect
() { #{{{
731 VCS_INFO_check_com tla ||
return 1
732 vcs_comm
[basedir
]="$(tla tree-root 2> /dev/null)" && return 0
737 vcs_info_printsys
() { # {{{
738 vcs_info print_systems_
741 vcs_info_lastmsg
() { # {{{
746 for i
in {0..$
((maxexports
- 1))} ; do
747 printf '$VCS_INFO_message_%d_: "' $i
748 if zstyle
-T ':vcs_info:formats:command' use-prompt-escapes
; then
749 print
-nP ${(P)${:-VCS_INFO_message_${i}_}}
751 print
-n ${(P)${:-VCS_INFO_message_${i}_}}
761 [[ -r .
]] ||
return 1
765 local -a VCSs disabled dps
766 local -x vcs usercontext
772 VCSs
=(git hg bzr darcs svk mtn svn cvs cdv tla
)
776 zstyle
-a ":vcs_info:${vcs}:${usercontext}" "disable" disabled
777 print
-l '# list of supported version control backends:' \
778 '# disabled systems are prefixed by a hash sign (#)'
779 for vcs
in ${VCSs} ; do
780 [[ -n ${(M)disabled:#${vcs}} ]] && printf '#'
783 print
-l '# flavours (cannot be used in the disable style; they' \
784 '# are disabled with their master [git-svn -> git]):' \
789 [[ -z ${usercontext} ]] && usercontext
=default
791 (*) [[ -z ${usercontext} ]] && usercontext
=$1
795 zstyle
-T ":vcs_info:${vcs}:${usercontext}" "enable" ||
{
796 [[ -n ${VCS_INFO_message_0_} ]] && VCS_INFO_set
--clear
799 zstyle
-a ":vcs_info:${vcs}:${usercontext}" "disable" disabled
801 zstyle
-a ":vcs_info:${vcs}:${usercontext}" "disable-patterns" dps
802 for pat
in ${dps} ; do
803 if [[ ${PWD} == ${~pat} ]] ; then
804 [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set
--clear
812 for vcs
in ${VCSs} ; do
813 [[ -n ${(M)disabled:#${vcs}} ]] && continue
815 VCS_INFO_
${vcs}_detect
&& (( found
= 1 )) && break
818 (( found
== 0 )) && {
823 VCS_INFO_
${vcs}_get_data ||
{
832 VCS_INFO_set
--nvcs preinit