zshrc: handle newer versions of mercurial
authorFrank Terbeck <ft@bewatermyfriend.org>
Mon, 6 Apr 2009 11:05:48 +0000 (13:05 +0200)
committerFrank Terbeck <ft@bewatermyfriend.org>
Mon, 6 Apr 2009 11:05:48 +0000 (13:05 +0200)
It seems like the mercurial vcs (hg) does not create a .hg/branch file anymore,
if there is only the 'default' branch. That broke hg-detection in vcs_info.

This detects hg repositories by the .hg/store directory and defaults to 'default'
if there is no .hg/branch file.

debian/changelog
etc/zsh/zshrc

index dbeee10..6355558 100644 (file)
@@ -1,3 +1,10 @@
+grml-etc-core (0.3.67) unstable; urgency=low
+
+  * zshrc: handle newer versions of hg, that don't create .hg/branch
+    anymore if there's only 'default'. Found by Andreas Korsten.
+
+ -- Frank Terbeck <ft@grml.org>  Mon, 06 Apr 2009 13:00:28 +0200
+
 grml-etc-core (0.3.66) unstable; urgency=low
 
   * vimrc: only set screen title if the caller explicitly asks for it.
index 8a836cd..86e5243 100644 (file)
@@ -1627,10 +1627,17 @@ VCS_INFO_git_get_data () { # {{{
 }
 # }}}
 VCS_INFO_hg_get_data () { # {{{
-    local hgbranch hgbase
+    local hgbranch hgbase file
 
     hgbase=${vcs_comm[basedir]}
-    hgbranch=$(< ${hgbase}/.hg/branch)
+
+    file="${hgbase}/.hg/branch"
+    if [[ -r ${file} ]] ; then
+        hgbranch=$(< ${file})
+    else
+        hgbranch='default'
+    fi
+
     VCS_INFO_formats '' "${hgbranch}" "${hgbase}"
     return 0
 }
@@ -1691,7 +1698,7 @@ VCS_INFO_detect_by_dir() { #{{{
     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
@@ -1745,7 +1752,7 @@ VCS_INFO_git_detect() { #{{{
 # }}}
 VCS_INFO_hg_detect() { #{{{
     VCS_INFO_check_com hg || return 1
-    vcs_comm[detect_need_file]=branch
+    vcs_comm[detect_need_file]=store
     VCS_INFO_detect_by_dir '.hg'
     return $?
 }