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