/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

Pass mapping object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib import (
25
25
    deprecated_graph,
26
26
    errors,
27
 
    foreign,
28
27
    inventory,
29
28
    osutils,
30
29
    repository,
33
32
    urlutils,
34
33
    versionedfile,
35
34
    )
 
35
from bzrlib.foreign import (
 
36
        ForeignRevision,
 
37
        )
36
38
from bzrlib.transport import get_transport
37
39
 
38
40
from bzrlib.plugins.git.foreign import (
 
41
    ForeignRepository,
39
42
    versionedfiles,
40
43
    )
41
44
from bzrlib.plugins.git.mapping import default_mapping
42
45
 
43
46
 
44
 
class GitRepository(repository.Repository):
 
47
class GitRepository(ForeignRepository):
45
48
    """An adapter to git repositories for bzr."""
46
49
 
47
50
    _serializer = None
120
123
        git_commit_id = self.lookup_git_revid(revision_id, default_mapping)
121
124
        commit = self._git.commit(git_commit_id)
122
125
        # print "fetched revision:", git_commit_id
123
 
        revision = self._parse_rev(commit)
 
126
        revision = self._parse_rev(commit, default_mapping)
124
127
        return revision
125
128
 
126
129
    def has_revision(self, revision_id):
135
138
        return [self.get_revision(r) for r in revisions]
136
139
 
137
140
    @classmethod
138
 
    def _parse_rev(klass, commit):
 
141
    def _parse_rev(klass, commit, mapping):
139
142
        """Convert a git commit to a bzr revision.
140
143
 
141
144
        :return: a `bzrlib.revision.Revision` object.
142
145
        """
143
 
        rev = foreign.ForeignRevision(commit.id, default_mapping, default_mapping.revision_id_foreign_to_bzr(commit.id))
144
 
        rev.parent_ids = tuple([default_mapping.revision_id_foreign_to_bzr(p.id) for p in commit.parents])
145
 
        rev.inventory_sha1 = ""
 
146
        rev = ForeignRevision(commit.id, mapping, mapping.revision_id_foreign_to_bzr(commit.id))
 
147
        rev.parent_ids = tuple([mapping.revision_id_foreign_to_bzr(p.id) for p in commit.parents])
146
148
        rev.message = commit.message.decode("utf-8", "replace")
147
149
        rev.committer = str(commit.committer).decode("utf-8", "replace")
148
150
        rev.properties['author'] = str(commit.author).decode("utf-8", "replace")
201
203
 
202
204
    def _build_inventory(self, tree, ie, path):
203
205
        assert isinstance(path, str)
204
 
        for key in tree:
205
 
            b = tree.get(key)
 
206
        for b in tree.contents:
206
207
            basename = b.name.decode("utf-8")
207
208
            if path == "":
208
209
                child_path = b.name