zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 3/3] vcs_info hg mq: Extract patch subjects
Date: Sat, 29 Jan 2022 16:15:27 +0000	[thread overview]
Message-ID: <20220129161527.17303-3-danielsh@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20220129161527.17303-1-danielsh@tarpaulin.shahaf.local2>

Use a NUL separator just in case someone's hg mq patch names include
literal spaces.  That means gen-applied-string hooks have to split their
arguments one way in the hg mq case and another way in every other case.
---
 Doc/Zsh/contrib.yo                            | 18 +++++++++++-----
 .../VCS_Info/Backends/VCS_INFO_get_data_hg    | 21 +++++++++++++++++++
 README                                        |  7 +++++++
 3 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 2cda891ec..c68fe33ef 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1656,12 +1656,20 @@ The arguments to this hook describe applied patches
 in the opposite order, which means that the first argument is the
 top-most patch and so forth.
 
-When the patches' log messages can be extracted, those are embedded
-within each argument after a space, so each argument is of the form
+Each argument contains both a patch name and, if possible, the first line of
+that patch's log message or description.  A literal `tt(?)' is substituted
+when the log message or description is empty or unable to be determined.
+
+In the tt(mq) backend, patch names may contain spaces, and each argument
+is of the form `var(patch name)tt($'\0')var(first line of the log message)',
+using a literal NUL as a separator.
+
+In the other backends, each argument is of the form
 `var(patch-name) var(first line of the log message)', where var(patch-name)
-contains no whitespace. The tt(mq) backend passes arguments of
-the form `var(patch name)', with possible embedded spaces, but without
-extracting the patch's log message.
+contains no whitespace.  Typically, one would use
+tt(${argv[1]#* }) and tt(${argv[1]%% *}) to separate the var(patch-name) and
+var(first line of the log message) parts.  (See the file
+tt(Misc/vcs_info-examples) in the source distribution for a complete example.)
 
 When setting tt(ret) to non-zero, the string in
 tt(${hook_com[applied-string]}) will be
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index d789d662a..cfaa3fe5e 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -211,6 +211,27 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
         done < ${mqseriesfile}
     fi
 
+    () {
+        local -a tmp
+        local i
+
+        tmp=()
+        for i in "${mqpatches[@]}" ; do
+            VCS_INFO_patch2subject "${patchdir}/$i"
+            [[ $REPLY == '# HG changeset patch' ]] && unset REPLY
+            tmp+=( "$i"$'\0'"${REPLY="?"}" )
+        done
+        mqpatches=( "${tmp[@]}" )
+
+        tmp=()
+        for i in "${mqunapplied[@]}" ; do
+            VCS_INFO_patch2subject "${patchdir}/$i"
+            [[ $REPLY == '# HG changeset patch' ]] && unset REPLY
+            tmp+=( "$i"$'\0'"${REPLY="?"}" )
+        done
+        mqunapplied=( "${tmp[@]}" )
+    }
+
     if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then
         guards_string=${(j:,:)mqguards}
         # TODO: %-escape extra_zformats[g:...] value
diff --git a/README b/README
index 3ef8afcd1..25a61a4b8 100644
--- a/README
+++ b/README
@@ -102,6 +102,13 @@ consistent with most other sh implementations.
 getopts now calculates OPTIND in a similar manner to other shells when the
 POSIX_BUILTINS option is enabled.
 
+vcs_info hg: Arguments to the gen-applied-string and gen-unapplied-string hooks
+now contain not only the patch's name but also the first line of the patch's
+log message.  The two parts are separated by a NUL byte.
+.
+This only affects you if you have defined custom vcs_info hook functions (see
+the output of 'zstyle -L ":vcs_info:*" hooks' and 'which -m -- "+vi*"' [sic]).
+
 Incompatibilities between 5.7.1 and 5.8
 ---------------------------------------
 


  parent reply	other threads:[~2022-01-29 16:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-29 16:15 [PATCH 1/3] vcs_info quilt: Pass the patches dir path to the gen-applied-string, gen-unapplied-string, and set-patch-format hooks Daniel Shahaf
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 ` Daniel Shahaf [this message]
2022-03-31  6:00   ` [PATCH 3/3] vcs_info hg mq: Extract patch subjects 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-3-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).