~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-20 16:32:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2050.
  • Revision ID: john@arbash-meinel.com-20060920163206-f996c191184dd0f7
Add the ability to report if the lock changes from underneath you

Show diffs side-by-side

added added

removed removed

Lines of Context:
363
363
        # XXX: the transport interface doesn't let us guard 
364
364
        # against operations there taking a long time.
365
365
        deadline = time.time() + timeout
366
 
        commented = False
 
366
        last_info = None
367
367
        while True:
368
368
            try:
369
369
                self.attempt_lock()
370
370
                return
371
371
            except LockContention:
372
372
                pass
373
 
            if not commented:
374
 
                commented = True
375
 
                self._report_function('Unable to obtain lock on %s\n'
 
373
            new_info = self.peek()
 
374
            mutter('last_info: %s, new info: %s', last_info, new_info)
 
375
            if new_info is not None and new_info != last_info:
 
376
                last_info = new_info
 
377
                formatted_info = self._format_lock_info(new_info)
 
378
                self._report_function('Unable to obtain %s\n'
 
379
                                      '%s\n' # held by
 
380
                                      '%s\n' # locked ... ago
376
381
                                      'Will continue to try for %s seconds\n',
377
 
                                      self.transport.abspath(self.path),
378
 
                                      timeout)
 
382
                                      formatted_info[0],
 
383
                                      formatted_info[1],
 
384
                                      formatted_info[2],
 
385
                                      deadline - time.time())
379
386
 
380
387
            if time.time() + poll < deadline:
381
388
                time.sleep(poll)