zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: (5/5) Make the hg backend work with new versions of mercurial
Date: Mon,  6 Apr 2009 19:45:38 +0200	[thread overview]
Message-ID: <1239039938-20782-6-git-send-email-ft@bewatermyfriend.org> (raw)
In-Reply-To: <1239039938-20782-1-git-send-email-ft@bewatermyfriend.org>

VCS_INFO_bydir_detect() now accepts every kind of file in
${vcs_comm[detect_need_file]} not just plain files.

The hg backend uses that by detecting via (paraphrased):
[[ -d .hg ]] && [[ -e .hg/store ]]
where .hg/store is a directory.

If .hg/branch is missing, the branch name defaults to 'default'.
---
 Functions/VCS_Info/Backends/VCS_INFO_detect_hg   |    2 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg |   10 ++++++++--
 Functions/VCS_Info/VCS_INFO_bydir_detect         |    2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
index 41fcc4b..36078b7 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_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index f8e21a9..d83521b 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -3,11 +3,17 @@
 ## Distributed under the same BSD-ish license as zsh itself.
 
 setopt localoptions NO_shwordsplit
-local hgbranch hgbranch_name hgbase hghash hglrev r_branch r_info
+local file hgbranch hgbranch_name hgbase hghash hglrev r_branch r_info
 
 hgbase=${vcs_comm[basedir]}
 rrn=${hgbase:t}
-hgbranch_name=$(< ${hgbase}/.hg/branch)
+
+file="${hgbase}/.hg/branch"
+if [[ -r ${file} ]] ; then
+    hgbranch_name=$(< ${file})
+else
+    hgbranch_name="default"
+fi
 
 hghash=''
 hglrev=''
diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index aff59f3..7985b69 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
-- 
1.6.2.1.136.g8e24


      parent reply	other threads:[~2009-04-06 17:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-06 17:45 PATCH: (0/5) Updates for vcs_info Frank Terbeck
2009-04-06 17:45 ` PATCH: (1/5) vcs_info: add revision and "misc" argument to VCS_INFO_formats() Frank Terbeck
2009-04-06 17:45 ` PATCH: (2/5) Add git's sha1 hash as revision information Frank Terbeck
2009-04-06 17:45 ` PATCH: (3/5) Add information about hg's local revision number and the commit's hash Frank Terbeck
2009-04-06 17:45 ` PATCH: (4/5) contrib.yo: updates for get-revision, %i and %m Frank Terbeck
2009-04-06 17:45 ` Frank Terbeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239039938-20782-6-git-send-email-ft@bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).