From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 1/3] vcs_info quilt: Pass the patches dir path to the gen-applied-string, gen-unapplied-string, and set-patch-format hooks
Date: Sat, 29 Jan 2022 16:15:25 +0000 [thread overview]
Message-ID: <20220129161527.17303-1-danielsh@tarpaulin.shahaf.local2> (raw)
I use that in my gen-applied-string hook.
---
This answers my question from workers/49724.
Doc/Zsh/contrib.yo | 12 ++++++++++++
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +-
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 2 +-
Functions/VCS_Info/VCS_INFO_quilt | 7 ++++++-
Functions/VCS_Info/VCS_INFO_set-patch-format | 8 +++++++-
5 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index eb5bbafb2..2cda891ec 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1669,6 +1669,10 @@ 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)).)
+
+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 +1691,10 @@ 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)).)
+
+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 +1777,10 @@ 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)).)
+
+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.
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index fe084dffb..e45eebc8e 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -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
}
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index b123e2270..0041a153c 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -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
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index ee242f552..ce5b41f24 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -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
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index c35b695c3..1c774a7f6 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -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'
next reply other threads:[~2022-01-29 16:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 16:15 Daniel Shahaf [this message]
2022-01-29 16:15 ` [PATCH 2/3] vcs_info hg mq: Don't include applied patches in the unapplied patches Daniel Shahaf
2022-01-29 16:15 ` [PATCH 3/3] vcs_info hg mq: Extract patch subjects Daniel Shahaf
2022-03-31 6:00 ` Lawrence Velázquez
2022-04-01 0:21 ` 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=20220129161527.17303-1-danielsh@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@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).