Creating a branch reference without opening
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 21 19:40:20 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Allouche wrote:
> Hello,
>
> In the Launchpad test suite, I want to create branch references that
> point to locations that cannot be opened (e.g. file://local/branch and
> http://example.com/branch). However the bzrlib API does not seem to
> provide a way to create a branch reference without opening it.
>
> Those tests are feature tests, so they should not use mocks and need to
> operate on branch references on disk. Since they test input validation
> that is done using bzrdir.get_branch_reference before opening the
> branch, so they do not need to open the branch references, and they
> should fail if they do try to open it.
>
> The code to create branch references is
> bzrdir.branch.BranchReferenceFormat.initialize, it ends with a
> self.open that calls BzrDir.open(location) on the referenced location.
>
> I filed a bug on this issue:
> https://bugs.edge.launchpad.net/bzr/+bug/139109
> No API to create a branch reference without opening it
>
> If you have a non-hackish solution that does not involve modifying
> bzrlib, I would like to hear about it.
>
Well, I would consider this hackish but:
os.mkdir('.bzr')
open('.bzr/branch-format',
'wb').write(bzrlib.bzrdir.BzrDirMetaFormat1().get_format_string())
os.mkdir('branch')
open('.bzr/branch/format',
'wb').write(bzrlib.branch.BranchReferenceFormat.get_format_string())
open('.bzr/branch/location', 'wb').write('http://bad/url/')
AFAIK that is how Launchpad does its redirects from "bzr branch
http://launchpad.net/bzr", by creating those 3 files.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG9BAUJdeBCYSNAAMRAo8MAJ9s17Aztr5kJLSLdfIA6KTSarVA0ACfUlXf
VCEUv47UcaFRA5/3fx+GhA8=
=yivU
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list