~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

Show diffs side-by-side

added added

removed removed

Lines of Context:
347
347
        This is a UI centric function: it uses the bzrlib.ui.ui_factory to
348
348
        prompt for input if a lock is detected and there is any doubt about
349
349
        it possibly being still active.
 
350
 
 
351
        :returns: LockResult for the broken lock.
350
352
        """
351
353
        self._check_not_locked()
352
354
        try:
361
363
            if bzrlib.ui.ui_factory.confirm_action(
362
364
                "Break %(lock_info)s", 'bzrlib.lockdir.break', 
363
365
                dict(lock_info=lock_info)):
364
 
                self.force_break(holder_info)
 
366
                result = self.force_break(holder_info)
 
367
                bzrlib.ui.ui_factory.show_message(
 
368
                    "Broke lock %s" % result.lock_url)
365
369
 
366
370
    def force_break(self, dead_holder_info):
367
371
        """Release a lock held by another process.
378
382
        After the lock is broken it will not be held by any process.
379
383
        It is possible that another process may sneak in and take the
380
384
        lock before the breaking process acquires it.
 
385
 
 
386
        :returns: LockResult for the broken lock.
381
387
        """
382
388
        if not isinstance(dead_holder_info, dict):
383
389
            raise ValueError("dead_holder_info: %r" % dead_holder_info)
403
409
                                 current_info.get('nonce'))
404
410
        for hook in self.hooks['lock_broken']:
405
411
            hook(result)
 
412
        return result
406
413
 
407
414
    def force_break_corrupt(self, corrupt_info_lines):
408
415
        """Release a lock that has been corrupted.