summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_hg2
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git4
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_hg39
-rw-r--r--Functions/VCS_Info/VCS_INFO_bydir_detect2
5 files changed, 51 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6df46a3e9..f47e885ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-19  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* Frank Terbeck: 27049, 27050, 27051, 27052:
+	Functions/VCS_Info/VCS_INFO_bydir_detect,
+	Functions/VCS_Info/Backends/VCS_INFO_detect_hg,
+	Functions/VCS_Info/Backends/VCS_INFO_get_data_git,
+	Functions/VCS_Info/Backends/VCS_INFO_get_data_hg: VCS_INFO
+	improvements.
+
 2009-06-18  Clint Adams  <clint@zsh.org>
 
 	* 27048: Functions/MIME/zsh-mime-setup: avoid multiline prints
@@ -11842,5 +11851,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4715 $
+* $Revision: 1.4716 $
 *****************************************************
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
index 41fcc4b4c..36078b7a7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
@@ -7,6 +7,6 @@ setopt localoptions NO_shwordsplit
 [[ $1 == '--flavours' ]] && return 1
 
 VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
-vcs_comm[detect_need_file]=branch
+vcs_comm[detect_need_file]=store
 VCS_INFO_bydir_detect '.hg'
 return $?
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index a536165e1..33e76d44f 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -135,7 +135,9 @@ if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then
     return 1
 fi
 
-if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
+if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" && \
+   [[ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" != 'true' ]] && \
+   git rev-parse --quiet --verify HEAD &> /dev/null ; then
     # Default: off - these are potentially expensive on big repositories
     ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
         gitunstaged=1
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index d70e03c00..d83521b14 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -3,10 +3,43 @@
 ## Distributed under the same BSD-ish license as zsh itself.
 
 setopt localoptions NO_shwordsplit
-local hgbranch hgbase
+local file hgbranch hgbranch_name hgbase hghash hglrev r_branch r_info
 
 hgbase=${vcs_comm[basedir]}
 rrn=${hgbase:t}
-hgbranch=$(< ${hgbase}/.hg/branch)
-VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' '' ''
+
+file="${hgbase}/.hg/branch"
+if [[ -r ${file} ]] ; then
+    hgbranch_name=$(< ${file})
+else
+    hgbranch_name="default"
+fi
+
+hghash=''
+hglrev=''
+if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
+    # Calling the 'hg' program is quite a bit too slow for prompts.
+    # If there's a way around that, I'd be interested.
+    # Disabled by default anyway, so no harm done.
+
+    HGRCPATH="/dev/null" ${vcs_comm[cmd]} branches \
+    | while read -r r_branch r_info ; do
+        if [[ ${r_branch} == ${hgbranch_name} ]] ; then
+            match=()
+            : ${r_info/(#b)([^:]##):(*)}
+            hglrev=${match[1]}
+            hghash=${match[2]}
+            break
+        fi
+    done
+
+    if [[ -n ${hglrev} ]] ; then
+        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat hgbranch || hgbranch="%b:%r"
+        zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev}"
+    fi
+else
+    hgbranch="${hgbranch_name}"
+fi
+
+VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hghash}"
 return 0
diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index aff59f300..7985b6994 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -10,7 +10,7 @@ realbasedir="$(VCS_INFO_realpath ${basedir})"
 while [[ ${realbasedir} != '/' ]]; do
     if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
         [[ -d ${basedir}/${dirname} ]] && \
-        [[ -f ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
+        [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
             break
     else
         [[ -d ${basedir}/${dirname} ]] && break