~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Martin Packman
  • Date: 2012-09-05 20:22:17 UTC
  • mfrom: (6437.63.6 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: martin.packman@canonical.com-20120905202217-79io6livc1q0p66u
Merge 2.5 into bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
from __future__ import absolute_import
37
37
 
 
38
import contextlib
38
39
import errno
39
40
import os
40
41
import sys
548
549
            trace.note(gettext('{0!r} was {1} locked again'), self, type_name)
549
550
        self._prev_lock = lock_type
550
551
 
 
552
@contextlib.contextmanager
 
553
def write_locked(lockable):
 
554
    lockable.lock_write()
 
555
    try:
 
556
        yield lockable
 
557
    finally:
 
558
        lockable.unlock()