/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

Simply refer to bzr's docs in HACKING.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    repository,
27
27
    revision,
28
28
    revisiontree,
29
 
    ui,
30
 
    urlutils,
31
29
    )
32
30
from bzrlib.foreign import (
33
31
    ForeignRepository,
34
32
    )
35
 
from bzrlib.trace import (
36
 
    mutter,
37
 
    )
38
 
from bzrlib.transport import (
39
 
    get_transport,
40
 
    )
41
33
 
42
34
from bzrlib.plugins.git.commit import (
43
35
    GitCommitBuilder,
44
36
    )
45
 
from bzrlib.plugins.git.inventory import (
46
 
    GitInventory,
47
 
    )
48
37
from bzrlib.plugins.git.mapping import (
49
38
    default_mapping,
50
39
    foreign_git,
51
40
    mapping_registry,
52
41
    )
 
42
from bzrlib.plugins.git.tree import (
 
43
    GitRevisionTree,
 
44
    InterGitRevisionTrees,
 
45
    )
53
46
from bzrlib.plugins.git.versionedfiles import (
54
47
    GitRevisions,
55
48
    GitTexts,
142
135
                parent_map[revision_id] = ()
143
136
                continue
144
137
            hexsha, mapping = self.lookup_git_revid(revision_id)
145
 
            commit  = self._git.commit(hexsha)
 
138
            try:
 
139
                commit = self._git.commit(hexsha)
 
140
            except KeyError:
 
141
                continue
146
142
            if commit is None:
 
143
                # Older versions of Dulwich used to return None rather than 
 
144
                # raise KeyError.
147
145
                continue
148
146
            else:
149
147
                parent_map[revision_id] = [mapping.revision_id_foreign_to_bzr(p) for p in commit.parents]
172
170
        :return: Tuple with git revisionid and mapping.
173
171
        """
174
172
        # Yes, this doesn't really work, but good enough as a stub
175
 
        return osutils.sha(rev_id).hexdigest(), self.get_mapping()
 
173
        return osutils.sha(revid).hexdigest(), self.get_mapping()
176
174
 
177
175
    def has_signature_for_revision_id(self, revision_id):
178
176
        return False
229
227
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
230
228
 
231
229
 
232
 
class GitRevisionTree(revisiontree.RevisionTree):
233
 
 
234
 
    def __init__(self, repository, revision_id):
235
 
        self._revision_id = revision_id
236
 
        self._repository = repository
237
 
        store = repository._git.object_store
238
 
        assert isinstance(revision_id, str)
239
 
        git_id, self.mapping = repository.lookup_git_revid(revision_id)
240
 
        try:
241
 
            commit = store[git_id]
242
 
        except KeyError, r:
243
 
            raise errors.NoSuchRevision(repository, revision_id)
244
 
        self.tree = commit.tree
245
 
        self._inventory = GitInventory(self.tree, self.mapping, store, 
246
 
                                       revision_id)
247
 
 
248
 
    def get_revision_id(self):
249
 
        return self._revision_id
250
 
 
251
 
    def get_file_text(self, file_id, path=None):
252
 
        if path is not None:
253
 
            entry = self._inventory._get_ie(path)
254
 
        else:
255
 
            entry = self._inventory[file_id]
256
 
        if entry.kind == 'directory': return ""
257
 
        return entry.object.data
258
 
 
259
 
 
260
230
class GitRepositoryFormat(repository.RepositoryFormat):
261
231
    """Git repository format."""
262
232
 
267
237
        return "Git Repository"
268
238
 
269
239
    def initialize(self, url, shared=False, _internal=False):
270
 
        raise bzr_errors.UninitializableFormat(self)
 
240
        raise errors.UninitializableFormat(self)
271
241
 
272
242
    def check_conversion_target(self, target_repo_format):
273
243
        return target_repo_format.rich_root_data