bzr init-repo
creates a so-called shared repository. In a shared repository, all revisions are stored inside the .bzr
directory of the repository, and the .bzr
directories of the branches themselves store only branch meta information, not the the revisions themselves. This way the branch directories become very light-weight, and the common revisions of branches are not duplicated.
Let's say we created a shared repository and branches inside it like this:
bzr init-repo the-project # create shared repo
bzr init the-project/trunk # create a branch inside shared repo
cd the-project/trunk # cd to branch dir
cp -r /path/to/files/* . # copy the project's files into the branch
bzr add # tell bazaar to add everything to version control
bzr commit -m 'added files' # commit the changes (add files)
bzr branch . ../branch1 # create another branch from the current one
bzr branch . ../branch2 # create another branch from the current one
Then the directories of the layout will function like this:
the-project/.bzr -- only revisions are stored here, no branch info
the-project/trunk/.bzr -- only branch info is stored here, no revisions
the-project/branch1/.bzr -- only branch info is stored here, no revisions
the-project/branch2/.bzr -- only branch info is stored here, no revisions
If you were not using a shared repository the situation would be very different, for example:
bzr init trunk # create a repo
cd trunk # cd to repo dir
cp -r /path/to/files/* . # copy the project's files into the repo
bzr add # tell bazaar to add everything to version control
bzr commit -m 'added files' # commit the changes (add files)
bzr branch . ../branch1 # create another repo from the current one
bzr branch . ../branch2 # create another repo from the current one
In this case (no shared repo) the directories of the layout will function like this:
trunk/.bzr -- revisions + branch info are stored here
branch1/.bzr -- revisions + branch info are stored here
branch2/.bzr -- revisions + branch info are stored here
In this case the revisions will be duplicated in all 3 branches.
bzr pull
is useful if the current branch is some revisions behind the other branch, so that the missing revisions can be appended in a straightforward way. If the current branch has some revisions that the other doesn't, then the pull fails as in your example. This is perfectly normal, and the solution in such situation is to do a normal merge with bzr merge
.
bzr merge
fails in your example because the two branches (trunk and the other branch) have no common revisions. This is because at the time you branched from trunk, it was completely empty, no revisions were committed to it. The two branches are completely independent, have absolutely no common revisions.
It is still possible to combine unrelated branches as @bialix explained in a comment with bzr merge ../../trunk -r0..-1
but I don't think this was your intention. It is pointless to branch from a trunk that has no revisions, in a realistic use case you would branch from a branch that has at least 1 revisions, in which case you will not get such error and the merge will work as expected.