~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

Support unbreakable locks for trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
import os
39
39
import sys
40
40
 
41
 
from bzrlib.errors import LockError
 
41
from bzrlib.errors import LockError, LockContention
42
42
from bzrlib.osutils import realpath
43
43
from bzrlib.trace import mutter
44
44
 
100
100
            try:
101
101
                self.filename = realpath(filename)
102
102
                if self.filename in self.open_locks:
103
 
                    self._clear_f() 
104
 
                    raise LockError("Lock already held.")
 
103
                    self._clear_f()
 
104
                    raise LockContention("Lock already held.")
105
105
                # reserve a slot for this lock - even if the lockf call fails, 
106
106
                # at thisi point unlock() will be called, because self.f is set.
107
107
                # TODO: make this fully threadsafe, if we decide we care.