/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.358.2 by Jelmer Vernooij
Refresh copyright headers, add my email.
2
# Copyright (C) 2007-2018 Jelmer Vernooij <jelmer@jelmer.uk>
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
0.358.1 by Jelmer Vernooij
Fix FSF address.
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
17
18
"""Tests for interfacing with a Git Repository"""
19
0.200.445 by Jelmer Vernooij
Import dulwich as dulwich, not as git.
20
import dulwich
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
21
from dulwich.repo import (
22
    Repo as GitRepo,
23
    )
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
24
import os
25
6986.2.1 by Jelmer Vernooij
Move breezy.plugins.git to breezy.git.
26
from ... import (
0.386.1 by Jelmer Vernooij
Support signing commits.
27
    config,
0.200.61 by Jelmer Vernooij
Fix tests.
28
    errors,
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
29
    revision,
30
    )
6986.2.1 by Jelmer Vernooij
Move breezy.plugins.git to breezy.git.
31
from ...repository import (
0.200.357 by Jelmer Vernooij
Move push code to push.py.
32
    InterRepository,
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
33
    Repository,
34
    )
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
35
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
36
from .. import (
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
37
    dir,
38
    repository,
0.200.97 by Jelmer Vernooij
use mapping object.
39
    tests,
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
40
    )
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
41
from ..mapping import (
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
42
    default_mapping,
43
    )
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
44
from ..object_store import (
0.235.2 by Jelmer Vernooij
Fix tests.
45
    BazaarObjectStore,
46
    )
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
47
from ..push import (
0.200.368 by Jelmer Vernooij
Cope with more granular timezones.
48
    MissingObjectsIterator,
49
    )
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
50
7143.15.2 by Jelmer Vernooij
Run autopep8.
51
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
52
class TestGitRepositoryFeatures(tests.TestCaseInTempDir):
0.200.32 by David Allouche
Rewrite GitRepository._parse_rev, with unit tests.
53
    """Feature tests for GitRepository."""
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
54
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
55
    def _do_commit(self):
56
        builder = tests.GitBranchBuilder()
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
57
        builder.set_file(b'a', b'text for a\n', False)
58
        commit_handle = builder.commit(b'Joe Foo <joe@foo.com>', b'message')
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
59
        mapping = builder.finish()
60
        return mapping[commit_handle]
61
0.200.18 by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.
62
    def test_open_existing(self):
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
63
        GitRepo.init(self.test_dir)
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
64
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
65
        repo = Repository.open('.')
66
        self.assertIsInstance(repo, repository.GitRepository)
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
67
0.200.56 by Jelmer Vernooij
Switch to using GitPython rather than our own in-house stuff.
68
    def test_has_git_repo(self):
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
69
        GitRepo.init(self.test_dir)
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
70
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
71
        repo = Repository.open('.')
0.257.1 by Jelmer Vernooij
use transport repo objects even for local access.
72
        self.assertIsInstance(repo._git, dulwich.repo.BaseRepo)
0.200.21 by John Arbash Meinel
Fix Repository.get_revision_graph()
73
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
74
    def test_has_revision(self):
75
        GitRepo.init(self.test_dir)
76
        commit_id = self._do_commit()
77
        repo = Repository.open('.')
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
78
        self.assertFalse(repo.has_revision(b'foobar'))
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
79
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
80
        self.assertTrue(repo.has_revision(revid))
81
82
    def test_has_revisions(self):
83
        GitRepo.init(self.test_dir)
84
        commit_id = self._do_commit()
85
        repo = Repository.open('.')
6964.2.3 by Jelmer Vernooij
Review comments.
86
        self.assertEqual(set(), repo.has_revisions([b'foobar']))
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
87
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
6964.2.3 by Jelmer Vernooij
Review comments.
88
        self.assertEqual(set([revid]), repo.has_revisions([b'foobar', revid]))
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
89
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
90
    def test_get_revision(self):
0.200.32 by David Allouche
Rewrite GitRepository._parse_rev, with unit tests.
91
        # GitRepository.get_revision gives a Revision object.
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
92
93
        # Create a git repository with a revision.
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
94
        GitRepo.init(self.test_dir)
