~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 (
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)
21
    config as _mod_config,
2745.6.1 by Aaron Bentley
Initial checking of knit graphs
22
    revision as _mod_revision,
23
    )
3689.1.1 by John Arbash Meinel
Rename repository_implementations tests into per_repository tests
24
from bzrlib.tests.per_repository import TestCaseWithRepository
2819.2.1 by Andrew Bennetts
Implement KnitRepository._find_inconsistent_revision_parents.
25
26
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
27
class TestNoSpuriousInconsistentAncestors(TestCaseWithRepository):
28
29
    def test_two_files_different_versions_no_inconsistencies_bug_165071(self):
30
        """Two files, with different versions can be clean."""
31
        tree = self.make_branch_and_tree('.')
32
        self.build_tree(['foo'])
33
        tree.smart_add(['.'])
4332.3.11 by Robert Collins
Move tree and back callbacks into the repository check core.
34
        revid1 = tree.commit('1')
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
35
        self.build_tree(['bar'])
36
        tree.smart_add(['.'])
4332.3.11 by Robert Collins
Move tree and back callbacks into the repository check core.
37
        revid2 = tree.commit('2')
38
        check_object = tree.branch.repository.check([revid1, revid2])
4245.1.1 by Ian Clatworthy
minor test clean-ups & _reconcile_pack API
39
        check_object.report_results(verbose=True)
4794.1.15 by Robert Collins
Review feedback.
40
        self.assertContainsRe(self.get_log(), "0 unreferenced text versions")
3036.1.1 by Robert Collins
* ``check`` no longer reports spurious unreferenced text versions.
41
42
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)
43
class TestCleanRepository(TestCaseWithRepository):
44
45
    def test_new_repo(self):
46
        repo = self.make_repository('foo')
47
        repo.lock_write()
48
        self.addCleanup(repo.unlock)
49
        config = _mod_config.Config()
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
50
        self.overrideEnv('BZR_EMAIL', 'foo@sample.com')
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)
51
        builder = repo.get_commit_builder(None, [], config)
52
        list(builder.record_iter_changes(None, _mod_revision.NULL_REVISION, [
53
            ('TREE_ROOT', (None, ''), True, (False, True), (None, None),
54
            (None, ''), (None, 'directory'), (None, False))]))
55
        builder.finish_inventory()
56
        rev_id = builder.commit('first post')
57
        result = repo.check(None, check_repo=True)
58
        result.report_results(True)
4794.1.15 by Robert Collins
Review feedback.
59
        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)
60
        self.assertFalse('Missing' in log, "Something was missing in %r" % log)