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