~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-20 19:46:46 UTC
  • mfrom: (4759 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4771.
  • Revision ID: john@arbash-meinel.com-20091020194646-wnqpd15qs19y28z7
Merge bzr.dev 4759, bringing in static_tuple and streaming improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
518
518
# We default to using the first available lock class.
519
519
_lock_type, WriteLock, ReadLock = _lock_classes[0]
520
520
 
 
521
 
 
522
class _RelockDebugMixin(object):
 
523
    """Mixin support for -Drelock flag.
 
524
 
 
525
    Add this as a base class then call self._note_lock with 'r' or 'w' when
 
526
    acquiring a read- or write-lock.  If this object was previously locked (and
 
527
    locked the same way), and -Drelock is set, then this will trace.note a
 
528
    message about it.
 
529
    """
 
530
    
 
531
    _prev_lock = None
 
532
 
 
533
    def _note_lock(self, lock_type):
 
534
        if 'relock' in debug.debug_flags and self._prev_lock == lock_type:
 
535
            if lock_type == 'r':
 
536
                type_name = 'read'
 
537
            else:
 
538
                type_name = 'write'
 
539
            trace.note('%r was %s locked again', self, type_name)
 
540
        self._prev_lock = lock_type
 
541