views:

251

answers:

2

I'm just starting out with bazaar, and I've found that the checkout feature is the most useful for the way I work - namely I can c/o from a "master copy", do some development and then commit my changes in the new directory. This then updates the "master copy".

But what if I'm working on (eg) two projects, changing different portions of code? Say:

~/master                - master copy
bzr co master ./gui
bzr co master ./engine

So I'm doing gui-related stuff in the ./gui directory and under-the-hood stuff in ./engine. How should I commit my changes? If I commit gui first, then engine, I guess any conflicts will be flagged in engine?

Is there a way to merge gui and engine, and then do just one commit to the master copy?

To make things a little more complicated, how about if I do this:

bzr branch gui ./mouse

Now I perhaps I've been working on mouse, but also on gui. If I want to merge the code from gui AND mouse, and then commit to master, what is the best way to manage this? Or indeed, if I also:

bzr branch gui ./keyboard

If I've changed altered gui, keyboard and mouse, should I hierarchically merge - ie mouse+keyboard, then merge this with gui, then commit gui to master?

I hope it is clear what I'm trying to achieve! Thanks in advance for your time.

A: 

Yes, bzr should prevent you from checking in changes from the engine repo if it detects conflicts. Normally, you first do "bzr up" just prior to check-in and then make sure your stuff plays nice with others.

As for the second part of your question, dealing with mouse/keyboard branches, this is how I would normally do it. Simply cd into the gui dir, and then do:

bzr merge ../mouse

After merging the changes, you can then commit from the gui directory and it will send the changeset to the "master" directory.

Note that I'm hardly a bzr expert, but this is the way I've been dealing with SVN repos.

oggy
+2  A: 

If you have two checkouts, any time you commit changes to one, you will first have to pull down any changes from the other one, potentially having to resolve conflicts at each step. This is generally a good idea, since it's easier to resolve conflicts over time and make sure your code doesn't diverge too much.

However, it sounds like you want to have separate developers working on "gui" and "engine", or you just want to save your conflict resolution till development on both branches has completed. In this case, you should probably create them as independent branches with "bzr branch". Each branch can use local commits and not worry about conflicts with each other. Then when it comes time to merge you can do it one of 3 ways, all of which get the same end result:

1. Merge one branch into the other, then push it up to master:

cd gui
bzr merge ../engine
# manually fix any conflicts
bzr commit
bzr push #back up to main

The downside to the above method is that your "gui" branch now has the "engine" changes in it. Which is fine if you're going to throw away both branches once they're pushed back into the mainline. But if you want to keep the branches longer, you can:

2. Merge into the mainline:

cd master
bzr merge ../gui
bzr commit
bzr merge ../engine
# manually fix conflicts
bzr commit

This has the upside that you still have "gui" and "engine" as separate branches, but you've had to commit one to master before you were sure that they would both work together. So you really probably want to:

3. Create a merge branch:

bzr branch ~/master gui-engine-merge
cd gui-engine-merge
bzr merge ../gui
bzr commit
bzr merge ../engine
# manually fix conflicts
bzr commit
bzr push ~/master
# since this branch was only for merging, you don't need it anymore:
cd ..
rm -r gui-engine-merge
Cody Casterline
Hmm, apparently StackOverflow is strangely formatting bash code, even though I prefixed it all with four spaces. (!?)
Cody Casterline
Apparently code blocks can't be included in lists. I've edited your post to use manually-numbered headers, and it looks fine now.
John Millikin
Yeah, I just went and read the formatting guidelines. It seems *reaaaaaaally* silly that if I attempt to number my own list in plain text it gets changed to an <ol> which messes up other formatting. >.<
Cody Casterline
I got around it by making my list items headers.
Cody Casterline