/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/lockable_files.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from .lazy_import import lazy_import
20
20
lazy_import(globals(), """
21
 
import warnings
22
 
 
23
21
from breezy import (
24
22
    counted_lock,
25
23
    errors,
26
24
    lock,
27
 
    osutils,
28
25
    transactions,
29
26
    urlutils,
30
27
    )
153
150
        """
154
151
        if self._lock_mode:
155
152
            if (self._lock_mode != 'w'
156
 
                or not self.get_transaction().writeable()):
 
153
                    or not self.get_transaction().writeable()):
157
154
                raise errors.ReadOnlyError(self)
158
155
            self._lock.validate_token(token)
159
156
            self._lock_count += 1
160
157
            return self._token_from_lock
161
158
        else:
162
159
            token_from_lock = self._lock.lock_write(token=token)
163
 
            #traceback.print_stack()
 
160
            # traceback.print_stack()
164
161
            self._lock_mode = 'w'
165
162
            self._lock_count = 1
166
163
            self._set_write_transaction()
174
171
            self._lock_count += 1
175
172
        else:
176
173
            self._lock.lock_read()
177
 
            #traceback.print_stack()
 
174
            # traceback.print_stack()
178
175
            self._lock_mode = 'r'
179
176
            self._lock_count = 1
180
177
            self._set_read_transaction()
196
193
        if self._lock_count > 1:
197
194
            self._lock_count -= 1
198
195
        else:
199
 
            #traceback.print_stack()
 
196
            # traceback.print_stack()
200
197
            self._finish_transaction()
201
198
            try:
202
199
                self._lock.unlock()
259
256
    This is suitable for use only in WorkingTrees (which are at present
260
257
    always local).
261
258
    """
 
259
 
262
260
    def __init__(self, transport, escaped_name, file_modebits, dir_modebits):
263
261
        self._transport = transport
264
262
        self._escaped_name = escaped_name
293
291
        """Create lock mechanism"""
294
292
        # for old-style locks, create the file now
295
293
        self._transport.put_bytes(self._escaped_name, b'',
296
 
                            mode=self._file_modebits)
 
294
                                  mode=self._file_modebits)
297
295
 
298
296
    def validate_token(self, token):
299
297
        if token is not None: