Collocating repo and checkout

Michael Homer michael at gobolinux.org
Mon Apr 6 09:04:17 BST 2009


Hi,
For my workflow I find git's in-repository branches handy, and I've been wanting 
to make that same functionality work in Bazaar, which I otherwise prefer. I've 
been looking at writing a plugin to duplicate at least the part of them that I 
find useful. In the course of that I've found an odd trait that seems very 
convenient, but also potentially dangerous.

The usual multi-branch workflow for Bazaar is to have one shared repository and 
several branches within it, possibly with one of those being a lightweight 
checkout of one of the others. By copying the "branch" and "checkout" 
directories out of that checkout into $repo/.bzr it seems to be possible to 
have Bazaar treat the root of the repository itself as the checkout. The 
treeless branches themselves can then be put somewhere out of the way, such as 
.bzr/local-branches, and you end up with a pretty good approximation of a 
single multi-branch branch. Specifying the paths to switch and merge then 
becomes a pain, but that's where the plugin would wrap things up nicely.

I have two questions to go with that: firstly, are there any potential pitfalls 
in this setup? Clearly it's a pretty big hack, but as far as I can tell from 
testing things out nothing in Bazaar has a problem with it. Both the checkout 
and the repository go about their business in the ordinary way, without any 
interference from each other. Secondly, since it's not an intentional 
behaviour, is it likely to continue working in the future (so I can base my 
plugin around it)?

For clarity, here's a script of how I'm initialising this repository:
bzr init-repo .
mkdir -p .bzr/local-branches
cd .bzr/local-branches
bzr init trunk
cd -
bzr checkout --lightweight .bzr/local-branches/trunk sandbox
cp -R sandbox/.bzr/{branch,checkout} .bzr
rm -rf sandbox

From that point on the root of the repository acts as a checkout, and you can 
create new branches and switch between them without issue. It avoids polluting 
.. with extra directories, which sometimes isn't an option for what I'm 
working on (such as live copies of scripts in the system). Storing the 
repository elsewhere and using a checkout live would also work, but probably 
couldn't be wrapped up in a generic way.
-Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090406/8d2475de/attachment.pgp 


More information about the bazaar mailing list