Branches with subsets of total code base

Joseph Wakeling joseph.wakeling at webdrake.net
Sun Mar 5 18:16:21 GMT 2006


Hello all,

I'm using bazaar-ng to keep track of the various code projects I have as
part of my PhD research.  I want to have one huge codebase which covers
*everything* I've written: the aim here is at some point to be able to
make all code available via my website.

However, this will cover a lot of diverse projects, and I would like to
be able to achieve, not just a "global" codebase, but separate branches
for individual projects.  The problem is that code for these projects
overlaps---for example I have random-number-generator modules, and graph
generation code, which will be reused in different programs.

So, what I'd like to be able to do is create branches with just a subset
of code---all that is needed for a given project---but which can push
and pull revisions for relevant code back and forth from the main code
base without having to worry about copying over all the other unrelated
material stored there.

To what extent is this possible with bazaar-ng?

To take an example of what I want, here's how my repository is laid out:

~/code/   --- home of my main branch.  Code is contained in the two
following subdirectories:
~/code/src/   --- this and its subdirectories contains source code for
different modules.
~/code/main/  --- contains main functions with makefiles etc., which tie
the different modules together into working programs.

So, right now I have two projects which are called n0 (a neural network
project) and MEGa (a financial market simulation).  By itself, n0 uses
the contents of the following directories:

~/code/main/n0/     --- the main program.
~/code/src/neuR0/   --- neural network function libraries
~/code/src/rng/       --- random number generators
~/code/src/error/     --- error recording functions

(There are a couple of others, but you get the idea.)  On the other hand
the MEGa project uses,

~/code/main/MEGa/
~/code/src/MEGa/
~/code/src/rng/
~/code/src/error/

Obviously if I'm doing work *just* on n0, or *just* on MEGa, it's a pain
to have to branch the whole repository.  What I would like to be able to
do is to create a branch like, n0_experimental, which will contain
*just* the sources and other stuff needed to edit and test out n0 and
not (for example) the code in the ~/code/src/MEGa directory.  But I'd
like to be able to push and pull revisions cleanly back and forth
between this branch and the main repository which contains not just the
n0 code but also the MEGa code and others besides.

If projects were self-contained it would be easy, but I don't know how
to deal with cases like this where there is code common to two different
projects.  I *could* just create separate branches within each library's
personal directory, like ~/code/src/neuR0/ or ~/code/src/rng/ , which
would just cover that particular library, but I don't want to do that: I
want branches to contain whole projects which can be compiled, run and
tested.

Any suggestions on how to achieve these aims?  Note that I'm not a
trained software engineer, so it may just be that I need education in
how to set up projects. :-)

Many thanks,

        -- Joe







More information about the bazaar mailing list