How to apply (export/import) a patch in BitKeeper

Let's say you need to backport a fix from one BitKeeper repository to another. Here's one way to do it. I suppose there are other or better ways to apply a patch, especially if you have a lot of changesets to backport. But if you're limited to a few changesetd, this seems to work for me.

The following documentation is useful :

1. Create personal clone of target repository :

$ pwd
$ mkdir target
$ cd target
$ bk clone /share/source/code code

2. Identify and create patch from source repository

$ cd /source/code
$ bk changes -uyour_user_name

ChangeSet@1.6813.1.10, 2009-10-23 16:53:29-07:00, me@localhost +3 -0
  Fix the foobar.
(My change set is 1.6813.1.10)

3. Export (create) patch from source repo and then import into your target repo :

$ mkdir /tmp/dkl

$ bk export -tpatch -r1.6813.1.10 > /tmp/dkl/bk.patch  (export from source repo)

$ less /tmp/dkl/bk.patch   (examine diff file)

$ cd /usr/me/target/code

$ bk import -tpatch /tmp/dkl/bk.patch .
Patching file foo.php
Patching file bar.php
Checking for potential renames in /usr/me/target/code ...
Checking in new or modified files in /usr/me/target/code ...
Creating changeset for bk-ssd.patch in /usr/me/target/code ...
ChangeSet revision 1.6751: +3 -0 = 12471

$ bk revtool (to see how patch applied - select your new changeset (1.6751) and hit "View Changeset" in revtool to see diffs)