~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:13:40 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504101340-18fa61cb9cf268fb
Add break_lock utility function to LockDir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
        self.transport.delete(tmpname + self.__INFO_NAME)
226
226
        self.transport.rmdir(tmpname)
227
227
 
 
228
    def break_lock(self):
 
229
        """Break a lock not held by this instance of LockDir.
 
230
 
 
231
        This is a UI centric function: it uses the bzrlib.ui.ui_factory to
 
232
        prompt for input if a lock is detected and there is any doubt about
 
233
        it possibly being still active.
 
234
        """
 
235
        holder_info = self.peek()
 
236
        if holder_info is not None:
 
237
            if bzrlib.ui.ui_factory.get_boolean(
 
238
                "Break lock %s held by %s@%s" % (
 
239
                    self.transport,
 
240
                    holder_info["user"],
 
241
                    holder_info["hostname"])):
 
242
                self.force_break(holder_info)
 
243
        
 
244
    
228
245
    def force_break(self, dead_holder_info):
229
246
        """Release a lock held by another process.
230
247