1
# (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
import bzrlib.bzrdir as bzrdir
24
from bzrlib import bzrdir, errors, repository
25
25
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
26
from bzrlib.commit import commit
27
import bzrlib.errors as errors
26
from bzrlib.delta import TreeDelta
28
27
from bzrlib.errors import (FileExists,
31
30
UninitializableFormat,
34
import bzrlib.repository as repository
35
33
from bzrlib.revision import NULL_REVISION
36
34
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
37
35
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
167
165
revision_id=None,
168
166
pb=bzrlib.progress.DummyProgress())
168
def test_get_revision_delta(self):
169
tree_a = self.make_branch_and_tree('a')
170
self.build_tree(['a/foo'])
171
tree_a.add('foo', 'file1')
172
tree_a.commit('rev1', rev_id='rev1')
173
self.build_tree(['a/vla'])
174
tree_a.add('vla', 'file2')
175
tree_a.commit('rev2', rev_id='rev2')
177
delta = tree_a.branch.repository.get_revision_delta('rev1')
178
self.assertIsInstance(delta, TreeDelta)
179
self.assertEqual([('foo', 'file1', 'file')], delta.added)
180
delta = tree_a.branch.repository.get_revision_delta('rev2')
181
self.assertIsInstance(delta, TreeDelta)
182
self.assertEqual([('vla', 'file2', 'file')], delta.added)
170
184
def test_clone_bzrdir_repository_revision(self):
171
185
# make a repository with some revisions,
172
186
# and clone it, this should not have unreferenced revisions.
270
284
self.assertMessageRoundtrips(
271
285
"All 8-bit chars: " + ''.join([unichr(x) for x in range(256)]))
287
def test_check_repository(self):
288
"""Check a fairly simple repository's history"""
289
tree = self.make_branch_and_tree('.')
290
tree.commit('initial empty commit', rev_id='a-rev',
291
allow_pointless=True)
292
result = tree.branch.repository.check(['a-rev'])
293
# writes to log; should accept both verbose or non-verbose
294
result.report_results(verbose=True)
295
result.report_results(verbose=False)
297
def test_get_revisions(self):
298
tree = self.make_branch_and_tree('.')
299
tree.commit('initial empty commit', rev_id='a-rev',
300
allow_pointless=True)
301
tree.commit('second empty commit', rev_id='b-rev',
302
allow_pointless=True)
303
tree.commit('third empty commit', rev_id='c-rev',
304
allow_pointless=True)
305
repo = tree.branch.repository
306
revision_ids = ['a-rev', 'b-rev', 'c-rev']
307
revisions = repo.get_revisions(revision_ids)
308
assert len(revisions) == 3, repr(revisions)
309
zipped = zip(revisions, revision_ids)
310
self.assertEqual(len(zipped), 3)
311
for revision, revision_id in zipped:
312
self.assertEqual(revision.revision_id, revision_id)
313
self.assertEqual(revision, repo.get_revision(revision_id))
273
315
class TestCaseWithComplexRepository(TestCaseWithRepository):