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

  • Committer: Jelmer Vernooij
  • Date: 2018-03-25 02:05:47 UTC
  • mto: (0.200.1934 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180325020547-suypsuhxtk84hoxr
Fix tree_content_summary test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    Tree,
50
50
    S_IFGITLINK,
51
51
    S_ISGITLINK,
52
 
    )
53
 
from dulwich.repo import Repo
 
52
    ZERO_SHA,
 
53
    )
 
54
from dulwich.repo import (
 
55
    NotGitRepository,
 
56
    Repo as GitRepo,
 
57
    )
54
58
import os
55
59
import posixpath
56
60
import re
698
702
        dir_ids = {}
699
703
        fk_entries = {'directory': tree.TreeDirectory,
700
704
                      'file': tree.TreeFile,
701
 
                      'symlink': tree.TreeLink}
 
705
                      'symlink': tree.TreeLink,
 
706
                      'tree-reference': tree.TreeNested}
702
707
        with self.lock_read():
703
708
            root_ie = self._get_dir_ie(u"", None)
704
709
            if include_root and not from_dir:
721
726
                    value = index[index_path]
722
727
                except KeyError:
723
728
                    value = None
724
 
                kind = osutils.file_kind(self.abspath(path))
 
729
                kind = self.kind(path)
725
730
                parent, name = posixpath.split(path)
726
731
                for dir_path, dir_ie in self._add_missing_parent_ids(parent, dir_ids):
727
732
                    pass
728
 
                if kind == 'directory':
 
733
                if kind in ('directory', 'tree-reference'):
729
734
                    if path != from_dir:
730
735
                        if self._has_dir(path):
731
736
                            ie = self._get_dir_ie(path, self.path2id(path))
776
781
                    paths.add(path)
777
782
            return paths
778
783
 
779
 
    def _directory_is_tree_reference(self, path):
780
 
        # FIXME: Check .gitsubmodules for path
781
 
        return False
782
 
 
783
784
    def iter_child_entries(self, path, file_id=None):
784
785
        encoded_path = path.encode('utf-8')
785
786
        with self.lock_read():
1135
1136
                                show_base=show_base)
1136
1137
            return count
1137
1138
 
 
1139
    def _read_submodule_head(self, path):
 
1140
        try:
 
1141
            return GitRepo(path).head()
 
1142
        except NotGitRepository:
 
1143
            return ZERO_SHA
 
1144
 
1138
1145
    def add_reference(self, sub_tree):
1139
1146
        """Add a TreeReference to the tree, pointing at sub_tree.
1140
1147
 
1149
1156
 
1150
1157
            self._add([sub_tree_path], [None], ['tree-reference'])
1151
1158
 
 
1159
    def get_reference_revision(self, path, file_id=None):
 
1160
        hexsha = self._read_submodule_head(path)
 
1161
        return self.branch.lookup_foreign_revision_id(hexsha)
 
1162
 
1152
1163
    def get_nested_tree(self, path, file_id=None):
1153
1164
        return workingtree.WorkingTree.open(self.abspath(path))
1154
1165
 
 
1166
    def _directory_is_tree_reference(self, relpath):
 
1167
        # as a special case, if a directory contains control files then
 
1168
        # it's a tree reference, except that the root of the tree is not
 
1169
        return relpath and osutils.lexists(self.abspath(relpath) + u"/.git")
 
1170
 
1155
1171
 
1156
1172
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):
1157
1173