/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
1
# Copyright (C) 2007 Canonical Ltd
0.200.252 by Jelmer Vernooij
Clarify history, copyright.
2
# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
"""An adapter between a Git Repository and a Bazaar Branch"""
19
0.200.45 by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers.
20
import bzrlib
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
21
from bzrlib import (
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
22
    errors,
0.200.132 by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer.
23
    graph,
0.200.38 by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster.
24
    inventory,
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
25
    osutils,
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
26
    repository,
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
27
    revision,
0.200.39 by David Allouche
Black-box text for "bzr log" in a git tree. Further simplification of GitRevisionTree.
28
    revisiontree,
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
29
    ui,
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
30
    urlutils,
31
    )
0.200.115 by Jelmer Vernooij
Pass mapping object.
32
from bzrlib.foreign import (
0.200.136 by Jelmer Vernooij
Merge new bzr-foreign.
33
        ForeignRepository,
0.200.115 by Jelmer Vernooij
Pass mapping object.
34
        )
0.200.132 by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer.
35
from bzrlib.trace import mutter
0.200.45 by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers.
36
from bzrlib.transport import get_transport
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
37
0.209.1 by Ali Sabil
Fixed wrong import for versionedfiles in repository.py
38
from bzrlib.plugins.git.foreign import (
0.208.5 by Jelmer Vernooij
Add log show function for git.
39
    versionedfiles,
0.200.20 by John Arbash Meinel
All tests are passing again
40
    )
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
41
from bzrlib.plugins.git.mapping import (
42
    default_mapping,
43
    inventory_to_tree_and_blobs,
44
    mapping_registry,
45
    revision_to_commit,
46
    )
0.200.208 by Jelmer Vernooij
Add dummy Repository.texts.
47
from bzrlib.plugins.git.versionedfiles import GitTexts
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
48
0.200.289 by Jelmer Vernooij
Cope with new member variables in RepositoryFormat.
49
import dulwich as git
50
import os
51
import time
52
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
53
0.200.120 by Jelmer Vernooij
Use API closer to that of python-git.
54
class GitTags(object):
55
56
    def __init__(self, tags):
57
        self._tags = tags
58
59
    def __iter__(self):
60
        return iter(self._tags)
61
62
0.200.115 by Jelmer Vernooij
Pass mapping object.
63
class GitRepository(ForeignRepository):
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
64
    """An adapter to git repositories for bzr."""
65
0.200.41 by David Allouche
Define _serializer = None in GitRepository.
66
    _serializer = None
67
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
68
    def __init__(self, gitdir, lockfiles):
0.200.289 by Jelmer Vernooij
Cope with new member variables in RepositoryFormat.
69
        ForeignRepository.__init__(self, GitRepositoryFormat(), gitdir, 
70
            lockfiles)
0.200.143 by Jelmer Vernooij
Reoncile InterGitRepository objects.
71
        from bzrlib.plugins.git import fetch
0.200.276 by Jelmer Vernooij
Improve formatting.
72
        for optimiser in [fetch.InterGitRepository, 
73
                          fetch.InterGitNonGitRepository]:
74
            repository.InterRepository.register_optimiser(optimiser)
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
75
76
    def is_shared(self):
77
        return True
78
79
    def supports_rich_root(self):
80
        return True
81
82
    def _warn_if_deprecated(self):
83
        # This class isn't deprecated
84
        pass
85
86
    def get_mapping(self):
87
        return default_mapping
88
0.200.147 by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though.
89
    def make_working_trees(self):
90
        return True
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
91
92
93
class LocalGitRepository(GitRepository):
0.200.276 by Jelmer Vernooij
Improve formatting.
94
    """Git repository on the file system."""
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
95
96
    def __init__(self, gitdir, lockfiles):
0.200.132 by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer.
97
        # FIXME: This also caches negatives. Need to be more careful 
98
        # about this once we start writing to git
99
        self._parents_provider = graph.CachingParentsProvider(self)
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
100
        GitRepository.__init__(self, gitdir, lockfiles)