0.200.902 by Jelmer Vernooij
Fix Repository.has_revision{s,}.
95
        commit_id = self._do_commit()
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
96
97
        # Get the corresponding Revision object.
0.200.104 by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids.
98
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
99
        repo = Repository.open('.')
0.200.29 by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes.
100
        rev = repo.get_revision(revid)
101
        self.assertIsInstance(rev, revision.Revision)
0.200.32 by David Allouche
Rewrite GitRepository._parse_rev, with unit tests.
102
0.200.106 by Jelmer Vernooij
Test that getting an unknown revision fails.
103
    def test_get_revision_unknown(self):
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
104
        GitRepo.init(self.test_dir)
0.200.106 by Jelmer Vernooij
Test that getting an unknown revision fails.
105
106
        repo = Repository.open('.')
7018.3.2 by Jelmer Vernooij
Fix some git tests.
107
        self.assertRaises(errors.NoSuchRevision, repo.get_revision, b"bla")
0.200.106 by Jelmer Vernooij
Test that getting an unknown revision fails.
108
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
109
    def simple_commit(self):
0.200.38 by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster.
110
        # Create a git repository with some interesting files in a revision.
0.200.447 by Jelmer Vernooij
Rely less on command-line git.
111
        GitRepo.init(self.test_dir)
0.200.38 by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster.
112
        builder = tests.GitBranchBuilder()
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
113
        builder.set_file(b'data', b'text\n', False)
114
        builder.set_file(b'executable', b'content', True)
7018.3.8 by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport.
115
        builder.set_symlink(b'link', b'broken')
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
116
        builder.set_file(b'subdir/subfile', b'subdir text\n', False)
117
        commit_handle = builder.commit(b'Joe Foo <joe@foo.com>', b'message',
7143.15.2 by Jelmer Vernooij
Run autopep8.
118
                                       timestamp=1205433193)
0.200.38 by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster.
119
        mapping = builder.finish()
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
120
        return mapping[commit_handle]
121
0.257.1 by Jelmer Vernooij
use transport repo objects even for local access.
122
    def test_pack(self):
123
        commit_id = self.simple_commit()
124
        repo = Repository.open('.')
125
        repo.pack()
126
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
127
    def test_revision_tree(self):
128
        commit_id = self.simple_commit()
0.200.104 by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids.
129
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
130
        repo = Repository.open('.')
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
131
        tree = repo.revision_tree(revid)
6964.2.3 by Jelmer Vernooij
Review comments.
132
        self.assertEqual(tree.get_revision_id(), revid)
6973.7.3 by Jelmer Vernooij
Fix some more tests.
133
        self.assertEqual(b"text\n", tree.get_file_text("data"))
0.200.79 by Jelmer Vernooij
Implement RevisionTree.get_revision_id().
134
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
135
0.204.2 by James Westby
Switch to TestCaseWithTransport so that the cache dir can be
136
class TestGitRepository(tests.TestCaseWithTransport):
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
137
0.252.41 by Jelmer Vernooij
Fix Repository.all_revision_ids.
138
    def _do_commit(self):
139
        builder = tests.GitBranchBuilder()
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
140
        builder.set_file(b'a', b'text for a\n', False)
141
        commit_handle = builder.commit(b'Joe Foo <joe@foo.com>', b'message')
0.252.41 by Jelmer Vernooij
Fix Repository.all_revision_ids.
142
        mapping = builder.finish()
143
        return mapping[commit_handle]
144
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
145
    def setUp(self):
0.204.2 by James Westby
Switch to TestCaseWithTransport so that the cache dir can be
146
        tests.TestCaseWithTransport.setUp(self)
0.200.445 by Jelmer Vernooij
Import dulwich as dulwich, not as git.
147
        dulwich.repo.Repo.create(self.test_dir)
0.200.94 by Jelmer Vernooij
Eliminate (duplicate) git_ prefix.
148
        self.git_repo = Repository.open(self.test_dir)
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
149
0.200.40 by David Allouche
GitRepository.supports_rich_root() => False
150
    def test_supports_rich_root(self):
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
151
        repo = self.git_repo
