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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 18:35:30 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7178.
  • Revision ID: jelmer@jelmer.uk-20181116183530-ue8yx60h5tinl2wy
Merge more-cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
    def supports_rename_tracking(self):
283
283
        return False
284
284
 
285
 
    def get_file_revision(self, path, file_id=None):
 
285
    def get_file_revision(self, path):
286
286
        change_scanner = self._repository._file_change_scanner
287
287
        if self.commit_id == ZERO_SHA:
288
288
            return NULL_REVISION
291
291
        return self._repository.lookup_foreign_revision_id(
292
292
            commit_id, self.mapping)
293
293
 
294
 
    def get_file_mtime(self, path, file_id=None):
 
294
    def get_file_mtime(self, path):
295
295
        try:
296
 
            revid = self.get_file_revision(path, file_id)
 
296
            revid = self.get_file_revision(path)
297
297
        except KeyError:
298
298
            raise errors.NoSuchFile(path)
299
299
        try:
369
369
        else:
370
370
            return (self.store, mode, hexsha)
371
371
 
372
 
    def is_executable(self, path, file_id=None):
 
372
    def is_executable(self, path):
373
373
        (store, mode, hexsha) = self._lookup_path(path)
374
374
        if mode is None:
375
375
            # the tree root is a directory
376
376
            return False
377
377
        return mode_is_executable(mode)
378
378
 
379
 
    def kind(self, path, file_id=None):
 
379
    def kind(self, path):
380
380
        (store, mode, hexsha) = self._lookup_path(path)
381
381
        if mode is None:
382
382
            # the tree root is a directory
531
531
        """See RevisionTree.get_revision_id."""
532
532
        return self._revision_id
533
533
 
534
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
 
534
    def get_file_sha1(self, path, stat_value=None):
535
535
        if self.tree is None:
536
536
            raise errors.NoSuchFile(path)
537
 
        return osutils.sha_string(self.get_file_text(path, file_id))
 
537
        return osutils.sha_string(self.get_file_text(path))
538
538
 
539
 
    def get_file_verifier(self, path, file_id=None, stat_value=None):
 
539
    def get_file_verifier(self, path, stat_value=None):
540
540
        (store, mode, hexsha) = self._lookup_path(path)
541
541
        return ("GIT", hexsha)
542
542
 
543
 
    def get_file_size(self, path, file_id=None):
 
543
    def get_file_size(self, path):
544
544
        (store, mode, hexsha) = self._lookup_path(path)
545
545
        if stat.S_ISREG(mode):
546
546
            return len(store[hexsha].data)
547
547
        return None
548
548
 
549
 
    def get_file_text(self, path, file_id=None):
 
549
    def get_file_text(self, path):
550
550
        """See RevisionTree.get_file_text."""
551
551
        (store, mode, hexsha) = self._lookup_path(path)
552
552
        if stat.S_ISREG(mode):
554
554
        else:
555
555
            return b""
556
556
 
557
 
    def get_symlink_target(self, path, file_id=None):
 
557
    def get_symlink_target(self, path):
558
558
        """See RevisionTree.get_symlink_target."""
559
559
        (store, mode, hexsha) = self._lookup_path(path)
560
560
        if stat.S_ISLNK(mode):
562
562
        else:
563
563
            return None
564
564
 
565
 
    def get_reference_revision(self, path, file_id=None):
 
565
    def get_reference_revision(self, path):
566
566
        """See RevisionTree.get_symlink_target."""
567
567
        (store, mode, hexsha) = self._lookup_path(path)
568
568
        if S_ISGITLINK(mode):
620
620
        return self.store.iter_tree_contents(
621
621
            self.tree, include_trees=include_trees)
622
622
 
623
 
    def annotate_iter(self, path, file_id=None,
624
 
                      default_revision=CURRENT_REVISION):
 
623
    def annotate_iter(self, path, default_revision=CURRENT_REVISION):
625
624
        """Return an iterator of revision_id, line tuples.
626
625
 
627
626
        For working trees (and mutable trees in general), the special
628
627
        revision_id 'current:' will be used for lines that are new in this
629
628
        tree, e.g. uncommitted changes.
630
 
        :param file_id: The file to produce an annotated version from
631
629
        :param default_revision: For lines that don't match a basis, mark them
632
630
            with this revision id. Not all implementations will make use of
633
631
            this value.
1149
1147
        kind = mode_kind(mode)
1150
1148
        ie = entry_factory[kind](file_id, name, parent_id)
1151
1149
        if kind == 'symlink':
1152
 
            ie.symlink_target = self.get_symlink_target(path, file_id)
 
1150
            ie.symlink_target = self.get_symlink_target(path)
1153
1151
        elif kind == 'tree-reference':
1154
 
            ie.reference_revision = self.get_reference_revision(path, file_id)
 
1152
            ie.reference_revision = self.get_reference_revision(path)
1155
1153
        else:
1156
1154
            try:
1157
 
                data = self.get_file_text(path, file_id)
 
1155
                data = self.get_file_text(path)
1158
1156
            except errors.NoSuchFile:
1159
1157
                data = None
1160
1158
            except IOError as e:
1204
1202
        self._versioned_dirs = None
1205
1203
        return count
1206
1204
 
1207
 
    def unversion(self, paths, file_ids=None):
 
1205
    def unversion(self, paths):
1208
1206
        with self.lock_tree_write():
1209
1207
            for path in paths:
1210
1208
                if self._unversion_path(path) == 0:
1375
1373
        else:
1376
1374
            return (kind, None, None, None)
1377
1375
 
1378
 
    def kind(self, relpath, file_id=None):
 
1376
    def kind(self, relpath):
1379
1377
        kind = osutils.file_kind(self.abspath(relpath))
1380
1378
        if kind == 'directory':
1381
1379
            (index, index_path) = self._lookup_index(relpath.encode('utf-8'))