Thoughts on Nested Branches: bzr init --nest?

Stephen J. Turnbull stephen at xemacs.org
Wed Apr 15 04:57:16 BST 2009


Maritza Mendez writes:

 > I wonder how often people need to create branches within branches compared
 > to how often this happens accidentally and causes problems.

I think that it's more likely that one of two things happens: (1) you
have a project with a fairly self-contained module, it turns out to be
useful elsewhere, and you do some refactoring to split it off as an
independent project.  (2) You decide to replace some functionality
implemented internally with an external independent module (obviously,
that's why Subversion calls them "externals").

In both cases I think it costs very little to require an option.
(FWIW, git happily inits a new repository in a subdirectory of an
existing project.)

I think the way git handles "submodules" is very elegant.  The
submodule is simply represented as a commit object rather than a tree
object.  It's a clear declaration that "I have my own history and I'm
proud of it!"  Of course you have to be careful with the programming
logic:  git commit and git log should *not* dereference a commit and
recursively manage the resulting subtree by default, while git diff
should do so, perhaps with some blatant warning that your submodule is
a fork of upstream.  But that's true anyway.

 > A session could look like this:
[...]
 > ~/martitza/Project_A/flowers> bzr init Project_B
 > Branch not created!  Enclosing brnach found at /home/martitza/Project_A
 > Use --nest to create nested branches.
 > ~/martitza/Project_A/flowers> bzr init --nest Project_B

Unless a nested branch needs to be a different format, I think "--force"
is a better choice for the name of the option.  Even in the case where
nesting requires a format, since bzr knows it's nested, it could do
this automagically:

flowers> bzr init Project_B
Branch not created!  Enclosing branch found at ../Project_A.
Nested branches require the gtfck format, and will not be usable with
bzr < 1000000BC.  Use --force to create nested branches if you need them.
flowers> bzr init --force Project_B




More information about the bazaar mailing list