/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 tree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-28 22:40:22 UTC
  • mto: (0.429.24 submodules)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180328224022-rq8v7ssm0xfige2f
Return store from self._lookup_path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
302
302
        if self.tree is None:
303
303
            raise errors.NoSuchFile(path)
304
304
        try:
305
 
            return tree_lookup_path(self.store.__getitem__, self.tree,
 
305
            (mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree,
306
306
                path.encode('utf-8'))
307
307
        except KeyError:
308
308
            raise errors.NoSuchFile(self, path)
 
309
        else:
 
310
            return (self.store, mode, hexsha)
309
311
 
310
312
    def is_executable(self, path, file_id=None):
311
 
        (mode, hexsha) = self._lookup_path(path)
 
313
        (store, mode, hexsha) = self._lookup_path(path)
312
314
        if mode is None:
313
315
            # the tree root is a directory
314
316
            return False
315
317
        return mode_is_executable(mode)
316
318
 
317
319
    def kind(self, path, file_id=None):
318
 
        (mode, hexsha) = self._lookup_path(path)
 
320
        (store, mode, hexsha) = self._lookup_path(path)
319
321
        if mode is None:
320
322
            # the tree root is a directory
321
323
            return "directory"
334
336
            return
335
337
        if from_dir is None:
336
338
            from_dir = u""
337
 
        (mode, hexsha) = self._lookup_path(from_dir)
 
339
        (store, mode, hexsha) = self._lookup_path(from_dir)
338
340
        if mode is None: # Root
339
341
            root_ie = self._get_dir_ie(b"", None)
340
342
        else:
349
351
            yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie)
350
352
        todo = set()
351
353
        if root_ie.kind == 'directory':
352
 
            todo.add((from_dir.encode("utf-8"), hexsha, root_ie.file_id))
 
354
            todo.add((store, from_dir.encode("utf-8"), hexsha, root_ie.file_id))
353
355
        while todo:
354
 
            (path, hexsha, parent_id) = todo.pop()
355
 
            tree = self.store[hexsha]
 
356
            (store, path, hexsha, parent_id) = todo.pop()
 
357
            tree = store[hexsha]
356
358
            for name, mode, hexsha in tree.iteritems():
357
359
                if self.mapping.is_special_file(name):
358
360
                    continue
360
362
                if stat.S_ISDIR(mode):
361
363
                    ie = self._get_dir_ie(child_path, parent_id)
362
364
                    if recursive:
363
 
                        todo.add((child_path, hexsha, ie.file_id))
 
365
                        todo.add((store, child_path, hexsha, ie.file_id))
364
366
                else:
365
367
                    ie = self._get_file_ie(child_path, name, mode, hexsha, parent_id)
366
368
                yield child_path.decode('utf-8'), "V", ie.kind, ie.file_id, ie
390
392
            posixpath.basename(path).decode("utf-8"), parent_id)
391
393
 
392
394
    def iter_child_entries(self, path, file_id=None):
393
 
        (mode, tree_sha) = self._lookup_path(path)
 
395
        (store, mode, tree_sha) = self._lookup_path(path)
394
396
 
395
397
        if not stat.S_ISDIR(mode):
396
398
            return
397
399
 
398
400
        encoded_path = path.encode('utf-8')
399
401
        file_id = self.path2id(path)
400
 
        tree = self.store[tree_sha]
 
402
        tree = store[tree_sha]
401
403
        for name, mode, hexsha in tree.iteritems():
402
404
            if self.mapping.is_special_file(name):
403
405
                continue
449
451
        return osutils.sha_string(self.get_file_text(path, file_id))
450
452
 
451
453
    def get_file_verifier(self, path, file_id=None, stat_value=None):
452
 
        (mode, hexsha) = self._lookup_path(path)
 
454
        (store, mode, hexsha) = self._lookup_path(path)
453
455
        return ("GIT", hexsha)
454
456
 
455
457
    def get_file_text(self, path, file_id=None):
456
458
        """See RevisionTree.get_file_text."""
457
 
        (mode, hexsha) = self._lookup_path(path)
 
459
        (store, mode, hexsha) = self._lookup_path(path)
458
460
        if stat.S_ISREG(mode):
459
 
            return self.store[hexsha].data
 
461
            return store[hexsha].data
460
462
        else:
461
463
            return b""
462
464
 
463
465
    def get_symlink_target(self, path, file_id=None):
464
466
        """See RevisionTree.get_symlink_target."""
465
 
        (mode, hexsha) = self._lookup_path(path)
 
467
        (store, mode, hexsha) = self._lookup_path(path)
466
468
        if stat.S_ISLNK(mode):
467
 
            return self.store[hexsha].data.decode('utf-8')
 
469
            return store[hexsha].data.decode('utf-8')
468
470
        else:
469
471
            return None
470
472
 
476
478
    def path_content_summary(self, path):
477
479
        """See Tree.path_content_summary."""
478
480
        try:
479
 
            (mode, hexsha) = self._lookup_path(path)
 
481
            (store, mode, hexsha) = self._lookup_path(path)
480
482
        except errors.NoSuchFile:
481
483
            return ('missing', None, None, None)
482
484
        kind = mode_kind(mode)
483
485
        if kind == 'file':
484
486
            executable = mode_is_executable(mode)
485
 
            contents = self.store[hexsha].data
 
487
            contents = store[hexsha].data
486
488
            return (kind, len(contents), executable, osutils.sha_string(contents))
487
489
        elif kind == 'symlink':
488
 
            return (kind, None, None, self.store[hexsha].data)
 
490
            return (kind, None, None, store[hexsha].data)
489
491
        else:
490
492
            return (kind, None, None, None)
491
493