/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 breezy/tests/blackbox/test_resolve.py

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010, 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
from breezy import (
18
 
    conflicts,
19
 
    tests,
20
 
    )
21
 
from breezy.bzr import conflicts as _mod_bzr_conflicts
22
 
from breezy.tests import (
23
 
    script,
24
 
    KnownFailure,
25
 
    )
26
 
from breezy.tests.blackbox import test_conflicts
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
38
 
$ brz conflicts
39
 
Text conflict in my_other_file
40
 
Path conflict: mydir3 / mydir2
41
 
Text conflict in myfile
42
 
$ brz resolve myfile
43
 
2>1 conflict resolved, 2 remaining
44
 
$ brz resolve my_other_file
45
 
2>1 conflict resolved, 1 remaining
46
 
$ brz resolve mydir2
47
 
2>1 conflict resolved, 0 remaining
48
 
""")
49
 
 
50
 
    def test_resolve_all(self):
51
 
        self.run_script("""\
52
 
$ cd branch
53
 
$ brz resolve --all
54
 
2>3 conflicts resolved, 0 remaining
55
 
$ brz conflicts
56
 
""")
57
 
 
58
 
    def test_resolve_from_subdir(self):
59
 
        self.run_script("""\
60
 
$ mkdir branch/subdir
61
 
$ cd branch/subdir
62
 
$ brz resolve ../myfile
63
 
2>1 conflict resolved, 2 remaining
64
 
""")
65
 
 
66
 
    def test_resolve_via_directory_option(self):
67
 
        self.run_script("""\
68
 
$ brz resolve -d branch myfile
69
 
2>1 conflict resolved, 2 remaining
70
 
""")
71
 
 
72
 
    def test_resolve_all_via_directory_option(self):
73
 
        self.run_script("""\
74
 
$ brz resolve -d branch --all
75
 
2>3 conflicts resolved, 0 remaining
76
 
$ brz conflicts -d branch
77
 
""")
78
 
 
79
 
    def test_bug_842575_manual_rm(self):
80
 
        self.run_script("""\
81
 
$ brz init -q trunk
82
 
$ echo original > trunk/foo
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
88
 
$ echo modified > tree/foo
89
 
$ brz update tree
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
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")
104
 
 
105
 
    def test_bug_842575_take_other(self):
106
 
        self.run_script("""\
107
 
$ brz init -q trunk
108
 
$ echo original > trunk/foo
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
115
 
$ echo modified > tree/foo
116
 
$ brz update tree
117
 
2>+N  .bzrignore
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 ...
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
128
 
$ echo mustignore > tree/foo
129
 
$ brz status tree
130
 
""")
131
 
        except AssertionError:
132
 
            raise KnownFailure("bug 842575")
133
 
 
134
 
 
135
 
class TestBug788000(script.TestCaseWithTransportAndScript):
136
 
 
137
 
    def test_bug_788000(self):
138
 
        self.run_script('''\
139
 
$ brz init a
140
 
$ mkdir a/dir
141
 
$ echo foo > a/dir/file
142
 
$ brz add a/dir
143
 
$ cd a
144
 
$ brz commit -m one
145
 
$ cd ..
146
 
$ brz branch a b
147
 
$ echo bar > b/dir/file
148
 
$ cd a
149
 
$ rm -r dir
150
 
$ brz commit -m two
151
 
$ cd ../b
152
 
''',
153
 
                        null_output_matches_anything=True)
154
 
 
155
 
        self.run_script('''\
156
 
$ brz pull
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('''\
166
 
$ brz resolve --take-other
167
 
2>deleted dir/file.THIS
168
 
2>deleted dir
169
 
2>3 conflicts resolved, 0 remaining
170
 
''')
171
 
 
172
 
 
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',
179
 
                                   b'<<<<<<<\na\n=======\n>>>>>>>\n')])
180
 
        tree.add('file', b'file_id')
181
 
        self.assertEqual(tree.kind('file'), 'file')
182
 
        file_conflict = _mod_bzr_conflicts.TextConflict('file', file_id=b'file_id')
183
 
        tree.set_conflicts([file_conflict])
184
 
        note = self.run_bzr('resolve', retcode=1, working_dir='tree')[1]
185
 
        self.assertContainsRe(note, '0 conflicts auto-resolved.')
186
 
        self.assertContainsRe(note,
187
 
                              'Remaining conflicts:\nText conflict in file')
188
 
        self.build_tree_contents([('tree/file', b'a\n')])
189
 
        note = self.run_bzr('resolve', working_dir='tree')[1]
190
 
        self.assertContainsRe(note, 'All conflicts resolved.')