/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-10-29 11:27:33 UTC
  • mto: This revision was merged to the branch mainline in revision 7170.
  • Revision ID: jelmer@jelmer.uk-20181029112733-bjvm24z12svwl53m
Get rid of file_ids in most of Tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
278
278
    def supports_rename_tracking(self):
279
279
        return False
280
280
 
281
 
    def get_file_revision(self, path, file_id=None):
 
281
    def get_file_revision(self, path):
282
282
        change_scanner = self._repository._file_change_scanner
283
283
        if self.commit_id == ZERO_SHA:
284
284
            return NULL_REVISION
286
286
            path.encode('utf-8'), self.commit_id)
287
287
        return self._repository.lookup_foreign_revision_id(commit_id, self.mapping)
288
288
 
289
 
    def get_file_mtime(self, path, file_id=None):
 
289
    def get_file_mtime(self, path):
290
290
        try:
291
 
            revid = self.get_file_revision(path, file_id)
 
291
            revid = self.get_file_revision(path)
292
292
        except KeyError:
293
293
            raise errors.NoSuchFile(path)
294
294
        try:
364
364
        else:
365
365
            return (self.store, mode, hexsha)
366
366
 
367
 
    def is_executable(self, path, file_id=None):
 
367
    def is_executable(self, path):
368
368
        (store, mode, hexsha) = self._lookup_path(path)
369
369
        if mode is None:
370
370
            # the tree root is a directory
371
371
            return False
372
372
        return mode_is_executable(mode)
373
373
 
374
 
    def kind(self, path, file_id=None):
 
374
    def kind(self, path):
375
375
        (store, mode, hexsha) = self._lookup_path(path)
376
376
        if mode is None:
377
377
            # the tree root is a directory
516
516
        """See RevisionTree.get_revision_id."""
517
517
        return self._revision_id
518
518
 
519
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
 
519
    def get_file_sha1(self, path, stat_value=None):
520
520
        if self.tree is None:
521
521
            raise errors.NoSuchFile(path)
522
 
        return osutils.sha_string(self.get_file_text(path, file_id))
 
522
        return osutils.sha_string(self.get_file_text(path))
523
523
 
524
 
    def get_file_verifier(self, path, file_id=None, stat_value=None):
 
524
    def get_file_verifier(self, path, stat_value=None):
525
525
        (store, mode, hexsha) = self._lookup_path(path)
526
526
        return ("GIT", hexsha)
527
527
 
528
 
    def get_file_size(self, path, file_id=None):
 
528
    def get_file_size(self, path):
529
529
        (store, mode, hexsha) = self._lookup_path(path)
530
530
        if stat.S_ISREG(mode):
531
531
            return len(store[hexsha].data)
532
532
        return None
533
533
 
534
 
    def get_file_text(self, path, file_id=None):
 
534
    def get_file_text(self, path):
535
535
        """See RevisionTree.get_file_text."""
536
536
        (store, mode, hexsha) = self._lookup_path(path)
537
537
        if stat.S_ISREG(mode):
539
539
        else:
540
540
            return b""
541
541
 
542
 
    def get_symlink_target(self, path, file_id=None):
 
542
    def get_symlink_target(self, path):
543
543
        """See RevisionTree.get_symlink_target."""
544
544
        (store, mode, hexsha) = self._lookup_path(path)
545
545
        if stat.S_ISLNK(mode):
547
547
        else:
548
548
            return None
549
549
 
550
 
    def get_reference_revision(self, path, file_id=None):
 
550
    def get_reference_revision(self, path):
551
551
        """See RevisionTree.get_symlink_target."""
552
552
        (store, mode, hexsha) = self._lookup_path(path)
553
553
        if S_ISGITLINK(mode):
604
604
        return self.store.iter_tree_contents(
605
605
                self.tree, include_trees=include_trees)
606
606
 
607
 
    def annotate_iter(self, path, file_id=None,
608
 
                      default_revision=CURRENT_REVISION):
 
607
    def annotate_iter(self, path, default_revision=CURRENT_REVISION):
609
608
        """Return an iterator of revision_id, line tuples.
610
609
 
611
610
        For working trees (and mutable trees in general), the special
612
611
        revision_id 'current:' will be used for lines that are new in this
613
612
        tree, e.g. uncommitted changes.
614
 
        :param file_id: The file to produce an annotated version from
615
613
        :param default_revision: For lines that don't match a basis, mark them
616
614
            with this revision id. Not all implementations will make use of
617
615
            this value.
1115
1113
        kind = mode_kind(mode)
1116
1114
        ie = entry_factory[kind](file_id, name, parent_id)
1117
1115
        if kind == 'symlink':
1118
 
            ie.symlink_target = self.get_symlink_target(path, file_id)
 
1116
            ie.symlink_target = self.get_symlink_target(path)
1119
1117
        elif kind == 'tree-reference':
1120
 
            ie.reference_revision = self.get_reference_revision(path, file_id)
 
1118
            ie.reference_revision = self.get_reference_revision(path)
1121
1119
        else:
1122
1120
            try:
1123
 
                data = self.get_file_text(path, file_id)
 
1121
                data = self.get_file_text(path)
1124
1122
            except errors.NoSuchFile:
1125
1123
                data = None
1126
1124
            except IOError as e:
1170
1168
        self._versioned_dirs = None
1171
1169
        return count
1172
1170
 
1173
 
    def unversion(self, paths, file_ids=None):
 
1171
    def unversion(self, paths):
1174
1172
        with self.lock_tree_write():
1175
1173
            for path in paths:
1176
1174
                if self._unversion_path(path) == 0:
1336
1334
        else:
1337
1335
            return (kind, None, None, None)
1338
1336
 
1339
 
    def kind(self, relpath, file_id=None):
 
1337
    def kind(self, relpath):
1340
1338
        kind = osutils.file_kind(self.abspath(relpath))
1341
1339
        if kind == 'directory':
1342
1340
            (index, index_path) = self._lookup_index(relpath.encode('utf-8'))