/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_reconcile.py

  • Committer: John Arbash Meinel
  • Date: 2008-04-29 16:43:14 UTC
  • mto: This revision was merged to the branch mainline in revision 3394.
  • Revision ID: john@arbash-meinel.com-20080429164314-n3q4obl92y7suwah
Fix the line endings on test_check and test_reconcile

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
"""Tests for branch implementations - test reconcile() functionality"""
18
 
 
19
 
from bzrlib import errors, reconcile
20
 
from bzrlib.tests.branch_implementations import TestCaseWithBranch
21
 
 
22
 
 
23
 
class TestBranchReconcile(TestCaseWithBranch):
24
 
 
25
 
    def test_reconcile_fixes_invalid_revhistory(self):
26
 
        # Different formats have different ways of handling invalid revision
27
 
        # histories, so the setup portion is customized
28
 
        tree = self.make_branch_and_tree('test')
29
 
        r1 = tree.commit('one')
30
 
        r2 = tree.commit('two')
31
 
        r3 = tree.commit('three')
32
 
        r4 = tree.commit('four')
33
 
        # create an alternate branch
34
 
        tree.set_parent_ids([r1])
35
 
        tree.branch.set_last_revision_info(1, r1)
36
 
        r2b = tree.commit('two-b')
37
 
 
38
 
        # now go back and merge the commit
39
 
        tree.set_parent_ids([r4, r2b])
40
 
        tree.branch.set_last_revision_info(4, r4)
41
 
 
42
 
        r5 = tree.commit('five')
43
 
        # Now, try to set an invalid history
44
 
        try:
45
 
            tree.branch.set_revision_history([r1, r2b, r5])
46
 
        except errors.NotLefthandHistory:
47
 
            # Branch5 allows set_revision_history to be wrong
48
 
            # Branch6 raises NotLefthandHistory, but we can force bogus stuff
49
 
            # with set_last_revision_info
50
 
            tree.branch.set_last_revision_info(3, r5)
51
 
 
52
 
        self.assertEqual((3, r5), tree.branch.last_revision_info())
53
 
        reconciler = tree.branch.reconcile()
54
 
        self.assertEqual((5, r5), tree.branch.last_revision_info())
55
 
        self.assertIs(True, reconciler.fixed_history)
56
 
 
57
 
    def test_reconcile_returns_reconciler(self):
58
 
        a_branch = self.make_branch('a_branch')
59
 
        result = a_branch.reconcile()
60
 
        self.assertIsInstance(result, reconcile.BranchReconciler)
61
 
        # No history to fix
62
 
        self.assertIs(False, result.fixed_history)
63
 
 
64
 
    def test_reconcile_supports_thorough(self):
65
 
        a_branch = self.make_branch('a_branch')
66
 
        a_branch.reconcile(thorough=False)
67
 
        a_branch.reconcile(thorough=True)
 
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
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Tests for branch implementations - test reconcile() functionality"""
 
18
 
 
19
from bzrlib import errors, reconcile
 
20
from bzrlib.tests.branch_implementations import TestCaseWithBranch
 
21
 
 
22
 
 
23
class TestBranchReconcile(TestCaseWithBranch):
 
24
 
 
25
    def test_reconcile_fixes_invalid_revhistory(self):
 
26
        # Different formats have different ways of handling invalid revision
 
27
        # histories, so the setup portion is customized
 
28
        tree = self.make_branch_and_tree('test')
 
29
        r1 = tree.commit('one')
 
30
        r2 = tree.commit('two')
 
31
        r3 = tree.commit('three')
 
32
        r4 = tree.commit('four')
 
33
        # create an alternate branch
 
34
        tree.set_parent_ids([r1])
 
35
        tree.branch.set_last_revision_info(1, r1)
 
36
        r2b = tree.commit('two-b')
 
37
 
 
38
        # now go back and merge the commit
 
39
        tree.set_parent_ids([r4, r2b])
 
40
        tree.branch.set_last_revision_info(4, r4)
 
41
 
 
42
        r5 = tree.commit('five')
 
43
        # Now, try to set an invalid history
 
44
        try:
 
45
            tree.branch.set_revision_history([r1, r2b, r5])
 
46
        except errors.NotLefthandHistory:
 
47
            # Branch5 allows set_revision_history to be wrong
 
48
            # Branch6 raises NotLefthandHistory, but we can force bogus stuff
 
49
            # with set_last_revision_info
 
50
            tree.branch.set_last_revision_info(3, r5)
 
51
 
 
52
        self.assertEqual((3, r5), tree.branch.last_revision_info())
 
53
        reconciler = tree.branch.reconcile()
 
54
        self.assertEqual((5, r5), tree.branch.last_revision_info())
 
55
        self.assertIs(True, reconciler.fixed_history)
 
56
 
 
57
    def test_reconcile_returns_reconciler(self):
 
58
        a_branch = self.make_branch('a_branch')
 
59
        result = a_branch.reconcile()
 
60
        self.assertIsInstance(result, reconcile.BranchReconciler)
 
61
        # No history to fix
 
62
        self.assertIs(False, result.fixed_history)
 
63
 
 
64
    def test_reconcile_supports_thorough(self):
 
65
        a_branch = self.make_branch('a_branch')
 
66
        a_branch.reconcile(thorough=False)
 
67
        a_branch.reconcile(thorough=True)