about summary refs log tree commit diff
path: root/Functions/VCS_Info/Backends/VCS_INFO_detect_svk
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-19 12:58:46 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-19 12:58:46 +0000
commit23f2b4503c9d7697e382fed550d3bf846b81dd5c (patch)
tree8953de32c2d4126882d9d4c66bcbe7b8615e3419 /Functions/VCS_Info/Backends/VCS_INFO_detect_svk
parentd9f1432e074872aa3a89515bc65ede5ad6551a47 (diff)
downloadzsh-23f2b4503c9d7697e382fed550d3bf846b81dd5c.tar.gz
zsh-23f2b4503c9d7697e382fed550d3bf846b81dd5c.tar.xz
zsh-23f2b4503c9d7697e382fed550d3bf846b81dd5c.zip
users/13252 and elsewhere: Frank Terbeck plus tweaks:
add VCS_Info function system
Diffstat (limited to 'Functions/VCS_Info/Backends/VCS_INFO_detect_svk')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_svk40
1 files changed, 40 insertions, 0 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svk b/Functions/VCS_Info/Backends/VCS_INFO_detect_svk
new file mode 100644
index 000000000..476b59101
--- /dev/null
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_svk
@@ -0,0 +1,40 @@
+## vim:ft=zsh
+## svk support by: Frank Terbeck <ft@bewatermyfriend.org>
+## Distributed under the same BSD-ish license as zsh itself.
+
+setopt localoptions NO_shwordsplit
+
+[[ $1 == '--flavours' ]] && return 1
+
+# This detection function is a bit different from the others.
+# We need to read svk's config file to detect a svk repository
+# in the first place. Therefore, we'll just proceed and read
+# the other information, too. This is more then any of the
+# other detections do but this takes only one file open for
+# svk at most. VCS_INFO_get_data_svk() gets simpler, too. :-)
+
+setopt localoptions noksharrays extendedglob
+local -i fhash
+fhash=0
+
+VCS_INFO_check_com svk || return 1
+[[ -f ~/.svk/config ]] || return 1
+
+while IFS= read -r line ; do
+    if [[ -n ${vcs_comm[basedir]} ]] ; then
+        line=${line## ##}
+        [[ ${line} == depotpath:* ]] && vcs_comm[branch]=${line##*/}
+        [[ ${line} == revision:* ]] && vcs_comm[revision]=${line##*[[:space:]]##}
+        [[ -n ${vcs_comm[branch]} ]] && [[ -n ${vcs_comm[revision]} ]] && break
+        continue
+    fi
+    (( fhash > 0 )) && [[ ${line} == '  '[^[:space:]]*:* ]] && break
+    [[ ${line} == '  hash:'* ]] && fhash=1 && continue
+    (( fhash == 0 )) && continue
+    [[ ${PWD}/ == ${${line## ##}%:*}/* ]] && vcs_comm[basedir]=${${line## ##}%:*}
+done < ~/.svk/config
+
+[[ -n ${vcs_comm[basedir]} ]]  && \
+[[ -n ${vcs_comm[branch]} ]]   && \
+[[ -n ${vcs_comm[revision]} ]] && return 0
+return 1