~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/decorators.py

  • Committer: Martin Pool
  • Date: 2006-02-22 04:29:54 UTC
  • mfrom: (1566 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060222042954-60333f08dd56a646
[merge] from bzr.dev before integration
Fix undefined ordering in sign_my_revisions breaking tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        def branch_method(self, ...):
33
33
            stuff
34
34
    """
35
 
    def decorated(self, *args, **kwargs):
 
35
    def read_locked(self, *args, **kwargs):
36
36
        self.lock_read()
37
37
        try:
38
38
            return unbound(self, *args, **kwargs)
39
39
        finally:
40
40
            self.unlock()
41
 
    decorated.__doc__ = unbound.__doc__
42
 
    decorated.__name__ = unbound.__name__
43
 
    return decorated
 
41
    read_locked.__doc__ = unbound.__doc__
 
42
    read_locked.__name__ = unbound.__name__
 
43
    return read_locked
44
44
 
45
45
 
46
46
def needs_write_lock(unbound):
47
47
    """Decorate unbound to take out and release a write lock."""
48
 
    def decorated(self, *args, **kwargs):
 
48
    def write_locked(self, *args, **kwargs):
49
49
        self.lock_write()
50
50
        try:
51
51
            return unbound(self, *args, **kwargs)
52
52
        finally:
53
53
            self.unlock()
54
 
    decorated.__doc__ = unbound.__doc__
55
 
    decorated.__name__ = unbound.__name__
56
 
    return decorated
 
54
    write_locked.__doc__ = unbound.__doc__
 
55
    write_locked.__name__ = unbound.__name__
 
56
    return write_locked
57
57