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

Share more code between local and remote classes, support opening remote branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    _serializer = None
63
63
 
64
64
    def __init__(self, gitdir, lockfiles):
 
65
        ForeignRepository.__init__(self, GitFormat(), gitdir, lockfiles)
 
66
        from bzrlib.plugins.git import fetch
 
67
        repository.InterRepository.register_optimiser(fetch.InterFromGitRepository)
 
68
 
 
69
    def is_shared(self):
 
70
        return True
 
71
 
 
72
    def supports_rich_root(self):
 
73
        return True
 
74
 
 
75
    def _warn_if_deprecated(self):
 
76
        # This class isn't deprecated
 
77
        pass
 
78
 
 
79
    def get_mapping(self):
 
80
        return default_mapping
 
81
 
 
82
 
 
83
 
 
84
class LocalGitRepository(GitRepository):
 
85
 
 
86
    def __init__(self, gitdir, lockfiles):
65
87
        # FIXME: This also caches negatives. Need to be more careful 
66
88
        # about this once we start writing to git
67
89
        self._parents_provider = graph.CachingParentsProvider(self)
68
 
        ForeignRepository.__init__(self, GitFormat(), gitdir, lockfiles)
 
90
        GitRepository.__init__(self, gitdir, lockfiles)
69
91
        self.base = gitdir.root_transport.base
70
 
        self.bzrdir = gitdir
71
92
        self._git = gitdir._git
72
93
        self.texts = None
73
94
        self.signatures = versionedfiles.VirtualSignatureTexts(self)
74
95
        self.revisions = versionedfiles.VirtualRevisionTexts(self)
75
96
        self.tags = GitTags(self._git.get_tags())
76
 
        from bzrlib.plugins.git import fetch
77
 
        repository.InterRepository.register_optimiser(fetch.InterFromGitRepository)
78
97
 
79
98
    def all_revision_ids(self):
80
99
        ret = set([revision.NULL_REVISION])
87
106
            ret.add(rev)
88
107
        return ret
89
108
 
90
 
    def is_shared(self):
91
 
        return True
92
 
 
93
 
    def supports_rich_root(self):
94
 
        return True
95
 
 
96
109
    #def get_revision_delta(self, revision_id):
97
110
    #    parent_revid = self.get_revision(revision_id).parent_ids[0]
98
111
    #    diff = self._git.diff(ids.convert_revision_id_bzr_to_git(parent_revid),
133
146
        ancestry.reverse()
134
147
        return ancestry
135
148
 
136
 
    def _warn_if_deprecated(self):
137
 
        # This class isn't deprecated
138
 
        pass
139
 
 
140
149
    def get_signature_text(self, revision_id):
141
150
        raise errors.NoSuchRevision(self, revision_id)
142
151
 
152
161
    def has_signature_for_revision_id(self, revision_id):
153
162
        return False
154
163
 
155
 
    def get_mapping(self):
156
 
        return default_mapping
157
 
 
158
164
    def lookup_git_revid(self, bzr_revid, mapping):
159
165
        try:
160
166
            return mapping.revision_id_bzr_to_foreign(bzr_revid)
254
260
 
255
261
    def _build_inventory(self, tree_id, ie, path):
256
262
        assert isinstance(path, str)
257
 
        tree = self._repository._git.get_tree(tree_id)
 
263
        tree = self._repository._git.tree(tree_id)
258
264
        for mode, name, hexsha in tree.entries():
259
265
            basename = name.decode("utf-8")
260
266
            if path == "":