/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2010, 2011 Canonical Ltd
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
17
from breezy import (
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
18
    conflicts,
19
    tests,
20
    )
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
21
from breezy.tests import (
22
    script,
23
    KnownFailure,
24
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
25
from breezy.tests.blackbox import test_conflicts
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
26
27
28
class TestResolve(script.TestCaseWithTransportAndScript):
29
30
    def setUp(self):
31
        super(TestResolve, self).setUp()
32
        test_conflicts.make_tree_with_conflicts(self, 'branch', 'other')
33
34
    def test_resolve_one_by_one(self):
35
        self.run_script("""\
36
$ cd branch
6622.1.29 by Jelmer Vernooij
Fix some more tests.
37
$ brz conflicts
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
38
Text conflict in my_other_file
39
Path conflict: mydir3 / mydir2
40
Text conflict in myfile
6622.1.29 by Jelmer Vernooij
Fix some more tests.
41
$ brz resolve myfile
6138.3.5 by Jonathan Riddell
make the test suite pass
42
2>1 conflict resolved, 2 remaining
6622.1.29 by Jelmer Vernooij
Fix some more tests.
43
$ brz resolve my_other_file
6138.3.5 by Jonathan Riddell
make the test suite pass
44
2>1 conflict resolved, 1 remaining
6622.1.29 by Jelmer Vernooij
Fix some more tests.
45
$ brz resolve mydir2
6138.3.5 by Jonathan Riddell
make the test suite pass
46
2>1 conflict resolved, 0 remaining
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
47
""")
48
49
    def test_resolve_all(self):
50
        self.run_script("""\
51
$ cd branch
6622.1.29 by Jelmer Vernooij
Fix some more tests.
52
$ brz resolve --all
6138.3.5 by Jonathan Riddell
make the test suite pass
53
2>3 conflicts resolved, 0 remaining
6622.1.29 by Jelmer Vernooij
Fix some more tests.
54
$ brz conflicts
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
55
""")
56
57
    def test_resolve_from_subdir(self):
58
        self.run_script("""\
59
$ mkdir branch/subdir
60
$ cd branch/subdir
6622.1.29 by Jelmer Vernooij
Fix some more tests.
61
$ brz resolve ../myfile
6138.3.5 by Jonathan Riddell
make the test suite pass
62
2>1 conflict resolved, 2 remaining
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
63
""")
64
65
    def test_resolve_via_directory_option(self):
66
        self.run_script("""\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
67
$ brz resolve -d branch myfile
6138.3.5 by Jonathan Riddell
make the test suite pass
68
2>1 conflict resolved, 2 remaining
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
69
""")
70
71
    def test_resolve_all_via_directory_option(self):
72
        self.run_script("""\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
73
$ brz resolve -d branch --all
6138.3.5 by Jonathan Riddell
make the test suite pass
74
2>3 conflicts resolved, 0 remaining
6622.1.29 by Jelmer Vernooij
Fix some more tests.
75
$ brz conflicts -d branch
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
76
""")
77
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
78
    def test_bug_842575_manual_rm(self):
79
        self.run_script("""\
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
80
$ brz init -q trunk
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
81
$ echo original > trunk/foo
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
82
$ brz add -q trunk/foo
83
$ brz commit -q -m first trunk
84
$ brz checkout -q trunk tree
85
$ brz rm -q trunk/foo
86
$ brz commit -q -m second trunk
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
87
$ echo modified > tree/foo
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
88
$ brz update tree
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
89
2>RM  foo => foo.THIS
90
2>Contents conflict in foo
91
2>1 conflicts encountered.
92
2>Updated to revision 2 of branch ...
93
$ rm tree/foo.BASE tree/foo.THIS
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
94
$ brz resolve --all -d tree
95
2>1 conflict resolved, 0 remaining
96
""")
97
        try:
98
            self.run_script("""\
99
$ brz status tree
100
""")
101
        except AssertionError:
102
            raise KnownFailure("bug #842575")
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
103
104
    def test_bug_842575_take_other(self):
105
        self.run_script("""\
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
106
$ brz init -q trunk
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
107
$ echo original > trunk/foo
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
108
$ brz add -q trunk/foo
109
$ brz commit -q -m first trunk
110
$ brz checkout -q --lightweight trunk tree
111
$ brz rm -q trunk/foo
112
$ brz ignore -d trunk foo
113
$ brz commit -q -m second trunk
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
114
$ echo modified > tree/foo
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
115
$ brz update tree
6123.12.4 by Martin von Gagern
Catch one more detail in #842575 test case.
116
2>+N  .bzrignore
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
117
2>RM  foo => foo.THIS
118
2>Contents conflict in foo
119
2>1 conflicts encountered.
120
2>Updated to revision 2 of branch ...
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
121
$ brz resolve --take-other --all -d tree
122
2>1 conflict resolved, 0 remaining
123
""")
124
        try:
125
            self.run_script("""\
126
$ brz status tree
6123.12.4 by Martin von Gagern
Catch one more detail in #842575 test case.
127
$ echo mustignore > tree/foo
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
128
$ brz status tree
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
129
""")
6833.4.1 by Jelmer Vernooij
Merge tests from Martin von Gagern, raise KnownFailure.
130
        except AssertionError:
131
            raise KnownFailure("bug 842575")
6123.12.1 by Martin von Gagern
Added blackbox test scripts exposing bug lp:842575.
132
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
133
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
134
class TestBug788000(script.TestCaseWithTransportAndScript):
135
136
    def test_bug_788000(self):
137
        self.run_script('''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
138
$ brz init a
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
139
$ mkdir a/dir
140
$ echo foo > a/dir/file
6622.1.29 by Jelmer Vernooij
Fix some more tests.
141
$ brz add a/dir
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
142
$ cd a
6622.1.29 by Jelmer Vernooij
Fix some more tests.
143
$ brz commit -m one
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
144
$ cd ..
6690.3.2 by Jelmer Vernooij
Use branch rather than clone.
145
$ brz branch a b
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
146
$ echo bar > b/dir/file
147
$ cd a
148
$ rm -r dir
6622.1.29 by Jelmer Vernooij
Fix some more tests.
149
$ brz commit -m two
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
150
$ cd ../b
151
''',
152
                        null_output_matches_anything=True)
153
154
        self.run_script('''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
155
$ brz pull
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
156
Using saved parent location:...
157
Now on revision 2.
158
2>RM  dir/file => dir/file.THIS
159
2>Conflict: can't delete dir because it is not empty.  Not deleting.
160
2>Conflict because dir is not versioned, but has versioned children...
161
2>Contents conflict in dir/file
162
2>3 conflicts encountered.
163
''')
164
        self.run_script('''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
165
$ brz resolve --take-other
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
166
2>deleted dir/file.THIS
167
2>deleted dir
6138.3.5 by Jonathan Riddell
make the test suite pass
168
2>3 conflicts resolved, 0 remaining
5972.1.1 by Vincent Ladeuil
Make ContentConflict resolution more robust
169
''')
170
171
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
172
class TestResolveAuto(tests.TestCaseWithTransport):
173
174
    def test_auto_resolve(self):
175
        """Text conflicts can be resolved automatically"""
176
        tree = self.make_branch_and_tree('tree')
177
        self.build_tree_contents([('tree/file',
6855.4.1 by Jelmer Vernooij
Yet more bees.
178
            b'<<<<<<<\na\n=======\n>>>>>>>\n')])
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
179
        tree.add('file', 'file_id')
6809.4.7 by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind.
180
        self.assertEqual(tree.kind('file', 'file_id'), 'file')
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
181
        file_conflict = conflicts.TextConflict('file', file_id='file_id')
182
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
183
        note = self.run_bzr('resolve', retcode=1, working_dir='tree')[1]
6143.1.4 by Jonathan Riddell
update tests
184
        self.assertContainsRe(note, '0 conflicts auto-resolved.')
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
185
        self.assertContainsRe(note,
186
            'Remaining conflicts:\nText conflict in file')
6855.4.1 by Jelmer Vernooij
Yet more bees.
187
        self.build_tree_contents([('tree/file', b'a\n')])
4597.9.19 by Vincent Ladeuil
resolve now reports conflicts resolved/remaining.
188
        note = self.run_bzr('resolve', working_dir='tree')[1]
189
        self.assertContainsRe(note, 'All conflicts resolved.')