[MERGE/RFC] no lock for 'is_shared'

John Arbash Meinel john at arbash-meinel.com
Mon Jul 21 23:27:25 BST 2008


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

One of the things I noticed when tracing update, is that we end up
reading the pack-names file twice. And I believe it is because
'is_shared' takes out an implicit write lock, which we then throw away.

And we use 'is_shared()' because BzrDir.find_repository() needs to know
whether it can use the containing repository or not. And it is done at
an early enough stage that we aren't going to have the repository
permanently locked yet. (It is done early enough that we don't even know
if we want a read lock or a write lock.)

So here is a possible patch:
=== modified file 'bzrlib/repository.py'
- --- bzrlib/repository.py        2008-06-26 00:17:06 +0000
+++ bzrlib/repository.py        2008-07-21 22:24:16 +0000
@@ -1580,7 +1580,6 @@
~         else:
~             return self.get_inventory(revision_id)

- -    @needs_read_lock
~     def is_shared(self):
~         """Return True if this repository is flagged as a shared
repository."""
~         raise NotImplementedError(self.is_shared)
@@ -1959,7 +1958,6 @@
~         super(MetaDirRepository, self).__init__(_format, a_bzrdir,
control_files)
~         self._transport = control_files._transport

- -    @needs_read_lock
~     def is_shared(self):
~         """Return True if this repository is flagged as a shared
repository."""
~         return self._transport.has('shared-storage')


It just removes the implicit lock. We aren't saving the value anyway, so
I don't think locking buys us anything but a round trip to read
something we aren't going to cache.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiFDU0ACgkQJdeBCYSNAAMjywCfRYQOprLUxsguTkkGfDAHImil
PngAni0IaJuHYwPboh+WcZpleVvcnHFo
=ftz6
-----END PGP SIGNATURE-----



More information about the bazaar mailing list