1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

49727 (+ comment): vcs_info quilt: Pass the patches dir path to the gen-applied-string, gen-unapplied-string, and set-patch-format hooks

I use that in my gen-applied-string hook.
This commit is contained in:
Daniel Shahaf 2022-01-29 16:15:25 +00:00
parent b8b7d9b46a
commit 80389df480
6 changed files with 38 additions and 4 deletions

View file

@ -1,5 +1,13 @@
2022-02-20 Daniel Shahaf <d.s@daniel.shahaf.name>
* 49727 (+ comment): Doc/Zsh/contrib.yo,
Functions/VCS_Info/Backends/VCS_INFO_get_data_git,
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg,
Functions/VCS_Info/VCS_INFO_quilt,
Functions/VCS_Info/VCS_INFO_set-patch-format: vcs_info
quilt: Pass the patches dir path to the gen-applied-string,
gen-unapplied-string, and set-patch-format hooks
* unposted: Functions/VCS_Info/Backends/VCS_INFO_get_data_hg:
vcs_info hg mg (with get-unapplied set): Stop leaking a variable
to global scope

View file

@ -1669,6 +1669,11 @@ available as tt(%p) in the tt(patch-format) and tt(nopatch-format) styles.
This hook is, in concert with tt(set-patch-format), responsible for
tt(%)-escaping that value for use in the prompt.
(See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).)
COMMENT(This paragraph is repeated above/below)\
The tt(quilt) backend passes to this hook the inputs
tt(${hook_com[quilt-patches-dir]}) and, if it has been
determined, tt(${hook_com[quilt-pc-dir]}).
)
item(tt(gen-unapplied-string))(
Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg) (with
@ -1687,6 +1692,11 @@ tt(patch-format) and tt(nopatch-format) styles.
This hook is, in concert with tt(set-patch-format), responsible for
tt(%)-escaping that value for use in the prompt.
(See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).)
COMMENT(This paragraph is repeated above/below)\
The tt(quilt) backend passes to this hook the inputs
tt(${hook_com[quilt-patches-dir]}) and, if it has been
determined, tt(${hook_com[quilt-pc-dir]}).
)
item(tt(gen-mqguards-string))(
Called in the tt(hg) backend when tt(guards-string) is generated; the
@ -1769,6 +1779,11 @@ This hook is, in concert with the tt(gen-applied-string) or
tt(gen-unapplied-string) hooks if they are defined, responsible for
tt(%)-escaping the final tt(patch-format) value for use in the prompt.
(See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).)
COMMENT(This paragraph is repeated above/below)\
The tt(quilt) backend passes to this hook the inputs
tt(${hook_com[quilt-patches-dir]}) and, if it has been
determined, tt(${hook_com[quilt-pc-dir]}).
)
item(tt(set-message))(
Called each time before a `tt(vcs_info_msg_)var(N)tt(_)' message is set.

View file

@ -132,7 +132,7 @@ VCS_INFO_git_handle_patches () {
VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \
'git_patches_unapplied' 'git_unapplied_s' \
":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg \
'' ''
'' '' ''
gitmisc=$REPLY
}

View file

@ -225,7 +225,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \
'mqunapplied' 'unapplied_string' \
":vcs_info:${vcs}:${usercontext}:${rrn}" hgmqstring \
extra_hook_com VCS_INFO_hg_extra_zformats
extra_hook_com VCS_INFO_hg_extra_zformats ''
hgmqstring=$REPLY
fi

View file

@ -179,10 +179,15 @@ function VCS_INFO_quilt-patch2subject() {
done
}
typeset -A quilt_extra_info=(
quilt-patches-dir ${patches}
${pc:+"quilt-pc-dir"} $pc
)
VCS_INFO_set-patch-format 'applied' 'applied_string' \
'unapplied' 'unapplied_string' \
${context} qstring \
'' ''
quilt_extra_info '' quilt_extra_info
qstring=$REPLY
case ${mode} in

View file

@ -15,6 +15,8 @@
# $7 - name of an assoc parameter with extra $hook_com key-value pairs for the
# set-patch-format hook invocation, or '' for none
# $8 - name of a function that sets $reply to extra arguments for the patch-format zformat call, or '' for none
# $9 - name of an assoc parameter with extra $hook_com key-value pairs for the
# gen-applied-string & gen-unapplied-string hook invocations, or '' for none
#
# The expanded patch-format string is returned in $REPLY.
#
@ -22,8 +24,10 @@
# - $hook_com is overwritten and the keys 'applied', 'applied-n',
# 'unapplied', 'unapplied-n', 'all-n' are set.
{
hook_com=()
local applied_needs_escaping='unknown'
local unapplied_needs_escaping='unknown'
hook_com+=( ${9:+"${(@kvP)9}"} )
if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
if (( ${(P)#1} )); then
REPLY=${(P)1[1]}
@ -37,6 +41,8 @@
: ${(P)2::=$REPLY}
hook_com=()
local unapplied_needs_escaping='unknown'
hook_com+=( ${9:+"${(@kvP)9}"} )
if VCS_INFO_hook 'gen-unapplied-string' "${(@P)3}"; then
REPLY=${(P)#3}
unapplied_needs_escaping='yes'