Branching with a Central Repository

Tom Widmer tom.widmer at googlemail.com
Tue Oct 6 18:16:42 BST 2009


A. S. Budden wrote:
> Dear all,
> 
> We are currently looking to move over to Bazaar at my workplace.  Due
> to the way work is backed up and shared, we will be using the central
> repository approach [1] mostly, such that everyone uses checkout to
> get projects.  The initial plan for a repository layout (no working
> copies) is:
> 
>     root\ProjectGroup\Project1
>     root\ProjectGroup\Project2

Project1 and Project2 should be separate shared repos.

> These will be the trunk of the project.  I had thought that if we
> create branches (we don't really do this at all at the moment), the
> new branches will be:
> 
>     root\ProjectGroup\Project1\feature-gui
>     root\ProjectGroup\Project1\feature-magic

I'd have:
root\ProjectGroup\Project1\trunk
or similar, and put the branches at the same level (or at least don't 
have your main branch as the root of the repo). You could also have:
root\ProjectGroup\Project1\trunk
root\ProjectGroup\Project1\branches\feature-gui
root\ProjectGroup\Project1\branches\feature-magic

which will have the same advantages (see below).


>     # Get the project
>     bzr co f:\root\ProjectGroup\Project1

bzr co f:\root\ProjectGroup\Project1\trunk Project1

>     cd Project1
> 
>     # Do some editing (e.g. go to revision 10)
>     bzr ci -m "Done some editing"
> 
>     # Now branch: it'd be nicer to just do
>     # "bzr branch feature-gui" and automatically
>     # handle the relationship to the current checkout
>     bzr branch f:\root\ProjectGroup\Project1
> f:\root\ProjectGroup\Project1\feature-gui

Much simpler:
bzr switch --create-branch feature-gui
(it uses the branch name as a relative path)

> 
>     # Bind to the new feature
>     bzr bind f:\root\ProjectGroup\Project1\feature-gui

Not needed.

> 
>     # Do some editing (e.g. go to revision 11)
>     bzr ci -m "Added GUI template files"
>     # Do some more editing (e.g. go to revision 12)
>     bzr ci -m "Added GUI"
> 
>     # Now we need to merge it back into the mainline
>     # (so we get 10.1.2 or whatever [2]) and switch back.
>     # How do we do this cleanly?
> 
>     # Guess (this is nasty):
> 
>     # Bind to the original project path (this could get messy as
>     # we've got the changes already made!)
>     bzr bind f:\root\ProjectGroup\Project1\

bzr switch trunk

>     # Merge in the changes
>     bzr merge f:\root\ProjectGroup\Project1\feature-gui

bzr merge feature-gui
(again using a relative path)

> Is there a better way to do this?  I've been reading the
> documentation, but most of the branching/merging discussion focuses on
> the distributed development workflow.

The relative path trick makes things much simpler.

Tom




More information about the bazaar mailing list