/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
1
# Copyright (C) 2007 Canonical Ltd
0.200.252 by Jelmer Vernooij
Clarify history, copyright.
2
# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
"""An adapter between a Git Repository and a Bazaar Branch"""
19
20
from bzrlib import (
0.200.1244 by Jelmer Vernooij
Implement GitRepository.check.
21
    check,
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
22
    errors,
0.200.1281 by Jelmer Vernooij
Provide Repository.get_known_graph_ancestry.
23
    graph as _mod_graph,
0.200.38 by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster.
24
    inventory,
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
25
    repository,
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
26
    revision,
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
27
    )
0.200.1186 by Jelmer Vernooij
Cope with InventoryRevisionTree.
28
try:
29
    from bzrlib.revisiontree import InventoryRevisionTree
30
except ImportError: # bzr < 2.4
31
    from bzrlib.revisiontree import RevisionTree as InventoryRevisionTree
0.200.115 by Jelmer Vernooij
Pass mapping object.
32
from bzrlib.foreign import (
0.200.292 by Jelmer Vernooij
Fix formatting.
33
    ForeignRepository,
34
    )
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
35
0.200.387 by Jelmer Vernooij
Initial work on supporting commit in git trees.
36
from bzrlib.plugins.git.commit import (
37
    GitCommitBuilder,
38
    )
0.200.1283 by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision().
39
from bzrlib.plugins.git.filegraph import (
40
    GitFileLastChangeScanner,
41
    GitFileParentProvider,
42
    )
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
43
from bzrlib.plugins.git.mapping import (
44
    default_mapping,
0.200.1263 by Jelmer Vernooij
Fix foreign_vcs_git.
45
    foreign_vcs_git,
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
46
    mapping_registry,
47
    )
0.200.617 by Jelmer Vernooij
Add custom InterTree for use between git revision trees.
48
from bzrlib.plugins.git.tree import (
49
    GitRevisionTree,
50
    )
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
51
52
0.252.21 by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions.
53
from dulwich.objects import (
54
    Commit,
0.200.1080 by Jelmer Vernooij
Fix handling of annotated tags when cloning from local repo.
55
    Tag,
0.200.1153 by Jelmer Vernooij
Import ZERO_SHA from dulwich.objects.
56
    ZERO_SHA,
0.252.21 by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions.
57
    )
0.200.1233 by Jelmer Vernooij
Implement Repository.iter_files_bytes.
58
from dulwich.object_store import (
59
    tree_lookup_path,
60
    )
0.252.21 by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions.
61
62
0.200.1246 by Jelmer Vernooij
Provide GitRepository.reconcile.
63
class RepoReconciler(object):
64
    """Reconciler that reconciles a repository.
65
66
    """
67
68
    def __init__(self, repo, other=None, thorough=False):
69
        """Construct a RepoReconciler.
70
71
        :param thorough: perform a thorough check which may take longer but
72
                         will correct non-data loss issues such as incorrect
73
                         cached data.
74
        """
75
        self.repo = repo
76
77
    def reconcile(self):
78
        """Perform reconciliation.
79
80
        After reconciliation the following attributes document found issues:
81
        inconsistent_parents: The number of revisions in the repository whose
82
                              ancestry was being reported incorrectly.
83
        garbage_inventories: The number of inventory objects without revisions
84
                             that were garbage collected.
85
        """
86
87
0.200.1244 by Jelmer Vernooij
Implement GitRepository.check.
88
class GitCheck(check.Check):
89
90
    def __init__(self, repository, check_repo=True):
91
        self.repository = repository
92
        self.checked_rev_cnt = 0
93
94
    def check(self, callback_refs=None, check_repo=True):
95
        if callback_refs is None:
96
            callback_refs = {}
97
        self.repository.lock_read()
98
        self.repository.unlock()
99
100
    def report_results(self, verbose):
101
        pass
102
103
0.200.115 by Jelmer Vernooij
Pass mapping object.
104
class GitRepository(ForeignRepository):
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
105
    """An adapter to git repositories for bzr."""
106
0.200.41 by David Allouche
Define _serializer = None in GitRepository.
107
    _serializer = None
0.200.1263 by Jelmer Vernooij
Fix foreign_vcs_git.
108
    vcs = foreign_vcs_git
0.200.1086 by Jelmer Vernooij
Provide chk_bytes attribute.
109
    chk_bytes = None
