Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 3/3] vcs_info hg mq: Extract patch subjects



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
 ---------------------------------------
 




Messages sorted by: Reverse Date, Date, Thread, Author