Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [WIP PATCH] vcs_info svn support for 'svnversion'
- X-seq: zsh-users 24510
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: [WIP PATCH] vcs_info svn support for 'svnversion'
- Date: Tue, 10 Dec 2019 05:17:34 +0000
- In-reply-to: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2>
Daniel Shahaf wrote on Sun, Dec 01, 2019 at 00:52:17 +0000:
> [[[
> From: Daniel Shahaf <danielsh@xxxxxxxxxx>
> 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
Here's another version. Differences:
- It's not a patch now, but configuration to be added to zshrc.
- It uses only public APIs, but takes advantage of an implementation detail to
avoid svnversion doing a (potentially expensive) tree crawl. The trade-off is
that it's not read-only any more.
[[[
zstyle -e ':vcs_info:svn+post-backend:*' hooks 'reply=( ${${(k)functions[(I)[+]vi-svn-post-backend*]}#+vi-} )'
## svn: indicate mixed-revision working copies in the %i (revision) expando
zstyle -e ':vcs_info:svn:*:*' "zshrc:make-temporary-changes" '[[ $PWD == ~/* ]] && reply=(true)'
+vi-svn-post-backend-mixed-revision() {
local non_uniform_revision modified
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
local output="$(svnversion 2>/dev/null)"
if [[ ${output} == *M* ]]; then
hook_com[unstaged]='yes' # value is ignored
fi
if [[ ${output} == *:* ]]; then
non_uniform_revision=${output}
fi
elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "zshrc:make-temporary-changes" \
&& [[ -w ${hook_com[base_orig]}/.svn/wc.db ]]; then
{
# Make a dummy propmod to prevent svnversion(1) from doing a worktree stat() crawl.
#
# This relies on an implementation detail of svn_wc_revision_status2():
# It will not do a tree crawl if it detected a propery mod (or a tree mod).
${vcs_comm[cmd]} propset --quiet vcs_info:dummy yes -- ${hook_com[base_orig]}
local output="${$(svnversion 2>/dev/null)/M/}" # remove 'M' caused by the dummy propmod
if [[ ${output} == *:* ]]; then
non_uniform_revision=${output}
fi
} always {
${vcs_comm[cmd]} propdel --quiet vcs_info:dummy -- ${hook_com[base_orig]}
}
fi
if [[ $non_uniform_revision == *:* ]]; then
integer min=${non_uniform_revision%%:*} max=${${non_uniform_revision#*:}%%[^0-9]*}
hook_com[revision]="r${min}:r${max}${non_uniform_revision//[0-9:]##}"
hook_com[revision]+=" (+$((max-min)))"
fi
return 0
}
]]]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author