summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2017-01-23 18:15:35 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2017-01-25 04:22:32 +0000
commit2854a67e09748a2e6f4e1d8a73bc463bad4cbd4e (patch)
tree6f656b8bb66efa00fe635515f5b98bc5149bd40a /Functions
parentedd9798de765049a904e0afa830b191d1932087d (diff)
downloadzsh-2854a67e09748a2e6f4e1d8a73bc463bad4cbd4e.tar.gz
zsh-2854a67e09748a2e6f4e1d8a73bc463bad4cbd4e.tar.xz
zsh-2854a67e09748a2e6f4e1d8a73bc463bad4cbd4e.zip
40403/0004: 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.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git8
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_hg11
-rw-r--r--Functions/VCS_Info/VCS_INFO_quilt9
-rw-r--r--Functions/VCS_Info/VCS_INFO_set-patch-format12
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 4d251497c..9a46c4eb7 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 52effa508..c99452e83 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 a81da1c49..aed9f0c33 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 664b4563d..84febabd9 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]} ))
 }