From 9ce1b6289aebc8e19b8bb25e4f7ac1cbc84e83de Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Sat, 4 Jan 2014 22:06:09 +0100 Subject: [PATCH 1/7] new faster SVN plugin --- .../svn-fast-info/svn-fast-info.plugin.zsh | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/svn-fast-info/svn-fast-info.plugin.zsh diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh new file mode 100644 index 000000000..d8fc53989 --- /dev/null +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -0,0 +1,64 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# Faster alternative to the current SVN plugin implementation. +# +# Works with svn 1.6, 1.7, 1.8. +# Use `svn_prompt_info` method to enquire the svn data. +# It's faster because his efficient use of svn (single svn call) done in the `parse_svn` function +# Also changed prompt suffix *after* the svn dirty marker +# +# *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it. + +function parse_svn() { + info=$(svn info 2> /dev/null) || return + in_svn=true + repo_need_upgrade="$(svn_repo_need_upgrade $info)" + svn_branch_name="$(svn_get_branch_name $info)" + svn_dirty="$(svn_dirty_choose)" + svn_repo_name="$(svn_get_repo_name $info)" + svn_rev="$(svn_get_revision $info)" +} + +function svn_prompt_info() { + eval parse_svn + + if [ ${in_svn} ]; then + echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ +$ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\ +$ZSH_PROMPT_BASE_COLOR${svn_dirty}\ +$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX\ +$ZSH_PROMPT_BASE_COLOR" + fi +} + + +function svn_repo_need_upgrade() { + info=$1 + [ -z "${info}" ] && info=$(svn info 2> /dev/null) + [ "${info}" = "E155036" ] && echo "upgrade repo with svn upgrade" +} + +function svn_get_branch_name() { + info=$1 + [ -z "${info}" ] && info=$(svn info 2> /dev/null) + echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL + echo $SVN_URL +} + +function svn_get_repo_name() { + info=$1 + [ -z "${info}" ] && info=$(svn info 2> /dev/null) + echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT + echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p" +} + +function svn_get_revision() { + info=$1 + [ -z "${info}" ] && info=$(svn info 2> /dev/null) + echo $info 2> /dev/null | sed -n s/Revision:\ //p +} + +function svn_dirty_choose() { + svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return + echo $ZSH_THEME_SVN_PROMPT_CLEAN +} \ No newline at end of file From 1304ed8d2521e452615bcf7563700018443f5470 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Mon, 6 Jan 2014 14:09:40 +0100 Subject: [PATCH 2/7] Report the SVN need upgrade This happen when subversion 1.7+ is used on a repository created with subversion up to 1.6 --- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index d8fc53989..1027bcac2 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -10,7 +10,7 @@ # *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it. function parse_svn() { - info=$(svn info 2> /dev/null) || return + info=$(svn info 2>&1) || return; # capture stdout and stdout in_svn=true repo_need_upgrade="$(svn_repo_need_upgrade $info)" svn_branch_name="$(svn_get_branch_name $info)" @@ -22,7 +22,13 @@ function parse_svn() { function svn_prompt_info() { eval parse_svn - if [ ${in_svn} ]; then + if [ ! -z $repo_need_upgrade ]; then + echo $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX$ZSH_PROMPT_BASE_COLOR\ +$repo_need_upgrade\ +$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR + fi + + if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ $ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\ $ZSH_PROMPT_BASE_COLOR${svn_dirty}\ @@ -34,8 +40,8 @@ $ZSH_PROMPT_BASE_COLOR" function svn_repo_need_upgrade() { info=$1 - [ -z "${info}" ] && info=$(svn info 2> /dev/null) - [ "${info}" = "E155036" ] && echo "upgrade repo with svn upgrade" + [ -z "${info}" ] && info=$(svn info 2>&1) + if grep -q "E155036" <<< $info; then echo "E155036: upgrade repo with svn upgrade"; fi } function svn_get_branch_name() { @@ -61,4 +67,4 @@ function svn_get_revision() { function svn_dirty_choose() { svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return echo $ZSH_THEME_SVN_PROMPT_CLEAN -} \ No newline at end of file +} From 642ae64bc50f93739ca280e8dcb1d6dbb5932f58 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Tue, 7 Jan 2014 02:10:34 +0100 Subject: [PATCH 3/7] Inline `parse_svn` to avoid leaky state As noted in review, `in_svn` is not properly reset to false. This is better anyway to not leak state. --- .../svn-fast-info/svn-fast-info.plugin.zsh | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index 1027bcac2..e75f21599 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -9,18 +9,14 @@ # # *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it. -function parse_svn() { - info=$(svn info 2>&1) || return; # capture stdout and stdout - in_svn=true - repo_need_upgrade="$(svn_repo_need_upgrade $info)" - svn_branch_name="$(svn_get_branch_name $info)" - svn_dirty="$(svn_dirty_choose)" - svn_repo_name="$(svn_get_repo_name $info)" - svn_rev="$(svn_get_revision $info)" -} - function svn_prompt_info() { - eval parse_svn + info=$(svn info 2>&1) || return; # capture stdout and stdout + in_svn=true + repo_need_upgrade="$(svn_repo_need_upgrade $info)" + svn_branch_name="$(svn_get_branch_name $info)" + svn_dirty="$(svn_dirty_choose)" + svn_repo_name="$(svn_get_repo_name $info)" + svn_rev="$(svn_get_revision $info)" if [ ! -z $repo_need_upgrade ]; then echo $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX$ZSH_PROMPT_BASE_COLOR\ @@ -28,13 +24,13 @@ $repo_need_upgrade\ $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR fi - if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then - echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ + if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then + echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ $ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\ $ZSH_PROMPT_BASE_COLOR${svn_dirty}\ $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX\ $ZSH_PROMPT_BASE_COLOR" - fi + fi } @@ -47,24 +43,24 @@ function svn_repo_need_upgrade() { function svn_get_branch_name() { info=$1 [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL - echo $SVN_URL + echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL + echo $SVN_URL } function svn_get_repo_name() { info=$1 [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p" + echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT + echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p" } function svn_get_revision() { info=$1 [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info 2> /dev/null | sed -n s/Revision:\ //p + echo $info 2> /dev/null | sed -n s/Revision:\ //p } function svn_dirty_choose() { - svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return - echo $ZSH_THEME_SVN_PROMPT_CLEAN + svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return + echo $ZSH_THEME_SVN_PROMPT_CLEAN } From 8bf8e1ecf9eeb4117b1196a5fd02d788979f05f7 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 7 Jan 2014 10:07:02 +0100 Subject: [PATCH 4/7] Heavy refactor of svn-fast-info --- .../svn-fast-info/svn-fast-info.plugin.zsh | 88 +++++++++++-------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index e75f21599..2183010ba 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -1,4 +1,4 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 +# vim:ft=zsh ts=2 sw=2 sts=2 et # # Faster alternative to the current SVN plugin implementation. # @@ -10,57 +10,69 @@ # *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it. function svn_prompt_info() { - info=$(svn info 2>&1) || return; # capture stdout and stdout - in_svn=true - repo_need_upgrade="$(svn_repo_need_upgrade $info)" - svn_branch_name="$(svn_get_branch_name $info)" - svn_dirty="$(svn_dirty_choose)" - svn_repo_name="$(svn_get_repo_name $info)" - svn_rev="$(svn_get_revision $info)" + local info + info=$(svn info 2>&1) || return 1; # capture stdout and stderr + local repo_need_upgrade=$(svn_repo_need_upgrade $info) - if [ ! -z $repo_need_upgrade ]; then - echo $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX$ZSH_PROMPT_BASE_COLOR\ -$repo_need_upgrade\ -$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR - fi - - if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then - echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ -$ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\ -$ZSH_PROMPT_BASE_COLOR${svn_dirty}\ -$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX\ -$ZSH_PROMPT_BASE_COLOR" - fi + if [ -n $repo_need_upgrade ]; then + printf '%s%s%s%s%s%s%s\n' \ + $ZSH_PROMPT_BASE_COLOR \ + $ZSH_THEME_SVN_PROMPT_PREFIX \ + $ZSH_PROMPT_BASE_COLOR \ + $repo_need_upgrade \ + $ZSH_PROMPT_BASE_COLOR \ + $ZSH_THEME_SVN_PROMPT_SUFFIX \ + $ZSH_PROMPT_BASE_COLOR \ + else + # something left for you to fix - + # repo name and rev aren't used here, did you forget them? + # especially since you set a repo name color + # if the prompt is alright this way, leave it as is and just + # delete the comment. The functions itself could stay imo, + # gives others the chance to use them. + printf '%s%s%s%s%s%s%s%s%s\n' \ + $ZSH_PROMPT_BASE_COLOR \ + $ZSH_THEME_SVN_PROMPT_PREFIX \ + $ZSH_THEME_REPO_NAME_COLOR \ + $(svn_get_branch_name $info) + ${svn_branch_name}\ + $ZSH_PROMPT_BASE_COLOR + $(svn_dirty_choose $info) + $ZSH_PROMPT_BASE_COLOR + $ZSH_THEME_SVN_PROMPT_SUFFIX\ + $ZSH_PROMPT_BASE_COLOR + fi } - function svn_repo_need_upgrade() { - info=$1 - [ -z "${info}" ] && info=$(svn info 2>&1) - if grep -q "E155036" <<< $info; then echo "E155036: upgrade repo with svn upgrade"; fi + grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \ + echo "E155036: upgrade repo with svn upgrade" } function svn_get_branch_name() { - info=$1 - [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL - echo $SVN_URL + echo ${1:-$(svn info 2> /dev/null)} |\ + grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' |\ + egrep -o '[^/]+$' } function svn_get_repo_name() { - info=$1 - [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p" + # I think this can be further cleaned up as well, not sure how, + # as I can't test it + local svn_root + local info=${1:-$(svn info 2> /dev/null)} + echo $info | sed 's/Repository\ Root:\ .*\///p' | read svn_root + echo $info | sed "s/URL:\ .*$svn_root\///p" } function svn_get_revision() { - info=$1 - [ -z "${info}" ] && info=$(svn info 2> /dev/null) - echo $info 2> /dev/null | sed -n s/Revision:\ //p + # does this work as it should? + echo ${1:-$(svn info 2> /dev/null)} | sed 's/Revision: //p' } function svn_dirty_choose() { - svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return - echo $ZSH_THEME_SVN_PROMPT_CLEAN + if svn status | grep -E '^\s*[ACDIM!?L]' &> /dev/null; then + echo $ZSH_THEME_SVN_PROMPT_DIRTY + else + echo $ZSH_THEME_SVN_PROMPT_CLEAN + fi } From 8ede6c6af3b3f11d9b688e4bf9c97be8a54c6c4d Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Wed, 8 Jan 2014 02:50:58 +0100 Subject: [PATCH 5/7] Added further cleanup and svn status information --- .../svn-fast-info/svn-fast-info.plugin.zsh | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index 2183010ba..2d43d365b 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -14,7 +14,7 @@ function svn_prompt_info() { info=$(svn info 2>&1) || return 1; # capture stdout and stderr local repo_need_upgrade=$(svn_repo_need_upgrade $info) - if [ -n $repo_need_upgrade ]; then + if [[ -n $repo_need_upgrade ]]; then printf '%s%s%s%s%s%s%s\n' \ $ZSH_PROMPT_BASE_COLOR \ $ZSH_THEME_SVN_PROMPT_PREFIX \ @@ -22,57 +22,53 @@ function svn_prompt_info() { $repo_need_upgrade \ $ZSH_PROMPT_BASE_COLOR \ $ZSH_THEME_SVN_PROMPT_SUFFIX \ - $ZSH_PROMPT_BASE_COLOR \ + $ZSH_PROMPT_BASE_COLOR else - # something left for you to fix - - # repo name and rev aren't used here, did you forget them? - # especially since you set a repo name color - # if the prompt is alright this way, leave it as is and just - # delete the comment. The functions itself could stay imo, - # gives others the chance to use them. - printf '%s%s%s%s%s%s%s%s%s\n' \ + printf '%s%s%s %s%s:%s%s%s%s%s' \ $ZSH_PROMPT_BASE_COLOR \ $ZSH_THEME_SVN_PROMPT_PREFIX \ - $ZSH_THEME_REPO_NAME_COLOR \ - $(svn_get_branch_name $info) - ${svn_branch_name}\ - $ZSH_PROMPT_BASE_COLOR - $(svn_dirty_choose $info) - $ZSH_PROMPT_BASE_COLOR - $ZSH_THEME_SVN_PROMPT_SUFFIX\ + \ + "$(svn_status_info $info)" \ + $ZSH_PROMPT_BASE_COLOR \ + \ + $ZSH_THEME_BRANCH_NAME_COLOR \ + $(svn_get_branch_name $info) \ + $ZSH_PROMPT_BASE_COLOR \ + \ + $(svn_get_revision $info) \ + $ZSH_PROMPT_BASE_COLOR \ + \ + $ZSH_THEME_SVN_PROMPT_SUFFIX \ $ZSH_PROMPT_BASE_COLOR fi } + function svn_repo_need_upgrade() { grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \ echo "E155036: upgrade repo with svn upgrade" } function svn_get_branch_name() { - echo ${1:-$(svn info 2> /dev/null)} |\ - grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' |\ - egrep -o '[^/]+$' + grep '^URL:' <<< "${1:-$(svn info 2> /dev/null)}" | egrep -o '(tags|branches)/[^/]+|trunk' } -function svn_get_repo_name() { - # I think this can be further cleaned up as well, not sure how, - # as I can't test it - local svn_root - local info=${1:-$(svn info 2> /dev/null)} - echo $info | sed 's/Repository\ Root:\ .*\///p' | read svn_root - echo $info | sed "s/URL:\ .*$svn_root\///p" +function svn_get_repo_root_name() { + grep '^Repository\ Root:' <<< "${1:-$(svn info 2> /dev/null)}" | sed 's#.*/##' } function svn_get_revision() { - # does this work as it should? - echo ${1:-$(svn info 2> /dev/null)} | sed 's/Revision: //p' + echo "${1:-$(svn info 2> /dev/null)}" | sed -n 's/Revision: //p' } -function svn_dirty_choose() { - if svn status | grep -E '^\s*[ACDIM!?L]' &> /dev/null; then - echo $ZSH_THEME_SVN_PROMPT_DIRTY - else - echo $ZSH_THEME_SVN_PROMPT_CLEAN - fi +function svn_status_info() { + local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" + local svn_status="$(svn status 2> /dev/null)"; + if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi + if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi + if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi + if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi + if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi + if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi + echo $svn_status_string } From f66ab7f98f9be0486b3a55858d9466232fc97ef6 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Wed, 8 Jan 2014 03:04:54 +0100 Subject: [PATCH 6/7] Renamed the methods of this script --- .../svn-fast-info/svn-fast-info.plugin.zsh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index 2d43d365b..a12007ec6 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -4,12 +4,10 @@ # # Works with svn 1.6, 1.7, 1.8. # Use `svn_prompt_info` method to enquire the svn data. -# It's faster because his efficient use of svn (single svn call) done in the `parse_svn` function -# Also changed prompt suffix *after* the svn dirty marker -# -# *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it. +# It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase +# It displays the current status of the local files (added, deleted, modified, replaced, or else...) -function svn_prompt_info() { +function svn_fast_info() { local info info=$(svn info 2>&1) || return 1; # capture stdout and stderr local repo_need_upgrade=$(svn_repo_need_upgrade $info) @@ -32,10 +30,10 @@ function svn_prompt_info() { $ZSH_PROMPT_BASE_COLOR \ \ $ZSH_THEME_BRANCH_NAME_COLOR \ - $(svn_get_branch_name $info) \ + $(svn_current_branch_name $info) \ $ZSH_PROMPT_BASE_COLOR \ \ - $(svn_get_revision $info) \ + $(svn_current_revision $info) \ $ZSH_PROMPT_BASE_COLOR \ \ $ZSH_THEME_SVN_PROMPT_SUFFIX \ @@ -43,21 +41,20 @@ function svn_prompt_info() { fi } - function svn_repo_need_upgrade() { grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \ echo "E155036: upgrade repo with svn upgrade" } -function svn_get_branch_name() { +function svn_current_branch_name() { grep '^URL:' <<< "${1:-$(svn info 2> /dev/null)}" | egrep -o '(tags|branches)/[^/]+|trunk' } -function svn_get_repo_root_name() { +function svn_repo_root_name() { grep '^Repository\ Root:' <<< "${1:-$(svn info 2> /dev/null)}" | sed 's#.*/##' } -function svn_get_revision() { +function svn_current_revision() { echo "${1:-$(svn info 2> /dev/null)}" | sed -n 's/Revision: //p' } From ca129bb55085cf93510346dcd70b1190b87d5bc0 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Fri, 10 Jan 2014 14:03:10 +0100 Subject: [PATCH 7/7] Renames main plugin function to `svn_prompt_info` --- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index a12007ec6..ea19bcea0 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -6,8 +6,10 @@ # Use `svn_prompt_info` method to enquire the svn data. # It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase # It displays the current status of the local files (added, deleted, modified, replaced, or else...) +# +# Use as a drop-in replacement of the svn plugin not as complementary plugin -function svn_fast_info() { +function svn_prompt_info() { local info info=$(svn info 2>&1) || return 1; # capture stdout and stderr local repo_need_upgrade=$(svn_repo_need_upgrade $info)