/breezy-hg/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-hg/trunk

« back to all changes in this revision

Viewing changes to workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-19 21:21:33 UTC
  • Revision ID: jelmer@jelmer.uk-20181119212133-l9vwjrub3sd8tia8
Fix tests against current brz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    IncompatibleFormat,
32
32
    NoSuchFile,
33
33
    NotWriteLocked,
 
34
    UnsupportedOperation,
34
35
    )
35
36
from .tree import (
36
37
    HgTreeDirectory,
57
58
    """
58
59
 
59
60
    supports_versioned_directories = False
 
61
    supports_setting_file_ids = False
60
62
 
61
63
    @property
62
64
    def _matchingcontroldir(self):
92
94
        self._lock_mode = None
93
95
        self._lock_count = 0
94
96
 
 
97
    def all_file_ids(self):
 
98
        raise UnsupportedOperation(self.all_file_ids, self)
 
99
 
95
100
    def lock_read(self):
96
101
        """Lock the repository for read operations.
97
102
 
179
184
            # hg does not canonicalise paths : make them absolute
180
185
            self._dirstate.add(hg_files)
181
186
 
182
 
    def unversion(self, file_ids):
183
 
        for file_id in file_ids:
184
 
            path = self.id2path(file_id)
185
 
            self._dirstate.remove(path.encode("utf-8"))
186
 
 
187
 
    def stored_kind(self, path, file_id=None):
 
187
    def unversion(self, paths):
 
188
        for path in paths:
 
189
            self._dirstate.forget(path.encode("utf-8"))
 
190
 
 
191
    def remove(self, files, verbose=False, to_file=None, keep_files=True,
 
192
               force=False):
 
193
        for path in files:
 
194
            self._dirstate.forget(path.encode("utf-8"))
 
195
 
 
196
    def stored_kind(self, path):
188
197
        return mode_kind(self._dirstate._map[path.encode("utf-8")][1])
189
198
 
190
199
    def _validate_unicode_text(self, text, context):
220
229
 
221
230
    def path2id(self, path):
222
231
        # FIXME: For the time being; should use file id map eventually
 
232
        if isinstance(path, list):
 
233
            path = '/'.join(path)
223
234
        return self._branch.mapping.generate_file_id(path)
224
235
 
225
236
    def has_or_had_id(self, file_id):
229
240
        raise NotImplementedError(self.has_id)
230
241
 
231
242
    def id2path(self, file_id):
232
 
        assert type(file_id) == str
 
243
        if not isinstance(file_id, bytes):
 
244
            raise TypeError(file_id)
233
245
        return self._branch.mapping.parse_file_id(file_id)
234
246
 
235
247
    def revision_tree(self, revid):
243
255
        return self._dirstate.extra()
244
256
 
245
257
    if not osutils.supports_executable():
246
 
        def is_executable(self, path, file_id=None):
 
258
        def is_executable(self, path):
247
259
            basis_tree = self.basis_tree()
248
260
            try:
249
 
                return basis_tree.is_executable(path, file_id)
 
261
                return basis_tree.is_executable(path)
250
262
            except NoSuchFile:
251
263
                # Default to not executable
252
264
                return False
253
265
    else:
254
 
        def is_executable(self, path, file_id=None):
 
266
        def is_executable(self, path):
255
267
            mode = os.lstat(self.abspath(path)).st_mode
256
268
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
257
269
 
258
270
        _is_executable_from_path_and_stat = \
259
271
            _is_executable_from_path_and_stat_from_stat
260
272
 
261
 
    def get_file_mtime(self, path, file_id=None):
 
273
    def get_file_mtime(self, path):
262
274
        """See Tree.get_file_mtime."""
263
275
        return os.lstat(self.abspath(path)).st_mtime
264
276
 
265
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
 
277
    def get_file_sha1(self, path, stat_value=None):
266
278
        try:
267
279
            return osutils.sha_file_by_name(self.abspath(path).encode(osutils._fs_enc))
268
280
        except OSError, (num, msg):
283
295
        name = osutils.basename(path)
284
296
        if 'l' in flags:
285
297
            ie = HgTreeLink(file_id, name, parent_id)
286
 
            ie.symlink_target = self.get_symlink_target(path, file_id)
 
298
            ie.symlink_target = self.get_symlink_target(path)
287
299
        else:
288
300
            ie = HgTreeFile(file_id, name, parent_id)
289
 
            ie.text_sha1 = self.get_file_sha1(path, file_id)
 
301
            ie.text_sha1 = self.get_file_sha1(path)
290
302
            ie.executable = ('x' in flags)
291
303
        return ie
292
304