Posts about vim

svn-commit

Hate it when you write a big long commit message in subversion, and then the commit fails for some reason and you have to commit again?

Tired of reading in the aborted commit log message into new commit log?

Can't remember what subversion calls the aborted log messages?

Me too.

So I wrote this little plugin for vim that will look in the current directory for any aborted subversion commit logs. It will pick the newest one, and read that in. Just put this script into ~/.vim/ftplugin and name it something starting with "svn" and you should be good to go!

" SVN aborted commit log reader

" Reads in the newest svn-commit.tmp log in the current directory

" (these get left behind by aborted commits)

"

" Written by Chris AtLee

" Released under the GPLv2

" Version 0.2

function s:ReadPrevCommitLog() " Get the newest file (ignoring this one) let commitfile = system("ls -t svn-commit.tmp | grep -v " . bufname("%") . " | head -1") " Strip off trailing newline let commitfile = substitute(commitfile, "\s\n$", "", "") " If we're left with a file that actually exists, then we can read it in if filereadable(commitfile) " Read in the old commit message "echo "Reading " . commitfile silent exe "0read " . commitfile

    " Delete everything from the first "^--This line" to the last one
    normal 1G
    let first = search("^--This line", "")
    normal G$
    let last = search("^--This line", "b") - 1

    if last > first
        silent exe first . "," . last . "d"
    endif
    normal 1G
    set modified
endif

endf

call s:ReadPrevCommitLog()