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

Merge thin-pack work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        GitRepository, 
27
27
        GitFormat,
28
28
        )
29
 
from bzrlib.plugins.git.converter import GitObjectConverter
 
29
from bzrlib.plugins.git.shamap import GitObjectConverter
30
30
from bzrlib.plugins.git.remote import RemoteGitRepository
31
31
 
32
32
import dulwich as git
75
75
        return None
76
76
 
77
77
 
78
 
def import_git_blob(repo, mapping, path, blob, inv, parent_invs, gitmap, executable):
 
78
def import_git_blob(repo, mapping, path, blob, inv, parent_invs, executable):
79
79
    """Import a git blob object into a bzr repository.
80
80
 
81
81
    :param repo: bzr repository
92
92
    ie.text_size = len(blob.data)
93
93
    ie.text_sha1 = osutils.sha_string(blob.data)
94
94
    ie.executable = executable
95
 
    gitmap._idmap.add_entry(blob.sha().hexdigest(), "blob", (ie.file_id, ie.revision))
96
 
 
97
 
 
98
 
def import_git_tree(repo, mapping, path, tree, inv, parent_invs, 
99
 
                    gitmap, lookup_object):
 
95
 
 
96
 
 
97
def import_git_tree(repo, mapping, path, tree, inv, parent_invs, lookup_object):
100
98
    """Import a git tree object into a bzr repository.
101
99
 
102
100
    :param repo: A Bzr repository object
111
109
        [])
112
110
    ie = inv.add_path(path, "directory", file_id)
113
111
    ie.revision = text_revision
114
 
    gitmap._idmap.add_entry(tree.sha().hexdigest(), "tree", (file_id, text_revision))
115
112
    for mode, name, hexsha in tree.entries():
116
113
        entry_kind = (mode & 0700000) / 0100000
117
114
        basename = name.decode("utf-8")
121
118
            child_path = urlutils.join(path, name)
122
119
        if entry_kind == 0:
123
120
            tree = lookup_object(hexsha)
124
 
            import_git_tree(repo, mapping, child_path, tree, inv, parent_invs, gitmap, lookup_object)
 
121
            import_git_tree(repo, mapping, child_path, tree, inv, parent_invs, lookup_object)
125
122
        elif entry_kind == 1:
126
123
            blob = lookup_object(hexsha)
127
124
            fs_mode = mode & 0777
128
 
            import_git_blob(repo, mapping, child_path, blob, inv, parent_invs, gitmap, bool(fs_mode & 0111))
 
125
            import_git_blob(repo, mapping, child_path, blob, inv, parent_invs, bool(fs_mode & 0111))
129
126
        else:
130
127
            raise AssertionError("Unknown blob kind, perms=%r." % (mode,))
131
128
 
149
146
            root_trees[rev.revision_id] = object_iter[o.tree]
150
147
            revisions[rev.revision_id] = rev
151
148
            graph.append((rev.revision_id, rev.parent_ids))
152
 
            target_git_object_retriever._idmap.add_entry(o.sha().hexdigest(), "commit", (rev.revision_id, o._tree))
153
149
    # Order the revisions
154
150
    # Create the inventory objects
155
151
    for i, revid in enumerate(topo_sort(graph)):
165
161
        def lookup_object(sha):
166
162
            if sha in object_iter:
167
163
                return object_iter[sha]
168
 
            return target_git_object_retriever[sha]
 
164
            return target_git_object_retriever(sha)
169
165
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
170
166
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
171
 
            target_git_object_retriever, lookup_object)
 
167
            lookup_object)
172
168
        repo.add_revision(rev.revision_id, rev, inv)
173
169
 
174
170
 
 
171
def reconstruct_git_object(repo, mapping, sha):
 
172
    import pdb; pdb.set_trace()
 
173
 
 
174
    # TODO: Tree
 
175
    # TODO: Blob
 
176
    raise KeyError("No such object %s" % sha)
 
177
 
 
178
 
175
179
class InterGitNonGitRepository(InterRepository):
176
180
 
177
181
    _matching_repo_format = GitFormat()