~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_repository.py

  • Committer: Martin Pool
  • Date: 2006-06-20 07:55:43 UTC
  • mfrom: (1798 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1799.
  • Revision ID: mbp@sourcefrog.net-20060620075543-b10f6575d4a4fa32
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
 
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
21
21
import sys
22
22
 
23
23
import bzrlib
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,
29
28
                           NoSuchRevision,
30
29
                           NoSuchFile,
31
30
                           UninitializableFormat,
32
31
                           NotBranchError,
33
32
                           )
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())
169
167
 
 
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')
 
176
 
 
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)
 
183
 
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)]))
272
286
 
 
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)
 
296
 
 
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))
 
314
 
273
315
class TestCaseWithComplexRepository(TestCaseWithRepository):
274
316
 
275
317
    def setUp(self):