~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

Introduce a new lock_broken hook.

* tests/test_lockdir.py:
(TestLockDirHooks): Separate hook related tests from other lock
tests.
(TestLockDirHooks.test_LockDir_broken_success,
TestLockDirHooks.test_LockDir_broken_failure): Add tests for the
new lock_broken hook.

* lockdir.py:
(LockDir.force_break): Fire lock_broken hook.

* lock.py:
(LockHooks.__init__): Add lock_broken hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
            self._trace("... unlock succeeded after %dms",
326
326
                    (time.time() - start_time) * 1000)
327
327
            result = lock.LockResult(self.transport.abspath(self.path),
328
 
                old_nonce)
 
328
                                     old_nonce)
329
329
            for hook in self.hooks['lock_released']:
330
330
                hook(result)
331
331
 
379
379
            raise LockBreakMismatch(self, broken_info, dead_holder_info)
380
380
        self.transport.delete(broken_info_path)
381
381
        self.transport.rmdir(tmpname)
 
382
        result = lock.LockResult(self.transport.abspath(self.path),
 
383
                                 current_info.get('nonce'))
 
384
        for hook in self.hooks['lock_broken']:
 
385
            hook(result)
382
386
 
383
387
    def _check_not_locked(self):
384
388
        """If the lock is held by this instance, raise an error."""