[BUG] push to shared repo when lock is held

John Arbash Meinel john at arbash-meinel.com
Thu Dec 7 15:26:29 GMT 2006


Wouter van Heyst wrote:
> On Tue, Dec 05, 2006 at 11:24:11AM +0200, Alexander Belchenko wrote:

...

>>
>> It's a really ugly. bzr creates directory to push before it try to
>> obtain lock to repository and then fails again because directory already
>> created.
> 
> I don't think it is an issue of doing things wrongly outside of the
> lock, so bug 30576 would help.
> 
> Wouter van Heyst
> 
> 

I really think that the "right" fix is to change the push code so that
it initializes a complete branch, before trying to copy the content. So
in effect 'bzr push' and 'bzr branch' become very similar to 'bzr init'
+ 'bzr pull'.

Right now you can look at bzrdir.BzrDir.clone() and you can see that it
does:

1) grab local repository
2) create or search for existing remote repository
3) remote_repo.fetch(local_repo) or local_repo.clone(local_repo)
depending on if a remote repository already exists. This spends a lot of
time copying data, and is typically where ^C will stop operations.
4) grab local branch
5) clone local branch to remote branch if available
6) ditto for the working tree.

I'm not sure where working trees would fall, but  I would suggest
changing it to:

1) grab local repo
2) search for remote, if not exists (or force) initialize a new one
3) grab local branch, if exists, initialize a remote branch.
4) remote_repo.fetch(local_repo)
5) local_branch.copy_content_into(remote_branch)


This solves a lot of the problems we've had with launchpad, and I don't
think it adds a lot of overhead. It does mean that we create a couple
empty files (.bzr/branch/revision-history, for example) before we
overwrite them during the copy stage. But I think it makes push creation
*much* more stable.

Honestly, I would prefer to deprecate creating branches with 'bzr push',
and for that to be switched back to 'bzr branch'. But that doesn't seem
to be the recognized workflow. So instead I'm just proposing the
BzrDir.clone() create the remote objects before it starts spending a lot
of time copying data.

It probably means adding a little bit more helper functions, to allow us
to initialize a remote repo/branch which is the same format as the local
one, without actually copying all the data into it. Right now we use
.clone() as both "initialize + copy".

We probably can do it with repo._format.initialize(remote). But to do
that correctly we need to promote _format to being a public member.

I think Aaron added the BzrDir.cloning_metadir() function, which might
be sufficient. Certainly it creates a BzrDir object with the right
repository format type. I don't think it has the right Branch type (but
at the moment we only have 1 branch format type)

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061207/75295acc/attachment.pgp 


More information about the bazaar mailing list