Recording where branches that are absent are

Robert Collins robertc at robertcollins.net
Wed Feb 1 21:05:09 GMT 2006


On Tue, 2006-01-31 at 02:15 -0500, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Robert Collins wrote:
> | Yes, I do mean .bzr/branch/branch-location. This would mean that:
> | Branch.open(dir) would be able to return the real branch that is rooted
> | at the branch-location, or a proxy to it, rather than failing.
> 
> I don't think that's an advantage.  If there's no branch at the
> location, it seems odd for the operation to succeed.  It could lead to
> an infinite loop.  (But it might make sense for open_containing.)

Well, I am thinking of is a 'there is a branch you can access via the
control dir here'. With the current design of recording this in the
working tree we can have inconsistent states like:

.bzr/workingtree has a branch pointer to a remote location
.bzr/branch has a branch

I think a huge advantage of this would be to make that impossible - not
illegal, actually impossible.


> | If the branch-location was in the checkout, then the only way you could
> | find there was a distant branch would be to create a working tree
> | instance and then look at its branch property.
> 
> I don't think a working tree with no branch present should even have a
> .bzr/branch directory, much less any control files.  That would imply a
> .bzr/branch-format, which might be different from the real branch's
> branch format.  All to solve an API issue that isn't very serious; we
> can easily have a function that does what you propose for open by
> creating a temp WorkingTree, which would be very cheap.

Thats a minor wart but not the key thing I am concerned about.

> Also, what you propose entails creating two Branch objects, because the
> one used to read branch-location, and one to instantiate the branch from
> its location.  (There may be branch-format differences, so we'd need two
> branches.)

Not at all.
BzrDirFormat7 [supporting split out repo/branch/checkout] when asked to
open a branch will do
branch_transport = self.transport.clone('branch')
format = BranchFormat.find_format(branch_transport)
# [compatability checks here if needed]
format.open(branch_transport)

format is a factory - if the detected format on disk is a
'BranchReference', then the constructed and returned branch would be a
real branch from the target url - there would be no instance of an
unreal or pseudo branch constructed at all.

with respect to potential cycles, I would not expect this to forward,
that is a reference could not be a reference to a reference.

> I see 'location of the branch' as a property of the WorkingTree.  It
> will be manipulated by working tree commands, and will affect the
> behavior of the WorkingTree alone.  As a WorkingTree property, the way
> it is represented should be subject to the checkout-format.

I see it as a property of the .bzr control dir - we should only ever
have one branch associated with a .bzr dir and this enforces that by
recording *either* a branch *or* a reference, but not both.

Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060202/e8e66122/attachment.pgp 


More information about the bazaar mailing list