about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-10-04 18:18:12 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-10-04 18:18:12 +0000
commit179cd828a57c36f312ed7f95abf5e7d8d5fe44a2 (patch)
tree5e7019d246e4093cc233edc61cc3ce5e817d8761 /Functions
parent500431077b5a8e9ba1af3e2cb87bae5d4701c799 (diff)
downloadzsh-179cd828a57c36f312ed7f95abf5e7d8d5fe44a2.tar.gz
zsh-179cd828a57c36f312ed7f95abf5e7d8d5fe44a2.tar.xz
zsh-179cd828a57c36f312ed7f95abf5e7d8d5fe44a2.zip
Lionel Flandrin: 27307: enhanced Mecurial VCS_INFO support
Diffstat (limited to 'Functions')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_hg30
1 files changed, 28 insertions, 2 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index d83521b14..0b66463fa 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -3,7 +3,21 @@
 ## Distributed under the same BSD-ish license as zsh itself.
 
 setopt localoptions NO_shwordsplit
-local file hgbranch hgbranch_name hgbase hghash hglrev r_branch r_info
+local file hgbranch hgbranch_name hgbase hghash hglrev hgmisc r_branch r_info revformat
+
+VCS_INFO_hg_get_mq_top_patch () {
+    local patchdir=$1
+
+    if [[ -e "${patchdir}/status" ]]; then
+        local -a patches
+        patches=(${(f)"$(< "${patchdir}/status")"})
+        printf "%s" "${patches[-1]/[^:]*:/}"
+        return 0
+    fi
+
+    return 1
+}
+
 
 hgbase=${vcs_comm[basedir]}
 rrn=${hgbase:t}
@@ -34,6 +48,8 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
     done
 
     if [[ -n ${hglrev} ]] ; then
+        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" hgrevformat revformat || revformat="%r:%h"
+        zformat -f hglrev "${revformat}" "r:${hglrev}" "h:${hghash}"
         zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat hgbranch || hgbranch="%b:%r"
         zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev}"
     fi
@@ -41,5 +57,15 @@ else
     hgbranch="${hgbranch_name}"
 fi
 
-VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hghash}"
+local patchdir=${hgbase}/.hg/patches/
+
+if [[ -d $patchdir ]] ; then
+    hgmisc=$(VCS_INFO_hg_get_mq_top_patch "${patchdir}")
+
+    hgmisc=${hgmisc:-"no patch applied"}
+else
+    hgmisc=''
+fi
+
+VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hgmisc}"
 return 0