zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs_info svn: 'Fix set-branch-format' when in subdirs
Date: Sun, 25 May 2014 21:56:26 +0000	[thread overview]
Message-ID: <20140525215626.GE2726@tarsus.local2> (raw)

The previous code would fail to detect the wcroot with Subversion 1.7+
when cwd is at least two levels below the root (i.e., ../../.svn exists
and ../.svn doesn't), and would then pass to the hook the revision and
basename of cwd rather than of the wcroot.
---

Two caveats:

1. This patch will conflict if applied before the other patch I just
sent.  The conflict is syntactic, not semantic, and only affects hunk
context lines.

2. I haven't tested this patch in any way.

 Functions/VCS_Info/Backends/VCS_INFO_get_data_svn |   22 ++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index ae3c499..e56afee 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -30,13 +30,21 @@ done
 
 cwdinfo=(${(kv)svninfo})
 
-while [[ -d "${svnbase}/../.svn" ]]; do
-    parentinfo=()
-    ${vcs_comm[cmd]} info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
-    [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break
-    svninfo=(${(kv)parentinfo})
-    svnbase="${svnbase}/.."
-done
+# Set svnbase to the wcroot path and svninfo to its `svn info`.
+if (( ${+svninfo[Working_Copy_Root_Path]} )); then
+  # svn 1.7+
+  svnbase=${svninfo[Working_Copy_Root_Path]}
+  ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
+else
+  # svn 1.0-1.6
+  while [[ -d "${svnbase}/../.svn" ]]; do
+      parentinfo=()
+      ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
+      [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break
+      svninfo=(${(kv)parentinfo})
+      svnbase="${svnbase}/.."
+  done
+fi
 
 svnbase="$(VCS_INFO_realpath ${svnbase})"
 
-- 
1.7.10.4


                 reply	other threads:[~2014-05-25 22:07 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=20140525215626.GE2726@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).