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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
19
 
from .lazy_import import lazy_import
 
19
from bzrlib.lazy_import import lazy_import
20
20
lazy_import(globals(), """
21
21
import warnings
22
22
 
23
 
from breezy import (
 
23
from bzrlib import (
24
24
    counted_lock,
25
25
    errors,
26
26
    lock,
30
30
    )
31
31
""")
32
32
 
33
 
from .decorators import (
 
33
from bzrlib.decorators import (
34
34
    only_raises,
35
35
    )
36
36
 
102
102
 
103
103
    def _escape(self, file_or_path):
104
104
        """DEPRECATED: Do not use outside this class"""
 
105
        if not isinstance(file_or_path, basestring):
 
106
            file_or_path = '/'.join(file_or_path)
105
107
        if file_or_path == '':
106
108
            return u''
107
 
        return urlutils.escape(file_or_path)
 
109
        return urlutils.escape(osutils.safe_unicode(file_or_path))
108
110
 
109
111
    def _find_modes(self):
110
112
        """Determine the appropriate modes for files and directories.
117
119
        try:
118
120
            st = self._transport.stat('.')
119
121
        except errors.TransportNotPossible:
120
 
            self._dir_mode = 0o755
121
 
            self._file_mode = 0o644
 
122
            self._dir_mode = 0755
 
123
            self._file_mode = 0644
122
124
        else:
123
125
            # Check the directory mode, but also make sure the created
124
126
            # directories and files are read-write for this user. This is
125
127
            # mostly a workaround for filesystems which lie about being able to
126
128
            # write to a directory (cygwin & win32)
127
 
            self._dir_mode = (st.st_mode & 0o7777) | 0o0700
 
129
            self._dir_mode = (st.st_mode & 07777) | 00700
128
130
            # Remove the sticky and execute bits for files
129
 
            self._file_mode = self._dir_mode & ~0o7111
 
131
            self._file_mode = self._dir_mode & ~07111
130
132
 
131
133
    def leave_in_place(self):
132
134
        """Set this LockableFiles to not clear the physical lock on unlock."""
201
203
            try:
202
204
                self._lock.unlock()
203
205
            finally:
204
 
                self._lock_count = 0
205
 
                self._lock_mode = None
 
206
                self._lock_mode = self._lock_count = None
206
207
 
207
208
    def is_locked(self):
208
209
        """Return true if this LockableFiles group is locked"""
292
293
    def create(self, mode=None):
293
294
        """Create lock mechanism"""
294
295
        # for old-style locks, create the file now
295
 
        self._transport.put_bytes(self._escaped_name, b'',
 
296
        self._transport.put_bytes(self._escaped_name, '',
296
297
                            mode=self._file_modebits)
297
298
 
298
299
    def validate_token(self, token):