mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Add svnsafeup function to svn plugin.
This provides a useful method to update some SVN repository in a "safely" manner.
This commit is contained in:
parent
52df85440e
commit
cef8ea75a9
1 changed files with 42 additions and 1 deletions
|
|
@ -39,4 +39,45 @@ function svn_dirty_choose {
|
|||
|
||||
function svn_dirty {
|
||||
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
|
||||
}
|
||||
}
|
||||
|
||||
# Function to update an SVN repository in a safe manner: first display
|
||||
# diffstat (if installed), log and diff, then ask about continuing with
|
||||
# `svn up`.
|
||||
# Optional args: $to $from (default: HEAD BASE)
|
||||
function svnsafeup() {
|
||||
if [[ "$(in_svn)" != "1" ]]; then
|
||||
echo "Not in a SVN repository." 1>&2 ; return 1
|
||||
fi
|
||||
local from=${2:-BASE} to=${1:-HEAD}
|
||||
local range="$from:$to"
|
||||
local marker_o='{{{' marker_c="}}}\n\n" # fold markers
|
||||
local repo_id="$(svn_get_repo_name)@$(svn_get_rev_nr)"
|
||||
local diffcmd="svn diff -r $range"
|
||||
|
||||
local diff=$($=diffcmd)
|
||||
if [[ $diff == '' ]] ; then
|
||||
echo "No changes for $repo_id in range $range."
|
||||
return
|
||||
fi
|
||||
|
||||
{
|
||||
echo "Diff for: $repo_id, range: $range"
|
||||
echo
|
||||
if [ $commands[diffstat] ] ; then
|
||||
echo "$diffcmd | diffstat: $marker_o"
|
||||
echo $diff | diffstat
|
||||
echo "$marker_c"
|
||||
fi
|
||||
echo "svn log -r $range: $marker_o"
|
||||
svn log -r $range
|
||||
echo "$marker_c"
|
||||
echo "$diffcmd: $marker_o"
|
||||
echo $diff
|
||||
echo "$marker_c"
|
||||
# add modeline for vim
|
||||
echo " vim:fdm=marker:fdl=1:"
|
||||
} | view -
|
||||
read "?continue to 'svn up'? (ctrl-c to abort)" || return 1
|
||||
svn up -r $to
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue