~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockable_files.py

  • Committer: Robert Collins
  • Date: 2006-05-05 00:44:25 UTC
  • mfrom: (1697 +trunk)
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060505004425-55597abf11998087
Merge HEAD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import bzrlib
22
22
from bzrlib.decorators import *
23
23
import bzrlib.errors as errors
24
 
from bzrlib.errors import LockError, ReadOnlyError
 
24
from bzrlib.errors import BzrError
25
25
from bzrlib.osutils import file_iterator, safe_unicode
26
26
from bzrlib.symbol_versioning import *
27
27
from bzrlib.trace import mutter, note
215
215
        # and potentially a remote locking protocol
216
216
        if self._lock_mode:
217
217
            if self._lock_mode != 'w' or not self.get_transaction().writeable():
218
 
                raise ReadOnlyError(self)
 
218
                raise errors.ReadOnlyError(self)
219
219
            self._lock_count += 1
220
220
        else:
221
221
            self._lock.lock_write()
260
260
        """Return true if this LockableFiles group is locked"""
261
261
        return self._lock_count >= 1
262
262
 
 
263
    def get_physical_lock_status(self):
 
264
        """Return physical lock status.
 
265
        
 
266
        Returns true if a lock is held on the transport. If no lock is held, or
 
267
        the underlying locking mechanism does not support querying lock
 
268
        status, false is returned.
 
269
        """
 
270
        try:
 
271
            return self._lock.peek() is not None
 
272
        except NotImplementedError:
 
273
            return False
 
274
 
263
275
    def get_transaction(self):
264
276
        """Return the current active transaction.
265
277
 
318
330
        self._lock.unlock()
319
331
        self._lock = None
320
332
 
 
333
    def peek(self):
 
334
        raise NotImplementedError()
 
335
 
321
336
    def create(self, mode=None):
322
337
        """Create lock mechanism"""
323
338
        # for old-style locks, create the file now