0.200.41 by David Allouche
Define _serializer = None in GitRepository.
110
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
111
    def __init__(self, gitdir, lockfiles):
0.200.1307 by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions.
112
        super(GitRepository, self).__init__(GitRepositoryFormat(),
113
            gitdir, lockfiles)
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
114
        from bzrlib.plugins.git import fetch, push
0.200.676 by Jelmer Vernooij
Avoid iterating over all keys in the tdb database.
115
        for optimiser in [fetch.InterRemoteGitNonGitRepository,
0.200.306 by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository.
116
                          fetch.InterLocalGitNonGitRepository,
0.200.456 by Jelmer Vernooij
Fix git -> git fetching.
117
                          fetch.InterGitGitRepository,
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
118
                          push.InterToLocalGitRepository,
119
                          push.InterToRemoteGitRepository]:
0.200.276 by Jelmer Vernooij
Improve formatting.
120
            repository.InterRepository.register_optimiser(optimiser)
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
121
0.200.1231 by Jelmer Vernooij
Implement GitRepository.add_fallback_repository.
122
    def add_fallback_repository(self, basis_url):
0.200.1307 by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions.
123
        raise errors.UnstackableRepositoryFormat(self._format,
124
            self.control_transport.base)
0.200.1231 by Jelmer Vernooij
Implement GitRepository.add_fallback_repository.
125
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
126
    def is_shared(self):
0.200.886 by Jelmer Vernooij
Git repositories are not shared.
127
        return False
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
128
0.200.1246 by Jelmer Vernooij
Provide GitRepository.reconcile.
129
    def reconcile(self, other=None, thorough=False):
130
        """Reconcile this repository."""
131
        reconciler = RepoReconciler(self, thorough=thorough)
132
        reconciler.reconcile()
133
        return reconciler
134
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
135
    def supports_rich_root(self):
136
        return True
137
0.200.1111 by Jelmer Vernooij
Drop support for Bazaar < 2.3.
138
    def _warn_if_deprecated(self, branch=None): # for bzr < 2.4
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
139
        # This class isn't deprecated
140
        pass
141
142
    def get_mapping(self):
143
        return default_mapping
144
0.200.147 by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though.
145
    def make_working_trees(self):
0.200.1033 by Jelmer Vernooij
Don't claim to support working trees for bare repositories.
146
        return not self._git.bare
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
147
0.200.557 by Jelmer Vernooij
Implement GitRepository.revision_graph_can_have_wrong_parents().
148
    def revision_graph_can_have_wrong_parents(self):
149
        return False
150
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
151
    def dfetch(self, source, stop_revision):
152
        interrepo = repository.InterRepository.get(source, self)
153
        return interrepo.dfetch(stop_revision)
154
0.200.1158 by Jelmer Vernooij
Implement stub Repositor.add_signature_text.
155
    def add_signature_text(self, revid, signature):
156
        raise errors.UnsupportedOperation(self.add_signature_text, self)
157
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
158
159
class LocalGitRepository(GitRepository):
0.200.276 by Jelmer Vernooij
Improve formatting.
160
    """Git repository on the file system."""
0.200.139 by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches.
161
162
    def __init__(self, gitdir, lockfiles):
163
        GitRepository.__init__(self, gitdir, lockfiles)
0.200.61 by Jelmer Vernooij
Fix tests.
164
        self.base = gitdir.root_transport.base
0.200.90 by Jelmer Vernooij
Basic support for opening working trees.
165
        self._git = gitdir._git
0.200.1283 by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision().
166
        self._file_change_scanner = GitFileLastChangeScanner(self)
0.200.45 by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers.
167
0.200.1224 by Jelmer Vernooij
provide explicit GitRepository.get_commit_builder.
168
    def get_commit_builder(self, branch, parents, config, timestamp=None,
169
                           timezone=None, committer=None, revprops=None,
170
                           revision_id=None, lossy=False):
171
        """Obtain a CommitBuilder for this repository.
172
173
        :param branch: Branch to commit to.
174
        :param parents: Revision ids of the parents of the new revision.
175
        :param config: Configuration to use.
176
        :param timestamp: Optional timestamp recorded for commit.
177
        :param timezone: Optional timezone for timestamp.
178
        :param committer: Optional committer to set for commit.
179
        :param revprops: Optional dictionary of revision properties.
180
        :param revision_id: Optional revision id.
181
        :param lossy: Whether to discard data that can not be natively
182
            represented, when pushing to a foreign VCS
183
        """
