views:

81

answers:

1

Using git, I can create branches conceptually, without having to branch my directory structure. When I switch between branches (assuming that everything has been committed), it will change the contents of the files that I'm working on to reflect whatever the status of the "current" branch is.

I really like being able to do this - it fits very well in my workflow, especially when I'm using say, Visual Studio.

But I am a Bazaar fanboy. I like that it's written mainly in Python, I like how pretty and simple (to me) the GUI is, and I love that it's very cross-platform.

So my desire is that it's possible, and my question is: can Bazaar do/emulate git's behavior? If so, how?

Thanks!

+2  A: 

I use (heavyweight) checkouts in Bazaar, so I'm not sure that this will be quite the same for you, but you should be able to do this with the switch command. For example:

mkdir source-repo
bzr init-repo --no-trees source-repo
bzr init source-repo/trunk
bzr co source-repo/trunk workdir
cd workdir
# Hack hack hack
bzr add
bzr ci -m "Done some stuff"
# Now create a branch and change the working directory files to match it
bzr switch -b my-new-branch
# We're now working on a checkout of ../source-repo/my-new-branch
# Hack hack hack
bzr add
bzr ci -m "Working on the branch"
# Now go back to the trunk (no -b as we're not creating the branch)
bzr switch trunk
# Working directory files now match the trunk branch
# Hack hack hack
bzr add
bzr ci -m "Changes to trunk"
# Merge in the changes from my-new-branch
bzr merge ../source-repo/my-new-branch
bzr ci -m "Merged my-new-branch"

You can, of course, also use the absolute path to the branches, but the relative ones save a lot of typing. Unfortunately, the merge command requires a full path.

Is this the sort of thing you're looking for?

Al
Perfect! Exactly what I was looking for. Another little question - do you know of any other way to delete a branch other than just `rm -rf ../source-repo/my-new-branch`?
Wayne Werner
Nope: I tend to just use `rm -rf` when I really need to delete a branch. Given that the branch only stores the changes (the rest of the code and history is in the shared repository: source-repo/.bzr in this case), they take up very little space and I tend to just leave them there. You can always organise them in subdirectories or with prefixes if you're trying to tidy up the directory structure.
Al