bzrlib should provide context managers for locking
Bug #522195 reported by
Henning Eggers
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
In a recent Launchpad branch I implemented this:
class ReadLockTree(
"""Context manager to claim a read lock on a bzr tree."""
def __init__(self, tree):
self.tree = tree
def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
return False
And used it like this:
with ReadLockTree(tree):
tree.
It would be great if it was generally integrated into bzrlib so that it can be used like this:
with lockable_
lockable_
Same for write locks.
Related branches
lp:~henninge/bzr/bug-522195-contextmanagers
- Robert Collins (community): Needs Fixing
-
Diff: 351 lines (+255/-4)7 files modifiedbzrlib/branch.py (+2/-1)
bzrlib/contextmanagers.py (+79/-0)
bzrlib/mutabletree.py (+2/-1)
bzrlib/repository.py (+2/-1)
bzrlib/tests/__init__.py (+1/-0)
bzrlib/tests/test_contextmanagers.py (+167/-0)
bzrlib/tree.py (+2/-1)
Changed in bzr: | |
status: | In Progress → Confirmed |
tags: | added: check-for-breezy |
To post a comment you must log in.
importance wishlist
status confirmed
done
Thanks; if you'd like this integrated, I suggest writing some tests for
it (python 2.4 compatible!) and proposing a merge.
It could live in the decorators module or the cleanup module, or even a
new one.
-Rob