0.200.131 by Jelmer Vernooij
Fix all tests but two, use rich roots by default.
152
        self.assertEqual(repo.supports_rich_root(), True)
0.200.40 by David Allouche
GitRepository.supports_rich_root() => False
153
0.200.60 by Jelmer Vernooij
Support signature functions.
154
    def test_get_signature_text(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
155
        self.assertRaises(
156
            errors.NoSuchRevision, self.git_repo.get_signature_text, revision.NULL_REVISION)
0.200.60 by Jelmer Vernooij
Support signature functions.
157
158
    def test_has_signature_for_revision_id(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
159
        self.assertEqual(False, self.git_repo.has_signature_for_revision_id(
160
            revision.NULL_REVISION))
0.200.60 by Jelmer Vernooij
Support signature functions.
161
0.200.75 by Jelmer Vernooij
Implement Repository.all_revision_ids().
162
    def test_all_revision_ids_none(self):
6964.2.3 by Jelmer Vernooij
Review comments.
163
        self.assertEqual([], self.git_repo.all_revision_ids())
0.200.75 by Jelmer Vernooij
Implement Repository.all_revision_ids().
164
0.200.1282 by Jelmer Vernooij
Add tests for get_known_graph_ancestry.
165
    def test_get_known_graph_ancestry(self):
166
        cid = self._do_commit()
167
        revid = default_mapping.revision_id_foreign_to_bzr(cid)
168
        g = self.git_repo.get_known_graph_ancestry([revid])
6964.2.3 by Jelmer Vernooij
Review comments.
169
        self.assertEqual(frozenset([revid]),
7143.15.2 by Jelmer Vernooij
Run autopep8.
170
                         g.heads([revid]))
0.200.1329 by Jelmer Vernooij
Fix more tests.
171
        self.assertEqual([(revid, 0, (1,), True)],
7143.15.2 by Jelmer Vernooij
Run autopep8.
172
                         [(n.key, n.merge_depth, n.revno, n.end_of_merge)
173
                          for n in g.merge_sort(revid)])
0.200.1282 by Jelmer Vernooij
Add tests for get_known_graph_ancestry.
174
0.252.41 by Jelmer Vernooij
Fix Repository.all_revision_ids.
175
    def test_all_revision_ids(self):
176
        commit_id = self._do_commit()
6964.2.3 by Jelmer Vernooij
Review comments.
177
        self.assertEqual(
7143.15.2 by Jelmer Vernooij
Run autopep8.
178
            [default_mapping.revision_id_foreign_to_bzr(commit_id)],
179
            self.git_repo.all_revision_ids())
0.252.41 by Jelmer Vernooij
Fix Repository.all_revision_ids.
180
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
181
    def assertIsNullInventory(self, inv):
182
        self.assertEqual(inv.root, None)
183
        self.assertEqual(inv.revision_id, revision.NULL_REVISION)
184
        self.assertEqual(list(inv.iter_entries()), [])
185
186
    def test_revision_tree_none(self):
187
        # GitRepository.revision_tree(None) returns the null tree.
188
        repo = self.git_repo
0.200.57 by Jelmer Vernooij
Fix more tests.
189
        tree = repo.revision_tree(revision.NULL_REVISION)
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
190
        self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
7358.14.1 by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id('').
191
        self.assertIs(None, tree.path2id(''))
0.202.2 by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data.
192
0.200.77 by Jelmer Vernooij
Handle NULL_REVISION in get_parent_map.
193
    def test_get_parent_map_null(self):
6964.2.3 by Jelmer Vernooij
Review comments.
194
        self.assertEqual({revision.NULL_REVISION: ()},
7143.15.2 by Jelmer Vernooij
Run autopep8.
195
                         self.git_repo.get_parent_map([revision.NULL_REVISION]))
0.200.77 by Jelmer Vernooij
Handle NULL_REVISION in get_parent_map.
196
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
197
0.386.1 by Jelmer Vernooij
Support signing commits.
198
class SigningGitRepository(tests.TestCaseWithTransport):
199
200
    def test_signed_commit(self):
201
        import breezy.gpg
202
        oldstrategy = breezy.gpg.GPGStrategy
203
        wt = self.make_branch_and_tree('.', format='git')
204
        branch = wt.branch
205
        revid = wt.commit("base", allow_pointless=True)
7143.15.2 by Jelmer Vernooij
Run autopep8.
206
        self.assertFalse(
207
            branch.repository.has_signature_for_revision_id(revid))
0.386.1 by Jelmer Vernooij
Support signing commits.
208
        try:
209
            breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
7018.3.7 by Jelmer Vernooij
Fix remaining git tests.
210
            conf = config.MemoryStack(b'''
0.386.1 by Jelmer Vernooij
Support signing commits.
211
create_signatures=always
212
''')
7143.15.2 by Jelmer Vernooij
Run autopep8.
213
            revid2 = wt.commit(config=conf, message="base",
214
                               allow_pointless=True)
215
0.386.1 by Jelmer Vernooij
Support signing commits.
216
            def sign(text):
217
                return breezy.gpg.LoopbackGPGStrategy(None).sign(text)
7143.15.2 by Jelmer Vernooij
Run autopep8.
218
            self.assertIsInstance(
219
                branch.repository.get_signature_text(revid2), bytes)
0.386.1 by Jelmer Vernooij
Support signing commits.
220
        finally:
221
            breezy.gpg.GPGStrategy = oldstrategy
222
223
7143.6.1 by Jelmer Vernooij
Support the 'authors' revprop when creating Git commits.
224
class RevpropsRepository(tests.TestCaseWithTransport):
225
226
    def test_author(self):
227
        wt = self.make_branch_and_tree('.', format='git')
228
        revid = wt.commit(
229
            "base", allow_pointless=True,
230
            revprops={'author': 'Joe Example <joe@example.com>'})
231
        rev = wt.branch.repository.get_revision(revid)
232
        r = dulwich.repo.Repo('.')
7143.6.2 by Jelmer Vernooij
Fix tests on python 3.
233
        self.assertEqual(b'Joe Example <joe@example.com>', r[r.head()].author)
7143.6.1 by Jelmer Vernooij
Support the 'authors' revprop when creating Git commits.
234
235
    def test_authors(self):
236
        wt = self.make_branch_and_tree('.', format='git')
237
        revid = wt.commit(
238
            "base", allow_pointless=True,
239
            revprops={'authors': 'Joe Example <joe@example.com>'})
240
        rev = wt.branch.repository.get_revision(revid)
241
        r = dulwich.repo.Repo('.')
7143.6.2 by Jelmer Vernooij
Fix tests on python 3.
242
        self.assertEqual(b'Joe Example <joe@example.com>', r[r.head()].author)
7143.6.1 by Jelmer Vernooij
Support the 'authors' revprop when creating Git commits.
243
244
    def test_multiple_authors(self):
245
        wt = self.make_branch_and_tree('.', format='git')
7143.16.10 by Jelmer Vernooij
Fix E128.
246
        self.assertRaises(
247
            Exception, wt.commit, "base", allow_pointless=True,
7143.6.1 by Jelmer Vernooij
Support the 'authors' revprop when creating Git commits.
248
            revprops={'authors': 'Joe Example <joe@example.com>\n'
249
                                 'Jane Doe <jane@example.com\n>'})
250
7206.2.1 by Jelmer Vernooij
Add support for --fixes in Git repositories.
251
    def test_bugs(self):
252
        wt = self.make_branch_and_tree('.', format='git')
253
        revid = wt.commit(
254
            "base", allow_pointless=True,
255
            revprops={
256
                'bugs': 'https://github.com/jelmer/dulwich/issues/123 fixed\n'
257
                })
258
        rev = wt.branch.repository.get_revision(revid)
259
        r = dulwich.repo.Repo('.')
260
        self.assertEqual(
261
            b'base\n'
262
            b'Fixes: https://github.com/jelmer/dulwich/issues/123\n',
263
            r[r.head()].message)
264
7143.6.1 by Jelmer Vernooij
Support the 'authors' revprop when creating Git commits.
265
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
266
class GitRepositoryFormat(tests.TestCase):
267
268
    def setUp(self):
269
        super(GitRepositoryFormat, self).setUp()
0.200.290 by Jelmer Vernooij
Fix tests.
270
        self.format = repository.GitRepositoryFormat()
0.200.71 by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description.
271
272
    def test_get_format_description(self):
6964.2.3 by Jelmer Vernooij
Review comments.
273
        self.assertEqual("Git Repository",
7143.15.2 by Jelmer Vernooij
Run autopep8.
274
                         self.format.get_format_description())
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
275
276
277
class RevisionGistImportTests(tests.TestCaseWithTransport):
278
279
    def setUp(self):
280
        tests.TestCaseWithTransport.setUp(self)
281
        self.git_path = os.path.join(self.test_dir, "git")
282
        os.mkdir(self.git_path)
0.200.445 by Jelmer Vernooij
Import dulwich as dulwich, not as git.
283
        dulwich.repo.Repo.create(self.git_path)
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
284
        self.git_repo = Repository.open(self.git_path)
285
        self.bzr_tree = self.make_branch_and_tree("bzr")
286
0.200.357 by Jelmer Vernooij
Move push code to push.py.
287
    def get_inter(self):
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
288
        return InterRepository.get(self.bzr_tree.branch.repository,
0.200.357 by Jelmer Vernooij
Move push code to push.py.
289
                                   self.git_repo)
290
0.200.368 by Jelmer Vernooij
Cope with more granular timezones.
291
    def object_iter(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
292
        store = BazaarObjectStore(
293
            self.bzr_tree.branch.repository, default_mapping)
294
        store_iterator = MissingObjectsIterator(
295
            store, self.bzr_tree.branch.repository)
0.254.8 by Jelmer Vernooij
Fix tests.
296
        return store, store_iterator
0.200.368 by Jelmer Vernooij
Cope with more granular timezones.
297
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
298
    def import_rev(self, revid, parent_lookup=None):
0.254.8 by Jelmer Vernooij
Fix tests.
299
        store, store_iter = self.object_iter()
0.200.847 by Jelmer Vernooij
Add BzrGitCache object.
300
        store._cache.idmap.start_write_group()
0.254.8 by Jelmer Vernooij
Fix tests.
301
        try:
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
302
            return store_iter.import_revision(revid, lossy=True)
0.254.8 by Jelmer Vernooij
Fix tests.
303
        except:
0.200.847 by Jelmer Vernooij
Add BzrGitCache object.
304
            store._cache.idmap.abort_write_group()
0.254.8 by Jelmer Vernooij
Fix tests.
305
            raise
306
        else:
0.200.847 by Jelmer Vernooij
Add BzrGitCache object.
307
            store._cache.idmap.commit_write_group()
0.200.256 by Jelmer Vernooij
Add tests for import_revision_gist.
308
309
    def test_pointless(self):
0.200.257 by Jelmer Vernooij
Add more details for commit, to avoid checksum from changing.
310
        revid = self.bzr_tree.commit("pointless", timestamp=1205433193,
7143.15.2 by Jelmer Vernooij
Run autopep8.
311
                                     timezone=0, committer="Jelmer Vernooij <jelmer@samba.org>")
312
        self.assertEqual(b"2caa8094a5b794961cd9bf582e3e2bb090db0b14",
313
                         self.import_rev(revid))
314
        self.assertEqual(b"2caa8094a5b794961cd9bf582e3e2bb090db0b14",
315
                         self.import_rev(revid))
0.200.658 by Jelmer Vernooij
Provide right infrastructure for foreign repository tests from bzrlib.
316
317
318
class ForeignTestsRepositoryFactory(object):
319
320
    def make_repository(self, transport):
0.200.1018 by Jelmer Vernooij
Fix use with new control dir API.
321
        return dir.LocalGitControlDirFormat().initialize_on_transport(transport).open_repository()