/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

Support converting git objects to bzr objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
        except KeyError:
177
177
            raise errors.NoSuchRevision(self, revision_id)
178
178
        # print "fetched revision:", git_commit_id
179
 
        revision = self._parse_rev(commit, self.get_mapping())
 
179
        revision = self.get_mapping().import_commit(commit)
180
180
        assert revision is not None
181
181
        return revision
182
182
 
191
191
    def get_revisions(self, revids):
192
192
        return [self.get_revision(r) for r in revids]
193
193
 
194
 
    @classmethod
195
 
    def _parse_rev(klass, commit, mapping):
196
 
        """Convert a git commit to a bzr revision.
197
 
 
198
 
        :return: a `bzrlib.revision.Revision` object.
199
 
        """
200
 
        if commit is None:
201
 
            raise AssertionError("Commit object can't be None")
202
 
        rev = ForeignRevision(commit.id, mapping, mapping.revision_id_foreign_to_bzr(commit.id))
203
 
        rev.parent_ids = tuple([mapping.revision_id_foreign_to_bzr(p) for p in commit.parents])
204
 
        rev.message = commit.message.decode("utf-8", "replace")
205
 
        rev.committer = str(commit.committer).decode("utf-8", "replace")
206
 
        if commit.committer != commit.author:
207
 
            rev.properties['author'] = str(commit.author).decode("utf-8", "replace")
208
 
        rev.timestamp = commit.commit_time
209
 
        rev.timezone = 0
210
 
        return rev
211
 
 
212
194
    def revision_trees(self, revids):
213
195
        for revid in revids:
214
196
            yield self.revision_tree(revid)