0.200.61 by Jelmer Vernooij
Fix tests.
101
        self.base = gitdir.root_transport.base
0.200.90 by Jelmer Vernooij
Basic support for opening working trees.
102
        self._git = gitdir._git
0.200.56 by Jelmer Vernooij
Switch to using GitPython rather than our own in-house stuff.
103
        self.texts = None
0.200.92 by Jelmer Vernooij
Update versionedfiles.
104
        self.signatures = versionedfiles.VirtualSignatureTexts(self)
105
        self.revisions = versionedfiles.VirtualRevisionTexts(self)
0.200.207 by Jelmer Vernooij
Provide Repository.inventories.
106
        self.inventories = versionedfiles.VirtualInventoryTexts(self)
0.200.209 by Jelmer Vernooij
Pass repository object to versionedfiles.
107
        self.texts = GitTexts(self)
0.200.120 by Jelmer Vernooij
Use API closer to that of python-git.
108
        self.tags = GitTags(self._git.get_tags())
0.200.45 by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers.
109
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
110
    def all_revision_ids(self):
111
        ret = set([revision.NULL_REVISION])
0.200.254 by Jelmer Vernooij
Fix tests.
112
        heads = self._git.heads()
113
        if heads == {}:
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
114
            return ret
0.200.254 by Jelmer Vernooij
Fix tests.
115
        bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in heads.itervalues()]
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
116
        ret = set(bzr_heads)
117
        graph = self.get_graph()
118
        for rev, parents in graph.iter_ancestry(bzr_heads):
119
            ret.add(rev)
0.200.74 by Jelmer Vernooij
Implement Repository.all_revision_ids().
120
        return ret
121
0.200.82 by Jelmer Vernooij
Support listing tags.
122
    #def get_revision_delta(self, revision_id):
123
    #    parent_revid = self.get_revision(revision_id).parent_ids[0]
124
    #    diff = self._git.diff(ids.convert_revision_id_bzr_to_git(parent_revid),
125
    #                   ids.convert_revision_id_bzr_to_git(revision_id))
126
0.200.132 by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer.
127
    def _make_parents_provider(self):
128
        """See Repository._make_parents_provider()."""
129
        return self._parents_provider
130
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
131
    def get_parent_map(self, revids):
132
        parent_map = {}
0.200.132 by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer.
133
        mutter("get_parent_map(%r)", revids)
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
134
        for revision_id in revids:
135
            assert isinstance(revision_id, str)
136
            if revision_id == revision.NULL_REVISION:
137
                parent_map[revision_id] = ()
138
                continue
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
139
            hexsha, mapping = self.lookup_git_revid(revision_id)
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
140
            commit  = self._git.commit(hexsha)
141
            if commit is None:
142
                continue
143
            else:
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
144
                parent_map[revision_id] = [mapping.revision_id_foreign_to_bzr(p) for p in commit.parents]
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
145
        return parent_map
146
147
    def get_ancestry(self, revision_id, topo_sorted=True):
148
        """See Repository.get_ancestry().
149
        """
150
        if revision_id is None:
0.200.237 by Jelmer Vernooij
Fix get_ancestry() contents.
151
            return [None, revision.NULL_REVISION] + self._all_revision_ids()
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
152
        assert isinstance(revision_id, str)
153
        ancestry = []
154
        graph = self.get_graph()
155
        for rev, parents in graph.iter_ancestry([revision_id]):
156
            ancestry.append(rev)
157
        ancestry.reverse()
0.200.237 by Jelmer Vernooij
Fix get_ancestry() contents.
158
        return [None] + ancestry
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
159
0.200.212 by Jelmer Vernooij
Move conversion functions to mapping, use fetch_objects() from repository if present.
160
    def import_revision_gist(self, source, revid, parent_lookup):
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
161
        """Import the gist of a revision into this Git repository.
0.200.212 by Jelmer Vernooij
Move conversion functions to mapping, use fetch_objects() from repository if present.
162
163
        """
