From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27965 invoked by alias); 23 Jan 2017 19:17:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40403 Received: (qmail 20361 invoked from network); 23 Jan 2017 19:17:08 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 2.867274 secs); 23 Jan 2017 19:17:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=0pyDIPci6dTizitgwvdvMXNVSxQ=; b=SLX0JM Iz4+da7sgwwNjAvNyICbXfkGhAKqRSFBcWQWzGxSquGvFE5iG5OoUma3fi4Lu+na 2/pjSk3oEEBoD46dC6Ye4Y9tn2J9j0AIHO3FXgHbuOlFyxa7YaE+rSFsHKUcbIwF 6BwTRSmBecvLqpAkyYmRtoFbs7L9bPD8Yis/0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=smtpout; bh=0pyDIPci6dTizitgwvdvMXNVSxQ=; b=gA/Dj XSj6eN39omcQAysJhO6bUBrlV9B5oA/T7g3V1nM6dlZQ6s050scoyAaIuTDlNxNF Vt4raApu3AGIyIpQoMzNDGxI3h9fv7B298UywPHjBMsWwb4wBtffw5x3zhgGU8SA cU55pFPc+t/h1uE4iqGlwwSkeizZ0Fsdyk5W+E= X-ME-Sender: X-Sasl-enc: qPL93nj8n77opW30FgeSOqdv+3rLTI1LoUc3eRHBu/2y 1485199022 Date: Mon, 23 Jan 2017 19:13:20 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 1..4/4] vcs_info set-patch-format helper Message-ID: <20170123191320.GA25339@fujitsu.shahaf.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) --jRHKVT23PllUwdXP Content-Type: text/plain; charset=utf-8 Content-Disposition: inline This is just a bit of code deduplication. It depends on the %c patch I just posted, but is independent of the "'%' in payloads not escaped" thread. The fourth patch also fixes a bug in the hg backend. Will commit with ${XSEQ}/000{1..4} as before. Cheers, Daniel --jRHKVT23PllUwdXP Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-vcs_info-set-patch-format-helper-Part-1.patch" >>From 6505e0aaecaccfb36804623d89c572cc5324cd0a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 23 Jan 2017 18:15:35 +0000 Subject: [PATCH 1/4] vcs_info set-patch-format helper: Part #1. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 11 +---------- Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 9 +-------- Functions/VCS_Info/VCS_INFO_quilt | 11 +---------- Functions/VCS_Info/VCS_INFO_set-patch-format | 20 ++++++++++++++++++++ Functions/VCS_Info/vcs_info | 1 + 5 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 Functions/VCS_Info/VCS_INFO_set-patch-format diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index efb77b7..02ea402 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -125,16 +125,7 @@ VCS_INFO_git_handle_patches () { git_patches_unapplied=(${(Oa)git_patches_unapplied}) (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} )) - if VCS_INFO_hook 'gen-applied-string' "${git_patches_applied[@]}"; then - if (( ${#git_patches_applied} )); then - git_applied_s=${git_patches_applied[1]} - else - git_applied_s="" - fi - else - git_applied_s=${hook_com[applied-string]} - fi - hook_com=() + VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' if VCS_INFO_hook 'gen-unapplied-string' "${git_patches_unapplied[@]}"; then git_unapplied_s=${#git_patches_unapplied} else diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 69b7db3..19bec7a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -203,14 +203,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ done < ${mqseriesfile} fi - if VCS_INFO_hook 'gen-applied-string' "${mqpatches[@]}"; then - (( ${#mqpatches} )) && applied_string=${mqpatches[1]} - else - applied_string=${hook_com[applied-string]} - fi - - hook_com=() - + VCS_INFO_set-patch-format 'mqpatches' 'applied_string' if VCS_INFO_hook 'gen-unapplied-string' "${mqunapplied[@]}"; then unapplied_string=${#mqunapplied} else diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 4c61506..dd3f495 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -173,16 +173,7 @@ function VCS_INFO_quilt() { all=( ${(Oa)applied} ${unapplied} ) - if VCS_INFO_hook 'gen-applied-string' "${applied[@]}"; then - if (( ${#applied} )); then - applied_string=${applied[1]} - else - applied_string="" - fi - else - applied_string=${hook_com[applied-string]} - fi - hook_com=() + VCS_INFO_set-patch-format 'applied' 'applied_string' if VCS_INFO_hook 'gen-unapplied-string' "${unapplied[@]}"; then unapplied_string="${#unapplied}" else diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format new file mode 100644 index 0000000..310df96 --- /dev/null +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -0,0 +1,20 @@ +# This function is the common guts of the gen-applied-string / +# gen-unapplied-string / set-patch-format dance of several backends. +# +# Parameters: +# $1 - name of an array parameter to be the argument to gen-applied-string +# $2 - name of a parameter to store the applied-string in +{ + local REPLY + if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then + if (( ${(P)#1} )); then + REPLY=${(P)1[1]} + else + REPLY="" + fi + else + REPLY=${hook_com[applied-string]} + fi + : ${(P)2::=$REPLY} + hook_com=() +} diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 24ae98e..4e9ac6c 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -21,6 +21,7 @@ static_functions=( VCS_INFO_get_cmd VCS_INFO_hexdump VCS_INFO_hook + VCS_INFO_set-patch-format VCS_INFO_maxexports VCS_INFO_nvcsformats VCS_INFO_patch2subject --jRHKVT23PllUwdXP Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-vcs_info-set-patch-format-helper-Part-2.patch" >>From b9d9499e64207c780a6ad9e7adf9129b47338ea2 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 23 Jan 2017 18:15:35 +0000 Subject: [PATCH 2/4] vcs_info set-patch-format helper: Part #2. Not all callers reset ${hook_com}, but those that don't, immediately overwrite it a few lines later. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 8 ++------ Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 11 ++--------- Functions/VCS_Info/VCS_INFO_quilt | 8 ++------ Functions/VCS_Info/VCS_INFO_set-patch-format | 10 ++++++++++ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 02ea402..e7b9ac4 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -125,12 +125,8 @@ VCS_INFO_git_handle_patches () { git_patches_unapplied=(${(Oa)git_patches_unapplied}) (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} )) - VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' - if VCS_INFO_hook 'gen-unapplied-string' "${git_patches_unapplied[@]}"; then - git_unapplied_s=${#git_patches_unapplied} - else - git_unapplied_s=${hook_com[unapplied-string]} - fi + VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \ + 'git_patches_unapplied' 'git_unapplied_s' if (( ${#git_patches_applied} )); then zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 19bec7a..90164fb 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -203,15 +203,8 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ done < ${mqseriesfile} fi - VCS_INFO_set-patch-format 'mqpatches' 'applied_string' - if VCS_INFO_hook 'gen-unapplied-string' "${mqunapplied[@]}"; then - unapplied_string=${#mqunapplied} - else - unapplied_string=${hook_com[unapplied-string]} - fi - - hook_com=() - + VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \ + 'mqunapplied' 'unapplied_string' if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then guards_string=${(j:,:)mqguards} else diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index dd3f495..1872fc7 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -173,12 +173,8 @@ function VCS_INFO_quilt() { all=( ${(Oa)applied} ${unapplied} ) - VCS_INFO_set-patch-format 'applied' 'applied_string' - if VCS_INFO_hook 'gen-unapplied-string' "${unapplied[@]}"; then - unapplied_string="${#unapplied}" - else - unapplied_string=${hook_com[unapplied-string]} - fi + VCS_INFO_set-patch-format 'applied' 'applied_string' \ + 'unapplied' 'unapplied_string' if (( ${#applied} )); then zstyle -s "${context}" patch-format qstring || qstring="%p (%n applied)" diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index 310df96..0bbd474 100644 --- a/Functions/VCS_Info/VCS_INFO_set-patch-format +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -4,6 +4,8 @@ # Parameters: # $1 - name of an array parameter to be the argument to gen-applied-string # $2 - name of a parameter to store the applied-string in +# $3 - name of an array parameter to be the argument to gen-unapplied-string +# $4 - name of a parameter to store the unapplied-string in { local REPLY if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then @@ -17,4 +19,12 @@ fi : ${(P)2::=$REPLY} hook_com=() + + if VCS_INFO_hook 'gen-unapplied-string' "${(@P)3}"; then + REPLY=${(P)#3} + else + REPLY=${hook_com[unapplied-string]} + fi + : ${(P)4::=$REPLY} + hook_com=() } --jRHKVT23PllUwdXP Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0003-vcs_info-set-patch-format-helper-Part-3.patch" >>From ddb58c59a36161fc6b59c33baeea2edbdd620ddc Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 23 Jan 2017 18:15:35 +0000 Subject: [PATCH 3/4] vcs_info set-patch-format helper: Part #3. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 8 ++------ Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 11 ++--------- Functions/VCS_Info/VCS_INFO_quilt | 8 ++------ Functions/VCS_Info/VCS_INFO_set-patch-format | 9 +++++++++ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index e7b9ac4..b44f00c 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -126,13 +126,9 @@ VCS_INFO_git_handle_patches () { (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} )) VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \ - 'git_patches_unapplied' 'git_unapplied_s' + 'git_patches_unapplied' 'git_unapplied_s' \ + ":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg - if (( ${#git_patches_applied} )); then - zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)" - else - zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format gitmsg || gitmsg="no patch applied" - fi hook_com=( applied "${git_applied_s}" unapplied "${git_unapplied_s}" applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} ) if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 90164fb..52effa5 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -204,21 +204,14 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ fi VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \ - 'mqunapplied' 'unapplied_string' + 'mqunapplied' 'unapplied_string' \ + ":vcs_info:${vcs}:${usercontext}:${rrn}" hgmqstring if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then guards_string=${(j:,:)mqguards} else guards_string=${hook_com[guards-string]} fi - if (( ${#mqpatches} )); then - zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format \ - hgmqstring || hgmqstring="%p (%n applied)" - else - zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format \ - hgmqstring || hgmqstring="no patch applied" - fi - hook_com=( applied "${applied_string}" unapplied "${unapplied_string}" applied-n ${#mqpatches} unapplied-n ${#mqunapplied} all-n ${#mqseries} guards "${guards_string}" guards-n ${#mqguards} ) diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 1872fc7..a81da1c 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -174,13 +174,9 @@ function VCS_INFO_quilt() { all=( ${(Oa)applied} ${unapplied} ) VCS_INFO_set-patch-format 'applied' 'applied_string' \ - 'unapplied' 'unapplied_string' + 'unapplied' 'unapplied_string' \ + ${context} qstring - if (( ${#applied} )); then - zstyle -s "${context}" patch-format qstring || qstring="%p (%n applied)" - else - zstyle -s "${context}" nopatch-format qstring || qstring="no patch applied" - fi hook_com=( applied "${applied_string}" unapplied "${unapplied_string}" applied-n ${#applied} unapplied-n ${#unapplied} all-n ${#all} ) if VCS_INFO_hook 'set-patch-format' ${qstring}; then diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index 0bbd474..664b456 100644 --- a/Functions/VCS_Info/VCS_INFO_set-patch-format +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -6,6 +6,8 @@ # $2 - name of a parameter to store the applied-string in # $3 - name of an array parameter to be the argument to gen-unapplied-string # $4 - name of a parameter to store the unapplied-string in +# $5 - context argument for use in zstyle getters +# $6 - name of a parameter to store a patch-format format string in { local REPLY if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then @@ -27,4 +29,11 @@ fi : ${(P)4::=$REPLY} hook_com=() + + if (( ${(P)#1} )); then + zstyle -s "${5}" patch-format REPLY || REPLY="%p (%n applied)" + else + zstyle -s "${5}" nopatch-format REPLY || REPLY="no patch applied" + fi + : ${(P)6::=$REPLY} } --jRHKVT23PllUwdXP Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0004-vcs_info-set-patch-format-helper-Part-4.patch" >>From c6a8845d370658cf4fcf79ab7e40ddf2bbd1b526 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 23 Jan 2017 18:15:35 +0000 Subject: [PATCH 4/4] vcs_info set-patch-format helper: Part #4. This also fixes the %a (${hook_com[all-n]}) expando in the hg backend: before this change, it counted only unapplied changes. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 8 +++----- Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 11 +++-------- Functions/VCS_Info/VCS_INFO_quilt | 9 ++------- Functions/VCS_Info/VCS_INFO_set-patch-format | 12 ++++++++++++ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index b44f00c..c4ae3fa 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -120,20 +120,18 @@ VCS_INFO_git_getbranch () { } VCS_INFO_git_handle_patches () { - local git_applied_s git_unapplied_s gitmsg git_all + local git_applied_s git_unapplied_s gitmsg git_patches_applied=(${(Oa)git_patches_applied}) git_patches_unapplied=(${(Oa)git_patches_unapplied}) - (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} )) VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \ 'git_patches_unapplied' 'git_unapplied_s' \ ":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg - hook_com=( applied "${git_applied_s}" unapplied "${git_unapplied_s}" - applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} ) if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \ - "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" "a:${git_all}" + "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" \ + "a:${hook_com[all-n]}" else gitmisc=${hook_com[patch-replace]} fi diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 52effa5..c99452e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -13,7 +13,7 @@ local hgbase bmfile branchfile rebasefile dirstatefile mqseriesfile \ hgbmstring hgmqstring applied_string unapplied_string guards_string local -a hgid_args defrevformat defbranchformat \ - hgbmarks mqpatches mqseries mqguards mqunapplied hgmisc \ + hgbmarks mqpatches mqguards mqunapplied hgmisc \ i_patchguards i_negguards i_posguards local -A hook_com @@ -175,9 +175,6 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ # Skip commented lines [[ ${i_patch} == [[:space:]]#"#"* ]] && continue - # Keep list of all patches - mqseries+=( $i_patch ) - # Separate negative and positive guards to more easily find the # intersection of active guards with patch guards i_patchguards=( ${(s: :)i_patchguards} ) @@ -212,14 +209,12 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ guards_string=${hook_com[guards-string]} fi - hook_com=( applied "${applied_string}" unapplied "${unapplied_string}" - applied-n ${#mqpatches} unapplied-n ${#mqunapplied} all-n ${#mqseries} - guards "${guards_string}" guards-n ${#mqguards} ) + hook_com+=( guards "${guards_string}" guards-n ${#mqguards} ) if VCS_INFO_hook 'set-patch-format' ${qstring}; then zformat -f hgmqstring "${hgmqstring}" \ "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \ - "n:${#mqpatches}" "c:${#mqunapplied}" "a:${#mqseries}" \ + "n:${#mqpatches}" "c:${#mqunapplied}" "a:${hook_com[all-n]}" \ "g:${hook_com[guards]}" "G:${#mqguards}" else hgmqstring=${hook_com[patch-replace]} diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index a81da1c..aed9f0c 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -91,7 +91,7 @@ function VCS_INFO_quilt() { local patches pc tmp qstring root local -i ret local context - local -a applied unapplied all applied_string unapplied_string quiltcommand quilt_env + local -a applied unapplied applied_string unapplied_string quiltcommand quilt_env local -A hook_com context=":vcs_info:${vcs}.quilt-${mode}:${usercontext}:${rrn}" @@ -171,17 +171,12 @@ function VCS_INFO_quilt() { } fi - all=( ${(Oa)applied} ${unapplied} ) - VCS_INFO_set-patch-format 'applied' 'applied_string' \ 'unapplied' 'unapplied_string' \ ${context} qstring - - hook_com=( applied "${applied_string}" unapplied "${unapplied_string}" - applied-n ${#applied} unapplied-n ${#unapplied} all-n ${#all} ) if VCS_INFO_hook 'set-patch-format' ${qstring}; then zformat -f qstring "${qstring}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \ - "n:${#applied}" "c:${#unapplied}" "a:${#all}" + "n:${#applied}" "c:${#unapplied}" "a:${hook_com[all-n]}" else qstring=${hook_com[patch-replace]} fi diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index 664b456..84febab 100644 --- a/Functions/VCS_Info/VCS_INFO_set-patch-format +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -8,6 +8,10 @@ # $4 - name of a parameter to store the unapplied-string in # $5 - context argument for use in zstyle getters # $6 - name of a parameter to store a patch-format format string in +# +# Output: +# - $hook_com is overwritten and the keys 'applied', 'applied-n', +# 'unapplied', 'unapplied-n', 'all-n' are set. { local REPLY if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then @@ -36,4 +40,12 @@ zstyle -s "${5}" nopatch-format REPLY || REPLY="no patch applied" fi : ${(P)6::=$REPLY} + + hook_com=( + applied-n ${(P)#1} + applied ${(P)2} + unapplied-n ${(P)#3} + unapplied ${(P)4} + ) + hook_com[all-n]=$(( ${hook_com[applied-n]} + ${hook_com[unapplied-n]} )) } --jRHKVT23PllUwdXP--