/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.foreign import (
46
 
    versionedfiles,
47
 
    )
48
 
from bzrlib.plugins.git.inventory import (
49
 
    GitInventory,
50
 
    )
51
37
from bzrlib.plugins.git.mapping import (
52
38
    default_mapping,
53
39
    foreign_git,
54
40
    mapping_registry,
55
41
    )
 
42
from bzrlib.plugins.git.tree import (
 
43
    GitRevisionTree,
 
44
    InterGitRevisionTrees,
 
45
    )
56
46
from bzrlib.plugins.git.versionedfiles import (
 
47
    GitRevisions,
57
48
    GitTexts,
58
49
    )
59
50
 
92
83
    def make_working_trees(self):
93
84
        return True
94
85
 
 
86
    def revision_graph_can_have_wrong_parents(self):
 
87
        return False
 
88
 
95
89
    def dfetch(self, source, stop_revision):
96
90
        interrepo = repository.InterRepository.get(source, self)
97
91
        return interrepo.dfetch(stop_revision)
112
106
        self.base = gitdir.root_transport.base
113
107
        self._git = gitdir._git
114
108
        self.texts = None
115
 
        self.signatures = versionedfiles.VirtualSignatureTexts(self)
116
 
        self.revisions = versionedfiles.VirtualRevisionTexts(self)
117
 
        self.inventories = versionedfiles.VirtualInventoryTexts(self)
 
109
        self.signatures = None
 
110
        self.revisions = GitRevisions(self._git.object_store)
 
111
        self.inventories = None
118
112
        self.texts = GitTexts(self)
119
113
 
120
114
    def all_revision_ids(self):
141
135
                parent_map[revision_id] = ()
142
136
                continue
143
137
            hexsha, mapping = self.lookup_git_revid(revision_id)
144
 
            commit  = self._git.commit(hexsha)
 
138
            try:
 
139
                commit = self._git.commit(hexsha)
 
140
            except KeyError:
 
141
                continue
145
142
            if commit is None:
 
143
                # Older versions of Dulwich used to return None rather than 
 
144
                # raise KeyError.
146
145
                continue
147
146
            else:
148
147
                parent_map[revision_id] = [mapping.revision_id_foreign_to_bzr(p) for p in commit.parents]
171
170
        :return: Tuple with git revisionid and mapping.
172
171
        """
173
172
        # Yes, this doesn't really work, but good enough as a stub
174
 
        return osutils.sha(rev_id).hexdigest(), self.get_mapping()
 
173
        return osutils.sha(revid).hexdigest(), self.get_mapping()
175
174
 
176
175
    def has_signature_for_revision_id(self, revision_id):
177
176
        return False
228
227
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
229
228
 
230
229
 
231
 
class GitRevisionTree(revisiontree.RevisionTree):
232
 
 
233
 
    def __init__(self, repository, revision_id):
234
 
        self._repository = repository
235
 
        self._revision_id = revision_id
236
 
        assert isinstance(revision_id, str)
237
 
        git_id, self.mapping = repository.lookup_git_revid(revision_id)
238
 
        try:
239
 
            commit = repository._git.commit(git_id)
240
 
        except KeyError, r:
241
 
            raise errors.NoSuchRevision(repository, revision_id)
242
 
        self.tree = commit.tree
243
 
        self._inventory = GitInventory(self.tree, self.mapping, repository._git.object_store, revision_id)
244
 
 
245
 
    def get_revision_id(self):
246
 
        return self._revision_id
247
 
 
248
 
    def get_file_text(self, file_id):
249
 
        entry = self._inventory[file_id]
250
 
        if entry.kind == 'directory': return ""
251
 
        return entry.object.data
252
 
 
253
 
 
254
230
class GitRepositoryFormat(repository.RepositoryFormat):
255
231
    """Git repository format."""
256
232
 
261
237
        return "Git Repository"
262
238
 
263
239
    def initialize(self, url, shared=False, _internal=False):
264
 
        raise bzr_errors.UninitializableFormat(self)
 
240
        raise errors.UninitializableFormat(self)
265
241
 
266
242
    def check_conversion_target(self, target_repo_format):
267
243
        return target_repo_format.rich_root_data
 
244
 
 
245
    def network_name(self):
 
246
        return "git"