zsh-workers
 help / color / Atom feed
* [PATCH 1/3] vcs_info: Set $rrn in all backends.
@ 2020-03-26  1:32 Daniel Shahaf
  2020-03-26  1:32 ` [PATCH 2/3] vcs_info: Deduplicate calling the set-branch-format hook Daniel Shahaf
  2020-03-26  1:32 ` [PATCH 3/3] vcs_info svn: Detect the "working copy format is too new" error Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-26  1:32 UTC (permalink / raw)
  To: zsh-workers

---
Untested.

 Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil | 1 +
 Functions/VCS_Info/Backends/VCS_INFO_get_data_p4     | 1 +
 Functions/VCS_Info/VCS_INFO_bydir_detect             | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil
index fd0f8389e..e84b3abc0 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil
@@ -20,5 +20,6 @@ if [ -n "$merging" ]; then
    action="merging"
 fi
 
+rrn=${fsinfo[local_root]:t}
 VCS_INFO_formats "$action" "${fsbranch}" "${fsinfo[local_root]}" '' "$changed" "${fshash}" "${fsinfo[repository]}"
 return 0
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
index 329884982..815924c26 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
@@ -17,6 +17,7 @@ local p4branch change
 # here down is synced as the revision.
 # I suppose the following might be slow on a tortuous client view.
 change="${${$(${vcs_comm[cmd]} changes -m 1 ...\#have)##Change }%% *}"
+rrn=${p4base:t}
 zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat p4branch || p4branch="%b:%r"
 hook_com=( branch "${p4info[Client_name]}" revision "${change}" )
 if VCS_INFO_hook 'set-branch-format' "${p4branch}"; then
diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index 29b261413..89b4d6503 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -36,4 +36,6 @@ done
 
 [[ ${basedir} == "/" ]] && return 1
 vcs_comm[basedir]=${basedir}
+# TODO: Would the following be correct? ---
+# rrn=${vcs_comm[basedir]:t}
 return 0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] vcs_info: Deduplicate calling the set-branch-format hook.
  2020-03-26  1:32 [PATCH 1/3] vcs_info: Set $rrn in all backends Daniel Shahaf
@ 2020-03-26  1:32 ` Daniel Shahaf
  2020-03-26  1:32 ` [PATCH 3/3] vcs_info svn: Detect the "working copy format is too new" error Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-26  1:32 UTC (permalink / raw)
  To: zsh-workers

---
svk and p4 are untested.

 .../VCS_Info/Backends/VCS_INFO_get_data_bzr   | 11 ++--------
 .../VCS_Info/Backends/VCS_INFO_get_data_p4    | 10 ++-------
 .../VCS_Info/Backends/VCS_INFO_get_data_svk   | 10 ++-------
 .../VCS_Info/Backends/VCS_INFO_get_data_svn   | 10 ++-------
 Functions/VCS_Info/VCS_INFO_set-branch-format | 22 +++++++++++++++++++
 Functions/VCS_Info/vcs_info                   |  1 +
 6 files changed, 31 insertions(+), 33 deletions(-)
 create mode 100644 Functions/VCS_Info/VCS_INFO_set-branch-format

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
index b30e0e12b..f1f5527e8 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
@@ -100,14 +100,7 @@ else
 fi
 
 rrn=${bzrbase:t}
-zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r"
-hook_com=( branch "${bzrinfo[2]}" revision "${bzrinfo[1]}" )
-if VCS_INFO_hook 'set-branch-format' "${bzrbr}"; then
-    zformat -f bzrbr "${bzrbr}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
-else
-    bzrbr=${hook_com[branch-replace]}
-fi
-hook_com=()
-
+VCS_INFO_set-branch-format "${bzrinfo[2]}" "${bzrinfo[1]}" &&
+    bzrbr="${REPLY}"
 VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' "${bzr_changes}" "${bzrinfo[1]}" "${bzr_changes}"
 return 0
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
index 815924c26..e8a08a663 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
@@ -18,13 +18,7 @@ local p4branch change
 # I suppose the following might be slow on a tortuous client view.
 change="${${$(${vcs_comm[cmd]} changes -m 1 ...\#have)##Change }%% *}"
 rrn=${p4base:t}
-zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat p4branch || p4branch="%b:%r"
-hook_com=( branch "${p4info[Client_name]}" revision "${change}" )
-if VCS_INFO_hook 'set-branch-format' "${p4branch}"; then
-    zformat -f p4branch "${p4branch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
-else
-    p4branch=${hook_com[branch-replace]}
-fi
-hook_com=()
+VCS_INFO_set-branch-format "${p4info[Client_name]}" "${change}" &&
+    p4branch="${REPLY}"
 VCS_INFO_formats '' "${p4branch}" "${p4base}" '' '' "$change" ''
 return 0
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk
index 1d2d22ffb..149e30222 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk
@@ -8,13 +8,7 @@ local -A hook_com
 
 svkbase=${vcs_comm[basedir]}
 rrn=${svkbase:t}
-zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svkbranch || svkbranch="%b:%r"
-hook_com=( branch "${vcs_comm[branch]}" revision "${vcs_comm[revision]}" )
-if VCS_INFO_hook 'set-branch-format' "${svkbranch}"; then
-    zformat -f svkbranch "${svkbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
-else
-    svkbranch=${hook_com[branch-replace]}
-fi
-hook_com=()
+VCS_INFO_set-branch-format "${vcs_comm[branch]}" "${vcs_comm[revision]}" &&
+    svkbranch="${REPLY}"
 VCS_INFO_formats '' "${svkbranch}" "${svkbase}" '' '' "${vcs_comm[revision]}" ''
 return 0
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index 21590addd..6fbd673a7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -60,13 +60,7 @@ else
 fi
 
 rrn=${svnbase:t}
-zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
-hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
-if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then
-    zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
-else
-    svnbranch=${hook_com[branch-replace]}
-fi
-hook_com=()
+VCS_INFO_set-branch-format "${svninfo[URL]##*/}" "${cwdinfo[Revision]}" &&
+    svnbranch="${REPLY}"
 VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${cwdinfo[Revision]}" ''
 return 0
diff --git a/Functions/VCS_Info/VCS_INFO_set-branch-format b/Functions/VCS_Info/VCS_INFO_set-branch-format
new file mode 100644
index 000000000..8cff51b9a
--- /dev/null
+++ b/Functions/VCS_Info/VCS_INFO_set-branch-format
@@ -0,0 +1,22 @@
+# A function for calling the branch-format hook
+#
+# Return the value to use in REPLY
+#
+# Parameters:
+readonly branch=$1
+readonly revision=$2
+#
+
+[[ -n $rrn ]] || return 1
+local -A hook_com
+local branchformat
+
+zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat branchformat || branchformat="%b:%r"
+hook_com=( branch "${branch}" revision "${revision}" )
+if VCS_INFO_hook 'set-branch-format' "${branchformat}"; then
+    zformat -f REPLY "${branchformat}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+else
+    REPLY=${hook_com[branch-replace]}
+fi
+hook_com=()
+return 0
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index 9f48bee75..786b61918 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -22,6 +22,7 @@ static_functions=(
     VCS_INFO_hexdump
     VCS_INFO_hook
     VCS_INFO_set-patch-format
+    VCS_INFO_set-branch-format
     VCS_INFO_maxexports
     VCS_INFO_nvcsformats
     VCS_INFO_patch2subject

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] vcs_info svn: Detect the "working copy format is too new" error.
  2020-03-26  1:32 [PATCH 1/3] vcs_info: Set $rrn in all backends Daniel Shahaf
  2020-03-26  1:32 ` [PATCH 2/3] vcs_info: Deduplicate calling the set-branch-format hook Daniel Shahaf
@ 2020-03-26  1:32 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-26  1:32 UTC (permalink / raw)
  To: zsh-workers

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index 6fbd673a7..786a74dcf 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -10,6 +10,7 @@ local -i rc
 local -A svninfo parentinfo cwdinfo
 local -A hook_com
 integer -r SVN_ERR_WC_UPGRADE_REQUIRED=155036 # from /usr/local/include/subversion-1/svn_error_codes.h
+integer -r SVN_ERR_WC_UNSUPPORTED_FORMAT=155021
 
 svnbase=".";
 svninfo=()
@@ -22,8 +23,15 @@ rc=$?
 if (( rc != 0 )) ; then
   if (( rc == 1 )) && [[ -n ${(M)dat:#"svn: E${SVN_ERR_WC_UPGRADE_REQUIRED}: "*} ]]; then
     hook_com=()
-    VCS_INFO_formats '' '?' '?' '' '' '?' 'upgrade required'
+    # User should run 'svn upgrade'
+    VCS_INFO_formats '' '?' '?' '' '' '?' 'working copy upgrade required'
     return $?
+  elif (( rc == 1 )) && [[ -n ${(M)dat:#"svn: E${SVN_ERR_WC_UNSUPPORTED_FORMAT}: "*} ]]; then
+    hook_com=()
+    # User probably needs to install a newer svn, but we're not sure, so point
+    # the user to svn's error message.
+    VCS_INFO_formats '' '?' '?' '' '' '?' 'svn error'
+    return $?
   else
     return 1
   fi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26  1:32 [PATCH 1/3] vcs_info: Set $rrn in all backends Daniel Shahaf
2020-03-26  1:32 ` [PATCH 2/3] vcs_info: Deduplicate calling the set-branch-format hook Daniel Shahaf
2020-03-26  1:32 ` [PATCH 3/3] vcs_info svn: Detect the "working copy format is too new" error Daniel Shahaf

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git