/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

Add check-all target.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
from dulwich.objects import (
49
49
    Commit,
 
50
    Tag,
 
51
    ZERO_SHA,
50
52
    )
51
53
 
52
54
 
56
58
    _serializer = None
57
59
    _commit_builder_class = GitCommitBuilder
58
60
    vcs = foreign_git
 
61
    chk_bytes = None
59
62
 
60
63
    def __init__(self, gitdir, lockfiles):
61
 
        ForeignRepository.__init__(self, GitRepositoryFormat(), gitdir,
62
 
            lockfiles)
 
64
        ForeignRepository.__init__(self, GitRepositoryFormat(), gitdir, lockfiles)
63
65
        from bzrlib.plugins.git import fetch, push
64
66
        for optimiser in [fetch.InterRemoteGitNonGitRepository,
65
67
                          fetch.InterLocalGitNonGitRepository,
74
76
    def supports_rich_root(self):
75
77
        return True
76
78
 
77
 
    def _warn_if_deprecated(self, branch=None):
 
79
    def _warn_if_deprecated(self, branch=None): # for bzr < 2.4
78
80
        # This class isn't deprecated
79
81
        pass
80
82
 
91
93
        interrepo = repository.InterRepository.get(source, self)
92
94
        return interrepo.dfetch(stop_revision)
93
95
 
 
96
    def add_signature_text(self, revid, signature):
 
97
        raise errors.UnsupportedOperation(self.add_signature_text, self)
 
98
 
94
99
 
95
100
class LocalGitRepository(GitRepository):
96
101
    """Git repository on the file system."""
134
139
                commit = self._git[hexsha]
135
140
            except KeyError:
136
141
                continue
137
 
            parent_map[revision_id] = [
 
142
            parents = [
138
143
                self.lookup_foreign_revision_id(p, mapping)
139
144
                for p in commit.parents]
 
145
            if parents == []:
 
146
                parents = [revision.NULL_REVISION]
 
147
            parent_map[revision_id] = tuple(parents)
140
148
        return parent_map
141
149
 
142
150
    def get_ancestry(self, revision_id, topo_sorted=True):
149
157
        graph = self.get_graph()
150
158
        for rev, parents in graph.iter_ancestry([revision_id]):
151
159
            ancestry.append(rev)
 
160
        if revision.NULL_REVISION in ancestry:
 
161
            ancestry.remove(revision.NULL_REVISION)
152
162
        ancestry.reverse()
153
163
        return [None] + ancestry
154
164
 
165
175
        assert type(foreign_revid) is str
166
176
        if mapping is None:
167
177
            mapping = self.get_mapping()
168
 
        from dulwich.protocol import (
169
 
            ZERO_SHA,
170
 
            )
171
178
        if foreign_revid == ZERO_SHA:
172
179
            return revision.NULL_REVISION
173
180
        commit = self._git[foreign_revid]
 
181
        while isinstance(commit, Tag):
 
182
            commit = self._git[commit.object[1]]
174
183
        rev, roundtrip_revid, verifiers = mapping.import_commit(commit,
175
184
            lambda x: None)
176
185
        # FIXME: check testament before doing this?
189
198
            if mapping is None:
190
199
                mapping = self.get_mapping()
191
200
            try:
192
 
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
193
 
                        mapping)
 
201
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)], mapping)
194
202
            except KeyError:
195
203
                # Update refs from Git commit objects
196
204
                # FIXME: Hitting this a lot will be very inefficient...
204
212
                raise errors.NoSuchRevision(self, bzr_revid)
205
213
 
206
214
    def get_revision(self, revision_id):
 
215
        if not isinstance(revision_id, str):
 
216
            raise errors.InvalidRevisionId(revision_id, self)
207
217
        git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
208
218
        try:
209
219
            commit = self._git[git_commit_id]
218
228
        return revision
219
229
 
220
230
    def has_revision(self, revision_id):
 
231
        """See Repository.has_revision."""
 
232
        if revision_id == revision.NULL_REVISION:
 
233
            return True
221
234
        try:
222
235
            git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
223
236
        except errors.NoSuchRevision:
225
238
        return (git_commit_id in self._git)
226
239
 
227
240
    def has_revisions(self, revision_ids):
 
241
        """See Repository.has_revisions."""
228
242
        return set(filter(self.has_revision, revision_ids))
229
243
 
230
244
    def get_revisions(self, revids):
 
245
        """See Repository.get_revisions."""
231
246
        return [self.get_revision(r) for r in revids]
232
247
 
233
248
    def revision_trees(self, revids):
 
249
        """See Repository.revision_trees."""
234
250
        for revid in revids:
235
251
            yield self.revision_tree(revid)
236
252
 
237
253
    def revision_tree(self, revision_id):
 
254
        """See Repository.revision_tree."""
238
255
        revision_id = revision.ensure_null(revision_id)
239
256
        if revision_id == revision.NULL_REVISION:
240
257
            inv = inventory.Inventory(root_id=None)
247
264
        return self.revision_tree(revision_id).inventory
248
265
 
249
266
    def set_make_working_trees(self, trees):
250
 
        pass
 
267
        raise NotImplementedError(self.set_make_working_trees)
251
268
 
252
269
    def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
253
270
        progress=None):
254
271
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
255
272
 
256
 
    def _get_versioned_file_checker(self, text_key_references=None,
257
 
                        ancestors=None):
 
273
    def _get_versioned_file_checker(self, text_key_references=None, ancestors=None):
258
274
        return GitVersionedFileChecker(self,
259
275
            text_key_references=text_key_references, ancestors=ancestors)
260
276
 
272
288
 
273
289
    supports_tree_reference = False
274
290
    rich_root_data = True
 
291
    supports_leaving_lock = False
 
292
    fast_deltas = True
 
293
    supports_funky_characters = True
 
294
    supports_external_lookups = False
 
295
    supports_full_versioned_files = False
 
296
 
 
297
    @property
 
298
    def _matchingbzrdir(self):
 
299
        from bzrlib.plugins.git.dir import LocalGitControlDirFormat
 
300
        return LocalGitControlDirFormat()
275
301
 
276
302
    def get_format_description(self):
277
303
        return "Git Repository"
278
304
 
279
 
    def initialize(self, url, shared=False, _internal=False):
280
 
        raise errors.UninitializableFormat(self)
 
305
    def initialize(self, controldir, shared=False, _internal=False):
 
306
        from bzrlib.plugins.git.dir import GitDir
 
307
        if not isinstance(controldir, GitDir):
 
308
            raise errors.UninitializableFormat(self)
 
309
        return controldir.open_repository()
281
310
 
282
311
    def check_conversion_target(self, target_repo_format):
283
312
        return target_repo_format.rich_root_data