Unlike Git, Bzr has a model of using one working directory per branch instead of using one working directory per repository (unless you use co-located branches). The basic workflow for your example is roughly the same:
First, branch off the current branch to a new directory ../import-patches
. You can use negative revision numbers or the last:n
notation to refer to revisions starting from the head of a branch (or use the revision number directly):
bzr branch . ../import-patches -r last:2
Then, go to the new branch directory and apply your patches (bzr patch may need the -p/--strip
option):
pushd ../import-patches
for p in 1 2 3; do
bzr patch /path/to/"${p}".patch
bzr commit -m "apply patch #${p}"
done
Now, go back to your original branch directory and merge. You'll need to commit the merge in a separate step:
popd
bzr merge ../import-patches
bzr commit
Note that each branch will have a standalone repository, unless you setup a shared repository with bzr init-repo
. A shared repository is just a directory with revision data stored in its .bzr
subdirectory and other subdirectories containing individual branches (including nested subdirectories); those branches will store all common revisions in the shared repository. If you are familiar with git-new-workdir
, this is similar to the main repository being a Git repository without a working tree, and each subdirectory being a working tree initialized with git-new-workdir
and associated with a separate branch.
Co-located branches allow you to have multiple branches in the same directory; this requires the colo
plugin for Bzr 2.5.x; co-located branches are supposed to be a core feature for 2.6, but may not be fully stable yet.