0.200.213 by Jelmer Vernooij
Move functions to mapping.
164
        objects = []
0.200.212 by Jelmer Vernooij
Move conversion functions to mapping, use fetch_objects() from repository if present.
165
        rev = source.get_revision(revid)
0.200.213 by Jelmer Vernooij
Move functions to mapping.
166
        for sha, object, path in inventory_to_tree_and_blobs(source, None, revid):
167
            if path == "":
168
                tree_sha = sha
0.200.221 by Jelmer Vernooij
Add FOSDEM roundtripping notes.
169
            objects.append((object, path))
0.200.213 by Jelmer Vernooij
Move functions to mapping.
170
        commit = revision_to_commit(rev, tree_sha, parent_lookup)
0.200.221 by Jelmer Vernooij
Add FOSDEM roundtripping notes.
171
        objects.append((commit, None))
172
        self._git.object_store.add_objects(objects)
0.200.222 by Jelmer Vernooij
Dpush works \o/
173
        return commit.sha().hexdigest()
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
174
175
    def dfetch(self, source, stop_revision):
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
176
        """Import the gist of the ancestry of a particular revision."""
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
177
        if stop_revision is None:
178
            raise NotImplementedError
179
        revidmap = {}
0.200.222 by Jelmer Vernooij
Dpush works \o/
180
        gitidmap = {}
0.200.282 by Jelmer Vernooij
Support dpushing with existing parents.
181
        def parent_lookup(revid):
182
            try:
183
                return gitidmap[revid]
184
            except KeyError:
185
                return self.lookup_git_revid(revid)[0]
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
186
        todo = []
0.200.222 by Jelmer Vernooij
Dpush works \o/
187
        source.lock_write()
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
188
        try:
189
            graph = source.get_graph()
0.200.222 by Jelmer Vernooij
Dpush works \o/
190
            ancestry = [x for x in source.get_ancestry(stop_revision) if x is not None]
191
            for revid in graph.iter_topo_order(ancestry):
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
192
                if not self.has_revision(revid):
193
                    todo.append(revid)
194
            pb = ui.ui_factory.nested_progress_bar()
195
            try:
0.200.222 by Jelmer Vernooij
Dpush works \o/
196
                for i, revid in enumerate(todo):
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
197
                    pb.update("pushing revisions", i, len(todo))
0.200.276 by Jelmer Vernooij
Improve formatting.
198
                    git_commit = self.import_revision_gist(source, revid,
0.200.282 by Jelmer Vernooij
Support dpushing with existing parents.
199
                        parent_lookup)
0.200.222 by Jelmer Vernooij
Dpush works \o/
200
                    gitidmap[revid] = git_commit
0.200.276 by Jelmer Vernooij
Improve formatting.
201
                    git_revid = self.get_mapping().revision_id_foreign_to_bzr(
202
                        git_commit)
0.200.222 by Jelmer Vernooij
Dpush works \o/
203
                    revidmap[revid] = git_revid
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
204
            finally:
205
                pb.finished()
0.200.222 by Jelmer Vernooij
Dpush works \o/
206
            source.fetch(self, revision_id=revidmap[stop_revision])
0.200.211 by Jelmer Vernooij
Add basic infrastructure for dpush.
207
        finally:
208
            source.unlock()
209
        return revidmap
210
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
211
    def get_signature_text(self, revision_id):
212
        raise errors.NoSuchRevision(self, revision_id)
213
0.200.124 by Jelmer Vernooij
Add lookup_revision_id stub.
214
    def lookup_revision_id(self, revid):
215
        """Lookup a revision id.
216
        
217
        :param revid: Bazaar revision id.
218
        :return: Tuple with git revisionid and mapping.
219
        """
220
        # Yes, this doesn't really work, but good enough as a stub
221
        return osutils.sha(rev_id).hexdigest(), self.get_mapping()
222
0.200.60 by Jelmer Vernooij
Support signature functions.
223
    def has_signature_for_revision_id(self, revision_id):
224
        return False
