Using Emacs ediff as a Bazaar change editor

Vincent Ladeuil vila+bzr at
Thu Jun 7 07:40:42 UTC 2012

>>>>> Ben Finney <ben+bazaar at> writes:

    > Howdy all,
    > I tend to use Bazaar from the command line, in a GNU Screen session,
    > usually without X access from that session. In another GNU Screen window
    > in the same session, I use Emacs as the editor, and enjoy its ‘ediff’
    > mode.

    > With recent talk about using an editor for resolving changes in Bazaar,
    > I'd like to know:

    > * What different Bazaar operations benefit from a change editor?
    >   Resolving merge conflicts; selecting hunks to shelve; viewing diffs;
    >   anything else?

I personally use a combination of dvc, diff-mode and smerge-mode to
*complement* bzr. On top of the features you mention above, I use the
diff-mode ability to go from the diff buffer to the file itself
respecting the cursor position. diff-mode also provides the ability to
apply, unapply or split a hunk.

I sometimes avoid using shelve by saving the diff buffer as a patch file,
unapply some hunks, commit, re-apply some hunks from the saved patch.

I also sometimes 'M-x cd' inside the diff buffer to apply one or several
hunks to a different working tree (working around the fact that a shelf
is tight to a given working tree).

    > * How can I best invoke (text-mode) ediff as a Bazaar change editor
    >   command? <URL:> discusses many
    >   variations of this, but I am hoping this is a solved problem in the
    >   Bazaar context.

Generally, I either split the hunks from the diff-mode buffer or I use
'bzr shelve' but I never mixed both.

The right configuration for emacs is probably something like:

  change_editor="""emacs --eval '(ediff "@old_path" "@new_path")'"""

in bazaar.conf (beware of quoting issues ;-/)

    > * Which ediff invocation is appropriate to each of the corresponding
    >   Bazaar operations above? I think ‘ediff’ would be best for viewing
    >   diffs,

I use dvc to build a diff buffer containing the result of either 'bzr
diff' or 'bzr diff -rsubmit:'. This covers my needs.

    > but ‘ediff-merge-files-with-ancestor’ for resolving conflicts, for
    > example.

smerge-mode is called automatically when you open a conflicted file and
'bzr resolve' is called when you save it.

There are shortcuts to navigate from one conflict to the other, select
which hunk you want to keep (including both versions and any added


More information about the bazaar mailing list