From 102c2da0fd90751bbff72ac846ef6b1718ca3862 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Fri, 29 Aug 2008 19:11:50 +0200 Subject: [PATCH] zshrc: Handle non-repo .hg subdirectories Such directories, that are not the .hg subdirectory of a mercurial repository. Found by Karl Voit. --- debian/changelog | 4 +++- etc/zsh/zshrc | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4c7a499..4f12d95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,10 @@ grml-etc-core (0.3.53) unstable; urgency=low rebase conflicts * zshrc: Make vcs_info() detect $GIT_DIR/svn and set the name of the vcs to 'git-svn' + * zshrc: Handle .hg subdirectories, that are not the .hg subdirectory + of a mercurial repository. Found by Karl Voit. - -- Frank Terbeck Wed, 27 Aug 2008 22:35:09 +0200 + -- Frank Terbeck Fri, 29 Aug 2008 19:08:28 +0200 grml-etc-core (0.3.52) unstable; urgency=low diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 45abfd1..0bb49ad 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1097,6 +1097,10 @@ VCS_INFO_format () { # {{{ # }}} VCS_INFO_realpath () { #{{{ # replacing 'readlink -f', which is really not portable. + + # If there *is* a chpwd() function unfunction it here. + # The *real* zsh does not loose its chpwd(), because we run + # in a different context (process substitution in $PROMPT). (( ${+functions[chpwd]} )) && unfunction chpwd setopt chaselinks cd $1 2>/dev/null && pwd @@ -1269,14 +1273,24 @@ VCS_INFO_bzr_get_data () { # {{{ VCS_INFO_detect_by_dir() { local dirname=${1} - local basedir="." + local basedir="." realbasedir + + 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]} ]] && \ + break + else + [[ -d ${basedir}/${dirname} ]] && break + fi - while [[ ! -d ${basedir}/${dirname} ]]; do basedir=${basedir}/.. - [[ $(VCS_INFO_realpath ${basedir}) = "/" ]] && return 1 + realbasedir=$(VCS_INFO_realpath ${basedir}) done - vcs_comm[basedir]=${basedir} + [[ ${realbasedir} == "/" ]] && return 1 + vcs_comm[basedir]=${realbasedir} return 0 } @@ -1297,6 +1311,7 @@ VCS_INFO_git_detect() { VCS_INFO_hg_detect() { check_com -c hg || return 1 + vcs_comm[detect_need_file]=branch VCS_INFO_detect_by_dir '.hg' return $? } -- 2.1.4