/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: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

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