/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-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

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