/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
1
# Copyright (C) 2008 Canonical Ltd
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
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
16
3389.2.6 by John Arbash Meinel
minor fix to test file comment
17
"""Tests for branch implementations - test check() functionality"""
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
18
4332.3.3 by Robert Collins
Alter Branch.check to log errors rather than raising.
19
from StringIO import StringIO
20
21
from bzrlib import errors, tests, ui
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
22
from bzrlib.tests.branch_implementations import TestCaseWithBranch
23
24
25
class TestBranchCheck(TestCaseWithBranch):
26
27
    def test_check_detects_invalid_revhistory(self):
28
        # Different formats have different ways of handling invalid revision
29
        # histories, so the setup portion is customized
30
        tree = self.make_branch_and_tree('test')
31
        r1 = tree.commit('one')
32
        r2 = tree.commit('two')
33
        r3 = tree.commit('three')
34
        r4 = tree.commit('four')
35
        # create an alternate branch
36
        tree.set_parent_ids([r1])
37
        tree.branch.set_last_revision_info(1, r1)
38
        r2b = tree.commit('two-b')
39
40
        # now go back and merge the commit
41
        tree.set_parent_ids([r4, r2b])
42
        tree.branch.set_last_revision_info(4, r4)
43
44
        r5 = tree.commit('five')
45
        # Now, try to set an invalid history
46
        try:
47
            tree.branch.set_revision_history([r1, r2b, r5])
3489.2.4 by Andrew Bennetts
Fix all tests broken by fixing make_branch_and_tree.
48
            if tree.branch.last_revision_info() != (3, r5):
49
                # RemoteBranch silently corrects an impossible revision
50
                # history given to set_revision_history.  It can be tricked
51
                # with set_last_revision_info though.
52
                tree.branch.set_last_revision_info(3, r5)
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
53
        except errors.NotLefthandHistory:
54
            # Branch5 allows set_revision_history to be wrong
55
            # Branch6 raises NotLefthandHistory, but we can force bogus stuff
56
            # with set_last_revision_info
57
            tree.branch.set_last_revision_info(3, r5)
58
4332.3.3 by Robert Collins
Alter Branch.check to log errors rather than raising.
59
        result = tree.branch.check()
60
        ui.ui_factory = tests.TestUIFactory(stdout=StringIO())
61
        result.report_results(True)
62
        self.assertContainsRe('revno does not match len',
63
            ui.ui_factory.stdout.getvalue())
3389.2.5 by John Arbash Meinel
Fix the line endings on test_check and test_reconcile
64
65
    def test_check_branch_report_results(self):
66
        """Checking a branch produces results which can be printed"""
67
        branch = self.make_branch('.')
68
        result = branch.check()
69
        # reports results through logging
70
        result.report_results(verbose=True)
71
        result.report_results(verbose=False)
72
73