0.200.1229 by Jelmer Vernooij
Provide CommitBuilder.any_changes.
184
        self.start_write_group()
0.200.1224 by Jelmer Vernooij
provide explicit GitRepository.get_commit_builder.
185
        return GitCommitBuilder(self, parents, config,
186
            timestamp, timezone, committer, revprops, revision_id,
187
            lossy)
188
0.200.1283 by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision().
189
    def get_file_graph(self):
0.200.1307 by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions.
190
        return _mod_graph.Graph(GitFileParentProvider(
191
            self._file_change_scanner))
0.200.1283 by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision().
192
0.200.1233 by Jelmer Vernooij
Implement Repository.iter_files_bytes.
193
    def iter_files_bytes(self, desired_files):
194
        """Iterate through file versions.
195
196
        Files will not necessarily be returned in the order they occur in
197
        desired_files.  No specific order is guaranteed.
198
199
        Yields pairs of identifier, bytes_iterator.  identifier is an opaque
200
        value supplied by the caller as part of desired_files.  It should
201
        uniquely identify the file version in the caller's context.  (Examples:
202
        an index number or a TreeTransform trans_id.)
203
204
        bytes_iterator is an iterable of bytestrings for the file.  The
205
        kind of iterable and length of the bytestrings are unspecified, but for
206
        this implementation, it is a list of bytes produced by
207
        VersionedFile.get_record_stream().
208
209
        :param desired_files: a list of (file_id, revision_id, identifier)
210
            triples
211
        """
212
        per_revision = {}
213
        for (file_id, revision_id, identifier) in desired_files:
0.200.1307 by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions.
214
            per_revision.setdefault(revision_id, []).append(
215
                (file_id, identifier))
0.200.1233 by Jelmer Vernooij
Implement Repository.iter_files_bytes.
216
        for revid, files in per_revision.iteritems():
217
            (commit_id, mapping) = self.lookup_bzr_revision_id(revid)
218
            try:
219
                commit = self._git.object_store[commit_id]
220
            except KeyError:
221
                raise errors.RevisionNotPresent(revid, self)
222
            root_tree = commit.tree
223
            for fileid, identifier in files:
224
                path = mapping.parse_file_id(fileid)
225
                try:
226
                    obj = tree_lookup_path(
227
                        self._git.object_store.__getitem__, root_tree, path)
228
                    if isinstance(obj, tuple):
229
                        (mode, item_id) = obj
230
                        obj = self._git.object_store[item_id]
231
                except KeyError:
232
                    raise errors.RevisionNotPresent((fileid, revid), self)
233
                else:
234
                    if obj.type_name == "tree":
235
                        yield (identifier, [])
236
                    elif obj.type_name == "blob":
237
                        yield (identifier, obj.chunked)
238
                    else:
239
                        raise AssertionError("file text resolved to %r" % obj)