225
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
226
    def lookup_git_revid(self, bzr_revid):
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
227
        try:
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
228
            return mapping_registry.revision_id_bzr_to_foreign(bzr_revid)
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
229
        except errors.InvalidRevisionId:
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
230
            raise errors.NoSuchRevision(self, bzr_revid)
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
231
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
232
    def get_revision(self, revision_id):
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
233
        git_commit_id, mapping = self.lookup_git_revid(revision_id)
0.200.147 by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though.
234
        try:
235
            commit = self._git.commit(git_commit_id)
236
        except KeyError:
237
            raise errors.NoSuchRevision(self, revision_id)
0.204.5 by James Westby
Lose the debuggin prints.
238
        # print "fetched revision:", git_commit_id
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
239
        revision = mapping.import_commit(commit)
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
240
        assert revision is not None
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
241
        return revision
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
242
243
    def has_revision(self, revision_id):
244
        try:
245
            self.get_revision(revision_id)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
246
        except errors.NoSuchRevision:
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
247
            return False
248
        else:
249
            return True
250
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
251
    def get_revisions(self, revids):
0.200.134 by Jelmer Vernooij
Fix get_revisions().
252
        return [self.get_revision(r) for r in revids]
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
253
254
    def revision_trees(self, revids):
255
        for revid in revids:
256
            yield self.revision_tree(revid)
257
258
    def revision_tree(self, revision_id):
0.200.57 by Jelmer Vernooij
Fix more tests.
259
        revision_id = revision.ensure_null(revision_id)
260
        if revision_id == revision.NULL_REVISION:
261
            inv = inventory.Inventory(root_id=None)
262
            inv.revision_id = revision_id
263
            return revisiontree.RevisionTree(self, inv, revision_id)
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
264
        return GitRevisionTree(self, revision_id)
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
265
266
    def get_inventory(self, revision_id):
0.200.57 by Jelmer Vernooij
Fix more tests.
267
        assert revision_id != None
268
        return self.revision_tree(revision_id).inventory
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
269
0.200.108 by Jelmer Vernooij
Support bzr init --git.
270
    def set_make_working_trees(self, trees):
271
        pass
272
0.200.276 by Jelmer Vernooij
Improve formatting.
273
    def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
274
        progress=None):
0.200.146 by Jelmer Vernooij
Merge dulwich.
275
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
0.200.138 by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories.
276
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
277
0.200.39 by David Allouche
Black-box text for "bzr log" in a git tree. Further simplification of GitRevisionTree.
278
class GitRevisionTree(revisiontree.RevisionTree):
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
279
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
280
    def __init__(self, repository, revision_id):
0.200.39 by David Allouche
Black-box text for "bzr log" in a git tree. Further simplification of GitRevisionTree.
281
        self._repository = repository
0.200.58 by Jelmer Vernooij
Fix remaining tests.
282
        self.revision_id = revision_id
0.200.149 by Jelmer Vernooij
Raise proper NoSuchRevision exception.
283
        assert isinstance(revision_id, str)
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
284
        git_id, self.mapping = repository.lookup_git_revid(revision_id)
0.200.149 by Jelmer Vernooij
Raise proper NoSuchRevision exception.
285
        try:
0.200.153 by Jelmer Vernooij
Merge new dulwich.
286
            commit = repository._git.commit(git_id)
287
        except KeyError, r:
0.200.149 by Jelmer Vernooij
Raise proper NoSuchRevision exception.
288
            raise errors.NoSuchRevision(repository, revision_id)
0.200.153 by Jelmer Vernooij
Merge new dulwich.
289
        self.tree = commit.tree
0.200.58 by Jelmer Vernooij
Fix remaining tests.
290
        self._inventory = inventory.Inventory(revision_id=revision_id)
291
        self._inventory.root.revision = revision_id
292
        self._build_inventory(self.tree, self._inventory.root, "")
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
293
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
294
    def get_revision_id(self):
295
        return self.revision_id
296
0.200.87 by Jelmer Vernooij
Remove cache usage.
297
    def get_file_text(self, file_id):
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
298
        entry = self._inventory[file_id]
