zsh-users
 help / color / mirror / code / Atom feed
* [WIP PATCH] vcs_info svn support for 'svnversion'
@ 2019-12-01  0:52 Daniel Shahaf
  2019-12-10  5:17 ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages 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
anyone.

Cheers,

Daniel


[[[
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.
 )
 kindex(check-for-changes)
 item(tt(check-for-changes))(
+TODO(svn)
 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.
 )
 kindex(get-revision)
 item(tt(get-revision))(
+TODO(svn)
 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}
 rrn=${svnbase:t}
 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
+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]}"
 else
     svnbranch=${hook_com[branch-replace]}
 fi
 hook_com=()
-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] 3+ messages in thread

end of thread, other threads:[~2019-12-10  5:56 UTC | newest]

Thread overview: 3+ messages (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
2019-12-10  5:17 ` Daniel Shahaf
2019-12-10  5:55   ` Daniel Shahaf

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).