/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/lock.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    :ivar unlock: A callable which will unlock the lock.
97
97
    """
98
98
 
99
 
    def __init__(self, unlock):
 
99
    def __init__(self, unlock, token=None):
100
100
        self.unlock = unlock
 
101
        self.token = token
101
102
 
102
103
    def __repr__(self):
103
104
        return "LogicalLockResult(%s)" % (self.unlock)
104
105
 
 
106
    def __enter__(self):
 
107
        return self
 
108
 
 
109
    def __exit__(self, exc_type, exc_val, exc_tb):
 
110
        # If there was an error raised, prefer the original one
 
111
        try:
 
112
            self.unlock()
 
113
        except:
 
114
            if exc_type is None:
 
115
                raise
 
116
        return False
105
117
 
106
118
 
107
119
def cant_unlock_not_held(locked_object):