~bzr-pqm/bzr/bzr.dev

5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2007-2011 Canonical Ltd
2745.6.7 by Aaron Bentley
Clean-up
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2745.6.7 by Aaron Bentley
Clean-up
16
17
18
"""Test operations that check the repository for corruption"""
19
2745.6.1 by Aaron Bentley
Initial checking of knit graphs
20
from bzrlib import (
21
    revision as _mod_revision,
22
    )
3689.1.1 by John Arbash Meinel
Rename repository_implementations tests into per_repository tests
23
from bzrlib.tests.per_repository import TestCaseWithRepository
2819.2.1 by Andrew Bennetts
Implement KnitRepository._find_inconsistent_revision_parents.
24
25
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
26
class TestNoSpuriousInconsistentAncestors(TestCaseWithRepository):
27
28
    def test_two_files_different_versions_no_inconsistencies_bug_165071(self):
29
        """Two files, with different versions can be clean."""
30
        tree = self.make_branch_and_tree('.')
31
        self.build_tree(['foo'])
32
        tree.smart_add(['.'])
4332.3.11 by Robert Collins
Move tree and back callbacks into the repository check core.
33
        revid1 = tree.commit('1')
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
34
        self.build_tree(['bar'])
35
        tree.smart_add(['.'])
4332.3.11 by Robert Collins
Move tree and back callbacks into the repository check core.
36
        revid2 = tree.commit('2')
37
        check_object = tree.branch.repository.check([revid1, revid2])
4245.1.1 by Ian Clatworthy
minor test clean-ups & _reconcile_pack API
38
        check_object.report_results(verbose=True)
4794.1.15 by Robert Collins
Review feedback.
39
        self.assertContainsRe(self.get_log(), "0 unreferenced text versions")
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
40
41
4657.1.1 by Robert Collins
Do not add the root directory entry to the list of expected keys during check in non rich-root repositories. (#416732)
42
class TestCleanRepository(TestCaseWithRepository):
43
44
    def test_new_repo(self):
6127.1.1 by Jelmer Vernooij
Use Branch.get_commit_builder, as Repository.get_commit_builder without Branch breaks with bzr-svn.
45
        branch = self.make_branch('foo')
46
        branch.lock_write()
47
        self.addCleanup(branch.unlock)
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
48
        self.overrideEnv('BZR_EMAIL', 'foo@sample.com')
6127.1.1 by Jelmer Vernooij
Use Branch.get_commit_builder, as Repository.get_commit_builder without Branch breaks with bzr-svn.
49
        builder = branch.get_commit_builder([], branch.get_config())
4657.1.1 by Robert Collins
Do not add the root directory entry to the list of expected keys during check in non rich-root repositories. (#416732)
50
        list(builder.record_iter_changes(None, _mod_revision.NULL_REVISION, [
51
            ('TREE_ROOT', (None, ''), True, (False, True), (None, None),
52
            (None, ''), (None, 'directory'), (None, False))]))
53
        builder.finish_inventory()
54
        rev_id = builder.commit('first post')
6127.1.1 by Jelmer Vernooij
Use Branch.get_commit_builder, as Repository.get_commit_builder without Branch breaks with bzr-svn.
55
        result = branch.repository.check(None, check_repo=True)
4657.1.1 by Robert Collins
Do not add the root directory entry to the list of expected keys during check in non rich-root repositories. (#416732)
56
        result.report_results(True)
4794.1.15 by Robert Collins
Review feedback.
57
        log = self.get_log()
4657.1.1 by Robert Collins
Do not add the root directory entry to the list of expected keys during check in non rich-root repositories. (#416732)
58
        self.assertFalse('Missing' in log, "Something was missing in %r" % log)