Reputation: 54223
I'm new to bazaar, but very familiar with Git. I'm trying to understand the basics.
Suppose I have a branch whose history looks like this:
* 3 bar
|
* 2 foo
|
* 1 initial commit
I have a series of patches that I want to turn into commits, but they're based on an old revision. I want to create the commits off of the old revision and then merge the results back in. The resulting graph should look like this:
* 4 merge
|\
| * 2.1.3 apply patch #3
| |
| * 2.1.2 apply patch #2
| |
| * 2.1.1 apply patch #1
| |
* | 3 bar
|/
* 2 foo
|
* 1 initial commit
How do I do this with bzr
?
With Git, I'd do something like this:
git checkout -b import-patches master^
for p in 1 2 3; do
git apply --index /path/to/"${p}".patch
git commit -m "apply patch #${p}"
done
git checkout master
git merge import-patches
git branch -d import-patches
Upvotes: 2
Views: 67
Reputation: 8730
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.
Upvotes: 2