svnsafeup: improve presentation (fold-indent).

Use indent folding: indent lines instead of adding fold markers. This
fixes display of large Javascript blobs which might contain a closing
fold marker. It looks probably better with folding enabled, too.

Then, pass '-c "set ..."' to `view` (assuming it's linked to `vim`),
instead of using a modeline. The latter will be disabled for root, at
least by default.
This commit is contained in:
Daniel Hahler 2011-04-12 21:51:18 +02:00
commit b959922708

View file

@ -42,8 +42,8 @@ function svn_dirty {
} }
# Function to update an SVN repository in a safe manner: first display # Function to update an SVN repository in a safe manner: first display
# diffstat (if installed), log and diff, then ask about continuing with # diffstat (if installed), log and diff (folded), then ask about continuing
# `svn up`. # with `svn up`.
# Optional args: $to $from (default: HEAD BASE) # Optional args: $to $from (default: HEAD BASE)
function svnsafeup() { function svnsafeup() {
if [[ "$(in_svn)" != "1" ]]; then if [[ "$(in_svn)" != "1" ]]; then
@ -51,7 +51,6 @@ function svnsafeup() {
fi fi
local from=${2:-BASE} to=${1:-HEAD} local from=${2:-BASE} to=${1:-HEAD}
local range="$from:$to" local range="$from:$to"
local marker_o='{{{' marker_c="}}}\n" # fold markers
local repo_id="$(svn_get_repo_name)@$(svn_get_rev_nr)" local repo_id="$(svn_get_repo_name)@$(svn_get_rev_nr)"
local diffcmd="svn diff -r $range" local diffcmd="svn diff -r $range"
@ -68,19 +67,13 @@ function svnsafeup() {
diffstat=$(echo $diff | diffstat) diffstat=$(echo $diff | diffstat)
echo -n "diffstat: " echo -n "diffstat: "
echo $diffstat | tail -n1 echo $diffstat | tail -n1
echo $marker_o echo $diffstat | sed 's/^/ /'
echo $diffstat
echo $marker_c
fi fi
echo "svn log -r $range: $marker_o" echo "svn log -r $range:"
svn log -r $range svn log -r $range | sed 's/^/ /'
echo "$marker_c" echo "$diffcmd:"
echo "$diffcmd: $marker_o" echo $diff | sed 's/^/ /' | sed '/^ Index: / !s/^/ /'
echo $diff | sed "s/^Index: .*/\0 ${marker_o}2/" } | view -c 'set foldnestmax=2 foldlevel=0 shiftwidth=2 foldmethod=indent' -
echo "${marker_c}2"
# add modeline for vim
echo " vim:fdm=marker:fdl=1:"
} | view -
read "answer?continue to 'svn up'? (ctrl-c to abort, y to continue) " || return 1 read "answer?continue to 'svn up'? (ctrl-c to abort, y to continue) " || return 1
[[ $answer == "y" ]] || return 1 [[ $answer == "y" ]] || return 1
svn up -r $to svn up -r $to