help / color / Atom feed
* [WIP PATCH] vcs_info svn support for 'svnversion'
@ 2019-12-01  0:52 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2019-12-01  0:52 UTC (permalink / raw)
  To: zsh-users

I hacked up 'svnversion' support into vcs_info, to enable vcs_info to indicate
non-uniform revisions and local mods in Subversion working copies.

As it stands, I feel it's too hacky — see log message for details — so I don't
intend to commit it as-is.  However, I'm posting it here in case it's useful to



From: Daniel Shahaf <danielsh@apache.org>
Subject: [PATCH]
 WIP: vcs_info svn: Use svnversion to show uniform revisions and local mods

The 'staged' expando, %c, will now be set if there's an 'M' in the output of `svnversion`.

The 'revision number' expando, %i, will now show the full output of svnversion.

svnversion will only be used if the check-for-changes and get-revision styles are both set.

TODO: derive the svnversion command name robustly
TODO: write docs
 Doc/Zsh/contrib.yo                                |  2 ++
 Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 21 +++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index d32ba018d..a20bf0c19 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1095,6 +1095,7 @@ is used as the command name.
 If enabled, this style causes the tt(%c) and tt(%u) format escapes to show
 when the working directory has uncommitted changes. The strings displayed by
 these escapes can be controlled via the tt(stagedstr) and tt(unstagedstr)
@@ -1183,6 +1184,7 @@ method will not return the local revision number.
 If set to true, vcs_info goes the extra mile to figure out the revision of
 a repository's work tree (currently for the tt(git) and tt(hg) backends,
 where this kind of information is not always vital). For tt(git), the
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index c1547950f..dd5ce1b0f 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -6,6 +6,7 @@
 setopt localoptions noksharrays extendedglob NO_shwordsplit
 local svnbase svnbranch a b rrn
+local non_uniform_revision modified
 local -i rc
 local -A svninfo parentinfo cwdinfo
 local -A hook_com
@@ -60,11 +61,27 @@ svnbase=${svnbase:P}
 zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
 hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
+if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" &&
+   zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "get-revision" ; then
+    local svnversion_cmd
+    if [[ $vcs_comm[cmd] == */* ]]; then
+        svnversion_cmd=${vcs_comm[cmd]:h}/${${vcs_comm[cmd]:t}/svn/svnversion}
+    else
+        svnversion_cmd=${vcs_comm[cmd]/svn/svnversion}
+    fi
+    hook_com[svnversion]=$($svnversion_cmd 2>/dev/null)
+    if [[ ${hook_com[svnversion]} == *M* ]]; then
+        modified=${hook_com[svnversion]}
+    fi
+    if [[ ${hook_com[svnversion]} == *:* ]]; then
+        non_uniform_revision=${hook_com[svnversion]}
+    fi
 if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then
-    zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+    zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}" "v:${hook_com[svnversion]}"
-VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${cwdinfo[Revision]}" ''
+VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' "$modified" "${non_uniform_revision:-${cwdinfo[Revision]}}" ''
 return 0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  0:52 [WIP PATCH] vcs_info svn support for 'svnversion' Daniel Shahaf


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git