Create patches for upstream with bzr

I searched a long time for a nice way to create clean diffs between two bzr branches. The command bzr diff remote-branch is not working ... Now I found a solution using a special revision identifier.

I found by accident in the bzr docs a page about some special revision identifiers. One of them is the branch: prefix which can be used to reference a remote branch.

With this knowledge its easy to create a diff between two bzr branches:

bzr diff -r branch:/path/to/remote-branch

You can also use instead of branch: the submit: identifier which only provides the diff back to the last common revision. This is exactly the behaviour you want to have for creating patches. You can also leave the argument for submit: blank and it will use the parent branch (the branch where you branched from) by default.

Here are now the steps I use when I want to provided a bug fix for an upstream project:

  • Branch the project's repository from launchpad (if the project is not available, I register it and import the upstream repository)
  • Then I branch the local copy of trunk to have a checkout dedicated for fixing the bug.
  • Hacking.
  • Run bzr diff -r submit: > ../bugfix.patch
  • Submit the patch to the developers.

Until today I was really disappointed by bzr for not having this feature. I was quite sure it MUST be there … but haven't found it. Ofcourse I know the bundle command etc. but this would create a merge directive which looks a bit like a patch but is actually only usefull if the upstream project also uses bzr.

Maybe this blog post helps someone else saving some time looking for this feature.


Comments

blog comments powered by Disqus