/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

Move conversion functions to mapping, use fetch_objects() from repository if present.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from bzrlib.plugins.git.foreign import (
41
41
    versionedfiles,
42
42
    )
43
 
from bzrlib.plugins.git.mapping import default_mapping, mapping_registry, inventory_to_tree_and_blobs, revision_to_commit
 
43
from bzrlib.plugins.git.mapping import default_mapping, mapping_registry
44
44
from bzrlib.plugins.git.versionedfiles import GitTexts
45
45
 
46
46
import dulwich as git
154
154
        """Impor the gist of another revision into this Git repository.
155
155
 
156
156
        """
157
 
        objects = []
158
157
        rev = source.get_revision(revid)
159
 
        for sha, object, path in inventory_to_tree_and_blobs(source, None, revid):
160
 
            if path == "":
161
 
                tree_sha = sha
162
 
            objects.append((object, path))
163
 
        commit = revision_to_commit(rev, tree_sha, parent_lookup)
164
 
        objects.append((commit, None))
165
 
        self._git.object_store.add_objects(objects)
166
 
        return commit.sha().hexdigest()
 
158
        inventory_to_tree_and_blobs(source, None, revid)
 
159
        commit = revision_to_commit(rev, FIXME, parent_lookup)
 
160
        pass
167
161
 
168
162
    def dfetch(self, source, stop_revision):
169
163
        if stop_revision is None:
170
164
            raise NotImplementedError
171
165
        revidmap = {}
172
 
        gitidmap = {}
173
166
        todo = []
174
 
        source.lock_write()
 
167
        source.lock_read()
175
168
        try:
176
169
            graph = source.get_graph()
177
 
            ancestry = [x for x in source.get_ancestry(stop_revision) if x is not None]
178
 
            for revid in graph.iter_topo_order(ancestry):
 
170
            for revid, parents in graph.iter_ancestry([stop_revision]):
179
171
                if not self.has_revision(revid):
180
172
                    todo.append(revid)
181
173
            pb = ui.ui_factory.nested_progress_bar()
182
174
            try:
183
 
                for i, revid in enumerate(todo):
 
175
                for i, revid in enumerate(reversed(todo)):
184
176
                    pb.update("pushing revisions", i, len(todo))
185
 
                    git_commit = self.import_revision_gist(source, revid, gitidmap.__getitem__)
186
 
                    gitidmap[revid] = git_commit
187
 
                    git_revid = self.get_mapping().revision_id_foreign_to_bzr(git_commit)
188
 
                    revidmap[revid] = git_revid
 
177
                    revidmap[revid] = self.import_revision_gist(source, revid)
189
178
            finally:
190
179
                pb.finished()
191
 
            source.fetch(self, revision_id=revidmap[stop_revision])
192
180
        finally:
193
181
            source.unlock()
194
182
        return revidmap
257
245
    def set_make_working_trees(self, trees):
258
246
        pass
259
247
 
260
 
    def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref, progress=None):
 
248
    def fetch_objects(self, determine_wants, graph_walker, progress=None):
261
249
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
262
250
 
263
251