Search code examples
gitbazaar

Is there a Bazaar equivalent of Git default branching?


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?


Solution

  • 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?