Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to programmatically create a new blank Bazaar branch/repo, tantamount to running brz init. I've tried several different routes from the bzrlib documentation but so far haven't succeeded.

These failures are listed below:

from bzrlib import repository
r = repository.Repository.open('/tmp/testing')
r = repository.Repository.create('/tmp/testing')

from bzrlib import branch
b = branch.Branch.create('/tmp/testing')
b = branch.Branch.open('/tmp/testing')

All result in failures that /tmp/testing is not a branch.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

There's a nice convenience function hidden in there somewhere:

from bzrlib import bzrdir
bzrdir.BzrDir.create_branch_convenience('./foo')

Create a new ControlDir, Branch and Repository at the url 'base'.

This is a convenience function - it will use an existing repository if possible, can be told explicitly whether to create a working tree or not.

This will use the current default ControlDirFormat unless one is

I honestly don't remember how I found it. Probably by reading the code of a plugin.

share|improve this answer
    
This is amazing. Thank you! –  Marco Ceppi Mar 15 '13 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.