zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: PATCH: PATCH: vcs_info: Detect very old mercurial repositories
Date: Sat, 19 Feb 2011 11:17:58 +0100	[thread overview]
Message-ID: <1298110678-31888-1-git-send-email-ft@bewatermyfriend.org> (raw)

On IRC Chris AtLee reported, that vcs_info's mercurial backend fails
to detect very very old mercurial repositories. Seth House dug back into
history and found out that checking for .hg/data will work these ancient
repositories.

This changes VCS_INFO_bydir_detect() to be able to check for more than
one file in `${vcs_comm[detect_need_file]}'. This limits file names
in that variable to not include spaces. That is not an issue currently
and shouldn't be in the future.

In essence, this looks for .hg/store to detect current repositories and
for .hg/data for ancient ones.
---
 Functions/VCS_Info/Backends/VCS_INFO_detect_hg   |    2 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg |    2 +-
 Functions/VCS_Info/VCS_INFO_bydir_detect         |   10 ++++++----
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
index e2866af..a22c1ee 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
@@ -7,7 +7,7 @@ setopt localoptions NO_shwordsplit
 [[ $1 == '--flavours' ]] && { print -l hg-git hg-hgsubversion hg-hgsvn; return 0 }
 
 VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
-vcs_comm[detect_need_file]=store
+vcs_comm[detect_need_file]="store data"
 VCS_INFO_bydir_detect '.hg' || return 1
 
 if [[ -d ${vcs_comm[basedir]}/.hg/svn ]] ; then
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 8e91d26..a1b87f5 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -50,7 +50,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
             "check-for-changes" || hgid_args+=( -r. )
 
         local HGRCPATH
-        HGRCPATH="/dev/null" ${vcs_comm[cmd]} ${(z)hgid_args} \
+        HGRCPATH="/dev/null" ${vcs_comm[cmd]} ${(z)hgid_args} 2> /dev/null \
             | read -r r_csetid r_lrev r_branch
     fi
 fi
diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index 0b5996f..70b0fb6 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -4,15 +4,17 @@
 
 setopt localoptions NO_shwordsplit
 local dirname=$1
-local basedir="." realbasedir
+local basedir="." realbasedir file
 
 realbasedir="$(VCS_INFO_realpath ${basedir})"
 while [[ ${realbasedir} != '/' ]]; do
     [[ -r ${realbasedir} ]] || return 1
     if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
-        [[ -d ${basedir}/${dirname} ]] && \
-        [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
-            break
+        [[ -d ${basedir}/${dirname} ]] && {
+            for file in ${(s: :)${vcs_comm[detect_need_file]}}; do
+                [[ -e ${basedir}/${dirname}/${file} ]] && break 2
+            done
+        }
     else
         [[ -d ${basedir}/${dirname} ]] && break
     fi
-- 
1.7.4.rc1.7.g2cf08


                 reply	other threads:[~2011-02-19 10:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1298110678-31888-1-git-send-email-ft@bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=zsh-workers@zsh.org \
    /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).