Search code examples
linuxsvnvimversionvi

SVN - Commit via VIM - Recover failed commit message


I typically use VIM for almost everything coding-related.

I have configured my environment so Subversion opens VIM to edit the commit message when I execute svn commit. If I close VIM without saving the commit message (eg: :qa!), it is discarded, and the commit operation is aborted.

If I save and close VIM, then the commit operation will commence.

If the commit fails, I have some SVN commit messages that appear to be saved in /tmp/ with file names like svn-**.tmp.

While writing the commit message in VIM, the commit message appears to have a file name of svn-commit.1.tmp. I would like to be able to recover this message for my next SVN commit. The typically use case is:

  1. I attempt to commit; complete writing message in VIM
  2. Commit fails
  3. I resolve the issue (eg: svn update)
  4. Now I want to attempt svn commit again with the previous message pre-loaded into VIM

Thank you for your help.


Solution

  • You could always use the -F option with svn commit, which uses a file to create the log message.

    Whenever I commit with svn, I first create a log file:

    vim log_file
    

    Then I use the following to commit:

    svn commit -F log_file --username blah
    

    This has always worked great for me.