0.200.87 by Jelmer Vernooij
Remove cache usage.
299
        if entry.kind == 'directory': return ""
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
300
        return self._repository._git.get_blob(entry.text_id).data
0.203.1 by Aaron Bentley
Make checkouts work
301
0.200.129 by Jelmer Vernooij
merge dulwich.
302
    def _build_inventory(self, tree_id, ie, path):
0.200.58 by Jelmer Vernooij
Fix remaining tests.
303
        assert isinstance(path, str)
0.216.3 by Jelmer Vernooij
Fix tree.
304
        tree = self._repository._git.tree(tree_id)
0.200.129 by Jelmer Vernooij
merge dulwich.
305
        for mode, name, hexsha in tree.entries():
0.200.128 by Jelmer Vernooij
Merge new dulwich.
306
            basename = name.decode("utf-8")
0.200.58 by Jelmer Vernooij
Fix remaining tests.
307
            if path == "":
0.200.128 by Jelmer Vernooij
Merge new dulwich.
308
                child_path = name
0.200.58 by Jelmer Vernooij
Fix remaining tests.
309
            else:
0.200.128 by Jelmer Vernooij
Merge new dulwich.
310
                child_path = urlutils.join(path, name)
0.200.152 by Jelmer Vernooij
Fix syntax errors.
311
            file_id = self.mapping.generate_file_id(child_path)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
312
            entry_kind = (mode & 0700000) / 0100000
313
            if entry_kind == 0:
0.200.58 by Jelmer Vernooij
Fix remaining tests.
314
                child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
315
            elif entry_kind == 1:
316
                file_kind = (mode & 070000) / 010000
317
                b = self._repository._git.get_blob(hexsha)
318
                if file_kind == 0:
0.200.58 by Jelmer Vernooij
Fix remaining tests.
319
                    child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
320
                    child_ie.text_sha1 = osutils.sha_string(b.data)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
321
                elif file_kind == 2:
0.200.58 by Jelmer Vernooij
Fix remaining tests.
322
                    child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
323
                    child_ie.text_sha1 = osutils.sha_string("")
324
                else:
325
                    raise AssertionError(
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
326
                        "Unknown file kind, perms=%o." % (mode,))
0.200.88 by Jelmer Vernooij
Fix RevisionTree.get_file_text().
327
                child_ie.text_id = b.id
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
328
                child_ie.text_size = len(b.data)
0.200.58 by Jelmer Vernooij
Fix remaining tests.
329
            else:
330
                raise AssertionError(
0.200.128 by Jelmer Vernooij
Merge new dulwich.
331
                    "Unknown blob kind, perms=%r." % (mode,))
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
332
            fs_mode = mode & 0777
333
            child_ie.executable = bool(fs_mode & 0111)
0.200.58 by Jelmer Vernooij
Fix remaining tests.
334
            child_ie.revision = self.revision_id
0.200.88 by Jelmer Vernooij
Fix RevisionTree.get_file_text().
335
            self._inventory.add(child_ie)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
336
            if entry_kind == 0:
337
                self._build_inventory(hexsha, child_ie, child_path)
0.200.58 by Jelmer Vernooij
Fix remaining tests.
338
0.203.1 by Aaron Bentley
Make checkouts work
339
0.200.289 by Jelmer Vernooij
Cope with new member variables in RepositoryFormat.
340
class GitRepositoryFormat(repository.RepositoryFormat):
0.203.1 by Aaron Bentley
Make checkouts work
341
342
    supports_tree_reference = False
0.200.133 by Jelmer Vernooij
Unmark as deprecated.
343
    rich_root_data = True
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
344
345
    def get_format_description(self):
346
        return "Git Repository"
0.200.133 by Jelmer Vernooij
Unmark as deprecated.
347
348
    def initialize(self, url, shared=False, _internal=False):
349
        raise bzr_errors.UninitializableFormat(self)
350
351
    def check_conversion_target(self, target_repo_format):
352
        return target_repo_format.rich_root_data