240
241
0.252.46 by Jelmer Vernooij
Generate refs/bzr/* if not set yet.
242
    def _iter_revision_ids(self):
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
243
        mapping = self.get_mapping()
0.252.21 by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions.
244
        for sha in self._git.object_store:
245
            o = self._git.object_store[sha]
246
            if not isinstance(o, Commit):
247
                continue
0.200.1029 by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.
248
            rev, roundtrip_revid, verifiers = mapping.import_commit(o,
0.261.6 by Jelmer Vernooij
Use mapping.revision_id_foreign_to_bzr to find parents everywhere.
249
                mapping.revision_id_foreign_to_bzr)
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
250
            yield o.id, rev.revision_id, roundtrip_revid
0.252.46 by Jelmer Vernooij
Generate refs/bzr/* if not set yet.
251
252
    def all_revision_ids(self):
253
        ret = set([])
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
254
        for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
0.252.46 by Jelmer Vernooij
Generate refs/bzr/* if not set yet.
255
            ret.add(revid)
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
256
            if roundtrip_revid:
257
                ret.add(roundtrip_revid)
0.200.74 by Jelmer Vernooij
Implement Repository.all_revision_ids().
258
        return ret
259
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
260
    def get_parent_map(self, revids):
261
        parent_map = {}
262
        for revision_id in revids:
0.200.1324 by Jelmer Vernooij
More work on roundtripping support.
263
            if type(revision_id) != str:
264
                raise ValueError
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
265
            if revision_id == revision.NULL_REVISION:
266
                parent_map[revision_id] = ()
267
                continue
0.200.1324 by Jelmer Vernooij
More work on roundtripping support.
268
            try:
269
                hexsha, mapping = self.lookup_bzr_revision_id(revision_id)
270
            except errors.NoSuchRevision:
271
                continue
0.200.612 by Jelmer Vernooij
Cope with Dulwich returning KeyError when a commit is not found.
272
            try:
0.200.832 by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names.
273
                commit = self._git[hexsha]
0.200.612 by Jelmer Vernooij
Cope with Dulwich returning KeyError when a commit is not found.
274
            except KeyError:
275
                continue
0.200.1094 by Jelmer Vernooij
Fix test_get_no_parents.
276
            parents = [
0.200.1022 by Jelmer Vernooij
Fix formatting.
277
                self.lookup_foreign_revision_id(p, mapping)
278
                for p in commit.parents]
0.200.1324 by Jelmer Vernooij
More work on roundtripping support.
279
            if len(parents) == 0:
0.200.1094 by Jelmer Vernooij
Fix test_get_no_parents.
280
                parents = [revision.NULL_REVISION]
281
            parent_map[revision_id] = tuple(parents)
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
282
        return parent_map
283
0.200.1281 by Jelmer Vernooij
Provide Repository.get_known_graph_ancestry.
284
    def get_known_graph_ancestry(self, revision_ids):
285
        """Return the known graph for a set of revision ids and their ancestors.
286
        """
287
        pending = set(revision_ids)
288
        parent_map = {}
289
        while pending:
290
            this_parent_map = self.get_parent_map(pending)
291
            parent_map.update(this_parent_map)
292
            pending = set()
293
            map(pending.update, this_parent_map.itervalues())
294
            pending = pending.difference(parent_map)
295
        return _mod_graph.KnownGraph(parent_map)
296
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
297
    def get_signature_text(self, revision_id):
298
        raise errors.NoSuchRevision(self, revision_id)
299
0.200.1244 by Jelmer Vernooij
Implement GitRepository.check.
300
    def check(self, revision_ids=None, callback_refs=None, check_repo=True):
301
        result = GitCheck(self, check_repo=check_repo)
302
        result.check(callback_refs)
303
        return result
304
0.257.1 by Jelmer Vernooij
use transport repo objects even for local access.
305
    def pack(self, hint=None, clean_obsolete_packs=False):
306
        self._git.object_store.pack_loose_objects()
307
0.200.650 by Jelmer Vernooij
Use standard names for lookup functions.
308
    def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
0.200.124 by Jelmer Vernooij
Add lookup_revision_id stub.
309
        """Lookup a revision id.
0.200.676 by Jelmer Vernooij
Avoid iterating over all keys in the tdb database.
310
0.200.124 by Jelmer Vernooij
Add lookup_revision_id stub.
311
        """
0.200.1033 by Jelmer Vernooij
Don't claim to support working trees for bare repositories.
312
        assert type(foreign_revid) is str
0.200.649 by Jelmer Vernooij
Make GitRevisions VF implementation behave as the interface expects.
313
        if mapping is None:
314
            mapping = self.get_mapping()
0.200.914 by Jelmer Vernooij
Fix tests.
315
        if foreign_revid == ZERO_SHA:
316
            return revision.NULL_REVISION
0.200.1268 by Jelmer Vernooij
Look in object store directly when something can't be a ref.
317
        commit = self._git.object_store[foreign_revid]
0.200.1080 by Jelmer Vernooij
Fix handling of annotated tags when cloning from local repo.
318
        while isinstance(commit, Tag):
319
            commit = self._git[commit.object[1]]
0.200.1029 by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.
320
        rev, roundtrip_revid, verifiers = mapping.import_commit(commit,
0.261.6 by Jelmer Vernooij
Use mapping.revision_id_foreign_to_bzr to find parents everywhere.
321
            mapping.revision_id_foreign_to_bzr)
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
322
        # FIXME: check testament before doing this?
323
        if roundtrip_revid:
324
            return roundtrip_revid
325
        else:
326
            return rev.revision_id
0.200.124 by Jelmer Vernooij
Add lookup_revision_id stub.
327
0.200.60 by Jelmer Vernooij
Support signature functions.
328
    def has_signature_for_revision_id(self, revision_id):
329
        return False
330
0.200.913 by Jelmer Vernooij
Fix tests.
331
    def lookup_bzr_revision_id(self, bzr_revid, mapping=None):
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
332
        try:
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
333
            return mapping_registry.revision_id_bzr_to_foreign(bzr_revid)
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
334
        except errors.InvalidRevisionId:
0.200.913 by Jelmer Vernooij
Fix tests.
335
            if mapping is None:
336
                mapping = self.get_mapping()
0.252.6 by Jelmer Vernooij
Roundtripping support for revision ids works.
337
            try:
0.200.1307 by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions.
338
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
339
                        mapping)
0.252.6 by Jelmer Vernooij
Roundtripping support for revision ids works.
340
            except KeyError:
0.252.46 by Jelmer Vernooij
Generate refs/bzr/* if not set yet.
341
                # Update refs from Git commit objects
342
                # FIXME: Hitting this a lot will be very inefficient...
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
343
                for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
344
                    if not roundtrip_revid:
345
                        continue
0.200.1022 by Jelmer Vernooij
Fix formatting.
346
                    refname = mapping.revid_as_refname(roundtrip_revid)
347
                    self._git.refs[refname] = git_sha
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
348
                    if roundtrip_revid == bzr_revid:
0.200.913 by Jelmer Vernooij
Fix tests.
349
                        return git_sha, mapping
350
                raise errors.NoSuchRevision(self, bzr_revid)
0.200.105 by Jelmer Vernooij
Add common function for finding git commit by bzr revid.
351
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
352
    def get_revision(self, revision_id):
0.200.1101 by Jelmer Vernooij
Raise InvalidRevisionId on invalid type being specified to Repository.get_revision.
353
        if not isinstance(revision_id, str):
354
            raise errors.InvalidRevisionId(revision_id, self)
0.200.650 by Jelmer Vernooij
Use standard names for lookup functions.
355
        git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
0.200.147 by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though.
356
        try:
0.200.832 by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names.
357
            commit = self._git[git_commit_id]
0.200.147 by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though.
358
        except KeyError:
359
            raise errors.NoSuchRevision(self, revision_id)
0.200.1029 by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.
360
        revision, roundtrip_revid, verifiers = mapping.import_commit(
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
361
            commit, self.lookup_foreign_revision_id)
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
362
        assert revision is not None
0.200.1029 by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.
363
        # FIXME: check verifiers ?
0.200.1021 by Jelmer Vernooij
Put testament sha1 in revisions.
364
        if roundtrip_revid:
365
            revision.revision_id = roundtrip_revid
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
366
        return revision
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
367
368
    def has_revision(self, revision_id):
0.200.1119 by Jelmer Vernooij
Refactor repository initialization.
369
        """See Repository.has_revision."""
0.200.1122 by Jelmer Vernooij
has_revision(null:) should always return True.
370
        if revision_id == revision.NULL_REVISION:
371
            return True
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
372
        try:
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
373
            git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
0.200.130 by Jelmer Vernooij
Make most tree inspection tests succeed.
374
        except errors.NoSuchRevision:
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
375
            return False
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
376
        return (git_commit_id in self._git)
377
378
    def has_revisions(self, revision_ids):
0.200.1119 by Jelmer Vernooij
Refactor repository initialization.
379
        """See Repository.has_revisions."""
0.200.913 by Jelmer Vernooij
Fix tests.
380
        return set(filter(self.has_revision, revision_ids))
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
381
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
382
    def get_revisions(self, revids):
0.200.1119 by Jelmer Vernooij
Refactor repository initialization.
383
        """See Repository.get_revisions."""
0.200.134 by Jelmer Vernooij
Fix get_revisions().
384
        return [self.get_revision(r) for r in revids]
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
385
386
    def revision_trees(self, revids):
0.200.1119 by Jelmer Vernooij
Refactor repository initialization.
387
        """See Repository.revision_trees."""
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
388
        for revid in revids:
389
            yield self.revision_tree(revid)
390
391
    def revision_tree(self, revision_id):
0.200.1119 by Jelmer Vernooij
Refactor repository initialization.
392
        """See Repository.revision_tree."""
0.200.57 by Jelmer Vernooij
Fix more tests.
393
        revision_id = revision.ensure_null(revision_id)
394
        if revision_id == revision.NULL_REVISION:
395
            inv = inventory.Inventory(root_id=None)
396
            inv.revision_id = revision_id
0.200.1186 by Jelmer Vernooij
Cope with InventoryRevisionTree.
397
            return InventoryRevisionTree(self, inv, revision_id)
0.200.195 by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface.
398
        return GitRevisionTree(self, revision_id)
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
399
400
    def get_inventory(self, revision_id):
0.264.4 by Jelmer Vernooij
No longer implement Repository.get_inventory.
401
        raise NotImplementedError(self.get_inventory)
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
402
0.200.108 by Jelmer Vernooij
Support bzr init --git.
403
    def set_make_working_trees(self, trees):
0.200.1321 by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite.
404
        raise errors.UnsupportedOperation(self.set_make_working_trees, self)
0.200.1216 by Jelmer Vernooij
Add note about set_make_working_trees.
405
        # TODO: Set bare= in the configuration bug=777065
0.200.108 by Jelmer Vernooij
Support bzr init --git.
406
0.200.276 by Jelmer Vernooij
Improve formatting.
407
    def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
408
        progress=None):
0.200.146 by Jelmer Vernooij
Merge dulwich.
409
        return self._git.fetch_objects(determine_wants, graph_walker, progress)
0.200.138 by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories.
410
0.200.43 by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity.
411
0.200.289 by Jelmer Vernooij
Cope with new member variables in RepositoryFormat.
412
class GitRepositoryFormat(repository.RepositoryFormat):
0.200.429 by Jelmer Vernooij
get remote dpush to a point where we now what to send.
413
    """Git repository format."""
0.203.1 by Aaron Bentley
Make checkouts work
414
0.200.1294 by Jelmer Vernooij
Mark as not supporting versioned directories.
415
    supports_versioned_directories = False
0.203.1 by Aaron Bentley
Make checkouts work
416
    supports_tree_reference = False
0.200.133 by Jelmer Vernooij
Unmark as deprecated.
417
    rich_root_data = True
0.200.1105 by Jelmer Vernooij
Don't claim to support leaving locks.
418
    supports_leaving_lock = False
0.200.1106 by Jelmer Vernooij
Claim to support fast deltas.
419
    fast_deltas = True
0.200.1123 by Jelmer Vernooij
Set more repository format flags.
420
    supports_funky_characters = True
0.200.1134 by Jelmer Vernooij
Set RepositoryFormat.supports_external_lookups.
421
    supports_external_lookups = False
0.200.1135 by Jelmer Vernooij
Set supports_full_versioned_files=False.
422
    supports_full_versioned_files = False
0.200.1162 by Jelmer Vernooij
Set RepositoryFormat.supports_revision_signatures.
423
    supports_revision_signatures = False
0.200.1166 by Jelmer Vernooij
Set GitRepositoryFormat.revision_graph_can_have_wrong_parents.
424
    revision_graph_can_have_wrong_parents = False
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
425
0.200.1083 by Jelmer Vernooij
Register repository format.
426
    @property
427
    def _matchingbzrdir(self):
428
        from bzrlib.plugins.git.dir import LocalGitControlDirFormat
429
        return LocalGitControlDirFormat()
430
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
431
    def get_format_description(self):
432
        return "Git Repository"
0.200.133 by Jelmer Vernooij
Unmark as deprecated.
433
0.200.1084 by Jelmer Vernooij
Support 'initializing' repositories in control directories.
434
    def initialize(self, controldir, shared=False, _internal=False):
435
        from bzrlib.plugins.git.dir import GitDir
436
        if not isinstance(controldir, GitDir):
437
            raise errors.UninitializableFormat(self)
438
        return controldir.open_repository()
0.200.133 by Jelmer Vernooij
Unmark as deprecated.
439
440
    def check_conversion_target(self, target_repo_format):
441
        return target_repo_format.rich_root_data
0.200.536 by Jelmer Vernooij
Implement network name.
442
0.200.658 by Jelmer Vernooij
Provide right infrastructure for foreign repository tests from bzrlib.
443
    def get_foreign_tests_repository_factory(self):
0.200.713 by Jelmer Vernooij
Improve formatting.
444
        from bzrlib.plugins.git.tests.test_repository import (
445
            ForeignTestsRepositoryFactory,
446
            )
0.200.658 by Jelmer Vernooij
Provide right infrastructure for foreign repository tests from bzrlib.
447
        return ForeignTestsRepositoryFactory()
448
0.200.536 by Jelmer Vernooij
Implement network name.
449
    def network_name(self):
450
        return "git"