/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-09-29 06:58:51 UTC
  • Revision ID: jelmer@jelmer.uk-20180929065851-dom63z9baz6guvru
Fix brz-hg specific tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
    def get_physical_lock_status(self):
134
134
        return False
135
135
 
 
136
    def _cleanup(self):
 
137
        pass
 
138
 
136
139
    def unlock(self):
137
140
        if not self._lock_count:
138
141
            return lock.cant_unlock_not_held(self)
181
184
            path = self.id2path(file_id)
182
185
            self._dirstate.remove(path.encode("utf-8"))
183
186
 
184
 
    def stored_kind(self, file_id, path=None):
185
 
        if path is not None:
186
 
            path = self.id2path(file_id)
 
187
    def stored_kind(self, path, file_id=None):
187
188
        return mode_kind(self._dirstate._map[path.encode("utf-8")][1])
188
189
 
189
190
    def _validate_unicode_text(self, text, context):
242
243
        return self._dirstate.extra()
243
244
 
244
245
    if not osutils.supports_executable():
245
 
        def is_executable(self, file_id, path=None):
 
246
        def is_executable(self, path, file_id=None):
246
247
            basis_tree = self.basis_tree()
247
 
            if file_id in basis_tree:
248
 
                return basis_tree.is_executable(file_id)
249
 
            # Default to not executable
250
 
            return False
 
248
            try:
 
249
                return basis_tree.is_executable(path, file_id)
 
250
            except NoSuchFile:
 
251
                # Default to not executable
 
252
                return False
251
253
    else:
252
 
        def is_executable(self, file_id, path=None):
253
 
            if not path:
254
 
                path = self.id2path(file_id)
 
254
        def is_executable(self, path, file_id=None):
255
255
            mode = os.lstat(self.abspath(path)).st_mode
256
256
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
257
257
 
258
258
        _is_executable_from_path_and_stat = \
259
259
            _is_executable_from_path_and_stat_from_stat
260
260
 
261
 
    def get_file_mtime(self, file_id, path=None):
 
261
    def get_file_mtime(self, path, file_id=None):
262
262
        """See Tree.get_file_mtime."""
263
 
        if not path:
264
 
            path = self.id2path(file_id)
265
263
        return os.lstat(self.abspath(path)).st_mtime
266
264
 
267
 
    def get_file_sha1(self, file_id, path=None, stat_value=None):
268
 
        if path is None:
269
 
            path = self.id2path(file_id)
 
265
    def get_file_sha1(self, path, file_id=None, stat_value=None):
270
266
        try:
271
267
            return osutils.sha_file_by_name(self.abspath(path).encode(osutils._fs_enc))
272
268
        except OSError, (num, msg):
294
290
            ie.executable = ('x' in flags)
295
291
        return ie
296
292
 
297
 
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
298
 
        # FIXME: Support specific_file_ids
 
293
    def iter_entries_by_dir(self, specific_files=None, yield_parents=False):
 
294
        # FIXME: Support specific_files
299
295
        # FIXME: yield actual inventory entries
300
 
        if specific_file_ids is not None:
 
296
        if specific_files is not None:
301
297
            raise NotImplementedError(self.iter_entries_by_dir)
302
298
        # Everything has a root directory
303
299
        yield u"", self._get_dir_ie(u"")
314
310
            fflags = self._dirstate.flags(p)
315
311
            decoded_path = p.decode("utf-8")
316
312
            yield decoded_path, self._get_file_ie(decoded_path, self.path2id(parent), fflags)
 
313
 
 
314
    def find_related_paths_across_trees(self, paths, trees=[],
 
315
            require_versioned=True):
 
316
        if paths is None:
 
317
            return None
 
318
 
 
319
        if require_versioned:
 
320
            trees = [self] + (trees if trees is not None else [])
 
321
            unversioned = set()
 
322
            for p in paths:
 
323
                for t in trees:
 
324
                    if t.is_versioned(p):
 
325
                        break
 
326
                else:
 
327
                    unversioned.add(p)
 
328
            if unversioned:
 
329
                raise errors.PathsNotVersionedError(unversioned)
 
330
 
 
331
        return filter(self.is_versioned, paths)