/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
from .lazy_import import lazy_import
20
18
lazy_import(globals(), """
21
 
import warnings
22
 
 
23
19
from breezy import (
24
20
    counted_lock,
25
 
    errors,
26
21
    lock,
27
 
    osutils,
28
22
    transactions,
29
23
    urlutils,
30
24
    )
31
25
""")
32
26
 
 
27
from . import (
 
28
    errors,
 
29
    )
33
30
from .decorators import (
34
31
    only_raises,
35
32
    )
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: