/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

Partially fix pull.

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.shamap import GitObjectConverter
 
29
from bzrlib.plugins.git.converter 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, executable):
 
78
def import_git_blob(repo, mapping, path, blob, inv, parent_invs, gitmap, 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
 
 
96
 
 
97
 
def import_git_tree(repo, mapping, path, tree, inv, parent_invs, lookup_object):
 
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):
98
100
    """Import a git tree object into a bzr repository.
99
101
 
100
102
    :param repo: A Bzr repository object
109
111
        [])
110
112
    ie = inv.add_path(path, "directory", file_id)
111
113
    ie.revision = text_revision
 
114
    gitmap._idmap.add_entry(tree.sha().hexdigest(), "tree", (file_id, text_revision))
112
115
    for mode, name, hexsha in tree.entries():
113
116
        entry_kind = (mode & 0700000) / 0100000
114
117
        basename = name.decode("utf-8")
118
121
            child_path = urlutils.join(path, name)
119
122
        if entry_kind == 0:
120
123
            tree = lookup_object(hexsha)
121
 
            import_git_tree(repo, mapping, child_path, tree, inv, parent_invs, lookup_object)
 
124
            import_git_tree(repo, mapping, child_path, tree, inv, parent_invs, gitmap, lookup_object)
122
125
        elif entry_kind == 1:
123
126
            blob = lookup_object(hexsha)
124
127
            fs_mode = mode & 0777
125
 
            import_git_blob(repo, mapping, child_path, blob, inv, parent_invs, bool(fs_mode & 0111))
 
128
            import_git_blob(repo, mapping, child_path, blob, inv, parent_invs, gitmap, bool(fs_mode & 0111))
126
129
        else:
127
130
            raise AssertionError("Unknown blob kind, perms=%r." % (mode,))
128
131
 
146
149
            root_trees[rev.revision_id] = object_iter[o.tree]
147
150
            revisions[rev.revision_id] = rev
148
151
            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))
149
153
    # Order the revisions
150
154
    # Create the inventory objects
151
155
    for i, revid in enumerate(topo_sort(graph)):
161
165
        def lookup_object(sha):
162
166
            if sha in object_iter:
163
167
                return object_iter[sha]
164
 
            return target_git_object_retriever(sha)
 
168
            return target_git_object_retriever[sha]
165
169
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
166
170
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
167
 
            lookup_object)
 
171
            target_git_object_retriever, lookup_object)
168
172
        repo.add_revision(rev.revision_id, rev, inv)
169
173
 
170
174
 
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
 
 
179
175
class InterGitNonGitRepository(InterRepository):
180
176
 
181
177
    _matching_repo_format = GitFormat()