mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
45626: vcs_info: Deduplicate calling the set-branch-format hook.
This commit is contained in:
parent
b0d020408a
commit
cb87816b0f
7 changed files with 39 additions and 33 deletions
|
@ -1,5 +1,13 @@
|
|||
2020-03-26 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 45626: Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr,
|
||||
Functions/VCS_Info/Backends/VCS_INFO_get_data_p4,
|
||||
Functions/VCS_Info/Backends/VCS_INFO_get_data_svk,
|
||||
Functions/VCS_Info/Backends/VCS_INFO_get_data_svn,
|
||||
Functions/VCS_Info/VCS_INFO_set-branch-format,
|
||||
Functions/VCS_Info/vcs_info: vcs_info: Deduplicate calling the
|
||||
set-branch-format hook.
|
||||
|
||||
* 45624: Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil,
|
||||
Functions/VCS_Info/Backends/VCS_INFO_get_data_p4,
|
||||
Functions/VCS_Info/VCS_INFO_bydir_detect: vcs_info: Set $rrn
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
22
Functions/VCS_Info/VCS_INFO_set-branch-format
Normal file
22
Functions/VCS_Info/VCS_INFO_set-branch-format
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue