Integrate the content of a branch into the trunk
Neil Martinsen-Burrell
nmb at wartburg.edu
Mon Jun 8 21:06:12 BST 2009
On 2009-06-08 09:40 , Adrián Ribao Martínez wrote:
> I've created a branch of the trunk a few days ago, Now I want to send
> the content of the new branch to the trunk. I think this is done with
> the send command, but I'm not sure, and I don't know the best way of
> doing it. I'd appreciate some help here.
Welcome to the world of distributed VCS! This is of course the
fundamental operation in this world. The most basic way to accomplish
this is with ``bzr push`` but that requires that your new branch be up
to date with the trunk. If the trunk has new revisions that are not
present in your branch, then pushing will fail and you will have to
merge the new revisions from the trunk before you can push. (This means
``bzr merge``, <test, test, test>, ``bzr commit``, then do the push again.)
I prefer to use ``bzr merge`` for these sorts of things since it is the
most general operation for combining branches. Here's an example::
nmb at guttle[/tmp]$ bzr init test
Created a standalone tree (format: pack-0.92)
nmb at guttle[/tmp]$ cd test
nmb at guttle[/tmp/test]$ echo "new file text" > a
nmb at guttle[/tmp/test]$ bzr add
adding a
nmb at guttle[/tmp/test]$ bzr ci -m 'first commit'
Committing to: /private/tmp/test/
added a
Committed revision 1.
nmb at guttle[/tmp/test]$ bzr branch . ../test_new
Branched 1 revision(s).
nmb at guttle[/tmp/test]$ cd ../test_new
nmb at guttle[/tmp/test_new]$ echo "another file in a branch" > b
nmb at guttle[/tmp/test_new]$ bzr add
adding b
nmb at guttle[/tmp/test_new]$ bzr ci -m 'changed on the branch'
Committing to: /private/tmp/test_new/
added b
Committed revision 2.
nmb at guttle[/tmp/test_new]$ cd ../test
nmb at guttle[/tmp/test]$ echo "an unrelated change" >> a
nmb at guttle[/tmp/test]$ bzr ci -m 'more trunk changes'
Committing to: /private/tmp/test/
modified a
Committed revision 2.
nmb at guttle[/tmp/test]$ cd ../test_new
nmb at guttle[/tmp/test_new]$ bzr push ../test # push doesn't work
bzr: ERROR: These branches have diverged. See "bzr help
diverged-branches" for more information.
nmb at guttle[/tmp/test_new]$ cd ../test
nmb at guttle[/tmp/test]$ bzr merge ../test_new
+N b
All changes applied successfully.
nmb at guttle[/tmp/test]$ bzr st
added:
b
pending merge tips: (use -v to see all merge revisions)
Neil Martinsen-Bu... 2009-06-08 changed on the branch
nmb at guttle[/tmp/test]$ cat b
another file in a branch
nmb at guttle[/tmp/test]$ bzr ci -m 'everything looks OK'
Committing to: /private/tmp/test/
added b
Committed revision 3.
nmb at guttle[/tmp/test]$ bzr log -n0
3 Neil Martinsen-Burrell 2009-06-08 [merge]
everything looks OK
1.1.1 Neil Martinsen-Burrell 2009-06-08
changed on the branch
2 Neil Martinsen-Burrell 2009-06-08
more trunk changes
1 Neil Martinsen-Burrell 2009-06-08
first commit
I believe that it is individual preference as to whether one solves
possible conflicts and integration problems on the branch (as is the
case when using ``bzr push``) or on the trunk (as above when using ``bzr
merge``). I guess the thing to understand is that a merge operation
must occur somewhere. If the branches have not diverged, then the merge
can happen automatically as part of a pull or push. If the branches
have diverged (as in the above example) then an explicit merge command
is required somewhere. (I know that the terminology used here is
inexact. Please don't shoot me.)
-Neil
More information about the bazaar
mailing list