From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: [WIP PATCH] vcs_info svn support for 'svnversion'
Date: Sun, 1 Dec 2019 00:52:17 +0000 [thread overview]
Message-ID: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2> (raw)
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
]]]
next reply other threads:[~2019-12-01 0:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-01 0:52 Daniel Shahaf [this message]
2019-12-10 5:17 ` Daniel Shahaf
2019-12-10 5:55 ` Daniel Shahaf
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=20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-users@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).