/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: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

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