~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Robert Collins
  • Date: 2006-05-04 10:36:13 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504103613-bf4d13f925aa8520
Extend LockableFiles to support break_lock() calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
        prompt for input if a lock is detected and there is any doubt about
233
233
        it possibly being still active.
234
234
        """
 
235
        self._check_not_locked()
235
236
        holder_info = self.peek()
236
237
        if holder_info is not None:
237
238
            if bzrlib.ui.ui_factory.get_boolean(
241
242
                    holder_info["hostname"])):
242
243
                self.force_break(holder_info)
243
244
        
244
 
    
245
245
    def force_break(self, dead_holder_info):
246
246
        """Release a lock held by another process.
247
247
 
260
260
        """
261
261
        if not isinstance(dead_holder_info, dict):
262
262
            raise ValueError("dead_holder_info: %r" % dead_holder_info)
263
 
        if self._lock_held:
264
 
            raise AssertionError("can't break own lock: %r" % self)
 
263
        self._check_not_locked()
265
264
        current_info = self.peek()
266
265
        if current_info is None:
267
266
            # must have been recently released
280
279
        self.transport.delete(broken_info_path)
281
280
        self.transport.rmdir(tmpname)
282
281
 
 
282
    def _check_not_locked(self):
 
283
        """If the lock is held by this instance, raise an error."""
 
284
        if self._lock_held:
 
285
            raise AssertionError("can't break own lock: %r" % self)
 
286
 
283
287
    def confirm(self):
284
288
        """Make sure that the lock is still held by this locker.
285
289