inaccessible shared repositories

Kent Gibson warthog618 at gmail.com
Mon Dec 4 14:50:51 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I ran across a small wrinkle wrt shared repositories.
'bzr branch' goes looking for a containing shared repository before
deciding whether to create a new one.  To find a containing shared
repository, bzr walks up the path until it finds one.
If the one it finds it not accessible (e.g. it is owned by someone
else) then bzr reports:

bzr: ERROR: Permission denied: u'/.bzr/branch-format': [Errno 13]
Permission denied: u'/.bzr/branch-format'

(In my case I have a bzr repository in / that is owned by root and not
accessible to other users - chmod 700.)

The only workaround I can find is to first create my own repository
using 'bzr init-repo' and then add the branch to that.
That seems a bit heavyweight, so I would prefer that bzr consider a
.bzr directory it cannot access as not being a valid repository and
remove it from consideration.

To that end I have a quick fix which is to catch the access violation
in BzrDirFormat.probe_transport:

=== modified file 'bzrlib/bzrdir.py'
- --- bzrlib/bzrdir.py    2006-12-01 19:41:16 +0000
+++ bzrlib/bzrdir.py    2006-12-04 11:25:45 +0000
@@ -1063,7 +1063,7 @@
         """Return the .bzrdir style transport present at URL."""
         try:
             format_string = transport.get(".bzr/branch-format").read()
- -        except errors.NoSuchFile:
+        except (errors.NoSuchFile, errors.PermissionDenied):
             raise errors.NotBranchError(path=transport.base)
 

I'm not sure this is the best place for it, or if there are
implications to other transports, but it works for my particular case.

Does this approach and patch seem reasonable?
If no one has a better suggestion I'll write up a test case and bundle it.

Cheers,
Kent.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFdDXLgoxTFTi1P8QRAm0RAJ9lXPSIAnVxryZ6TSy+qTDtjQLyBwCbBzAc
1XhUETWNHU8JjSNTwbRkN00=
=gFOf
-----END PGP SIGNATURE-----




More information about the bazaar mailing list