Almost three years ago, I published a bash wrapper function for the
svn command on this blog. This shell function allows to use external tools when calling
svn diff, for example
colordiff, Apple’s FileMerge on OS X or vimdiff.
Sometimes I was a bit frustrated that bzr does not support hunk splitting during selection changes with
bzr shelve, as does
git commit --interactive. Now with bzr 2.1.0 there is a new option available to launch an external editor to shelve changes as you like.
Just add the option
change_editor to your ~/.bazaar/bazaar.conf in the
change_editor = vimdiff -f @new_path @old_path
Alternatively, you can of course use
kdiff3 as well as
change_editor, which will be a lot easier to use for beginners.
The placeholder @new_path will automatically be replaced with the path of the new version and @old_path with the path of the old version. With this configuration, there will be a new choice “
e” during shelve:
e” will start vimdiff in a two column view with the new version to the left and the old version to the right. You should read
:help diff in vim to get more information about this mode. Basically you can obtain changes from the other buffer using
do (“diff obtain”) and put changes to the other buffer using
dp (“diff put”). Note that the old version on the right will be read-only and you are not supposed to change it. Also do not make unrelated changes or introduce new differences as that will result in conflicts on
bzr unshelve later.
When you are fine with the changes exit the editor with
:wqa. After confirming the shelve once more, you will see the left file as the new version in the working tree and every difference to the right file will be shelved.
Unfortunately this is not yet documented in bzr itself at the time of this writing.