/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.15 by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt
1
# Copyright (C) 2005-2011 Canonical Ltd
1399.1.12 by Robert Collins
add new test script
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1399.1.12 by Robert Collins
add new test script
17
18
import os
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
19
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
20
from bzrlib import (
21
    bzrdir,
22
    conflicts,
23
    errors,
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
24
    transport,
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
25
    workingtree,
26
    )
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
27
from bzrlib.lockdir import LockDir
1986.1.8 by Robert Collins
Update to bzr.dev, which involves adding lock_tree_write to MutableTree and MemoryTree.
28
from bzrlib.mutabletree import needs_tree_write_lock
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
29
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
30
from bzrlib.workingtree import (
31
    TreeEntry,
32
    TreeDirectory,
33
    TreeFile,
34
    TreeLink,
35
    )
1399.1.12 by Robert Collins
add new test script
36
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
37
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
38
class TestTreeDirectory(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
39
40
    def test_kind_character(self):
41
        self.assertEqual(TreeDirectory().kind_character(), '/')
42
43
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
44
class TestTreeEntry(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
45
46
    def test_kind_character(self):
47
        self.assertEqual(TreeEntry().kind_character(), '???')
48
49
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
50
class TestTreeFile(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
51
52
    def test_kind_character(self):
53
        self.assertEqual(TreeFile().kind_character(), '')
54
55
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
56
class TestTreeLink(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
57
58
    def test_kind_character(self):
59
        self.assertEqual(TreeLink().kind_character(), '')
60
61
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
62
class TestDefaultFormat(TestCaseWithTransport):
63
64
    def test_get_set_default_format(self):
65
        old_format = workingtree.WorkingTreeFormat.get_default_format()
66
        # default is 3
67
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
68
        workingtree.WorkingTreeFormat.set_default_format(SampleTreeFormat())
69
        try:
70
            # the default branch format is used by the meta dir format
71
            # which is not the default bzrdir format at this point
72
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
73
            dir.create_repository()
74
            dir.create_branch()
75
            result = dir.create_workingtree()
76
            self.assertEqual(result, 'A tree')
77
        finally:
78
            workingtree.WorkingTreeFormat.set_default_format(old_format)
79
        self.assertEqual(old_format, workingtree.WorkingTreeFormat.get_default_format())
80
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
81
    def test_open(self):
82
        tree = self.make_branch_and_tree('.')
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
83
        open_direct = workingtree.WorkingTree.open('.')
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
84
        self.assertEqual(tree.basedir, open_direct.basedir)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
85
        open_no_args = workingtree.WorkingTree.open()
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
86
        self.assertEqual(tree.basedir, open_no_args.basedir)
87
88
    def test_open_containing(self):
89
        tree = self.make_branch_and_tree('.')
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
90
        open_direct, relpath = workingtree.WorkingTree.open_containing('.')
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
91
        self.assertEqual(tree.basedir, open_direct.basedir)
92
        self.assertEqual('', relpath)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
93
        open_no_args, relpath = workingtree.WorkingTree.open_containing()
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
94
        self.assertEqual(tree.basedir, open_no_args.basedir)
95
        self.assertEqual('', relpath)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
96
        open_subdir, relpath = workingtree.WorkingTree.open_containing('subdir')
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
97
        self.assertEqual(tree.basedir, open_subdir.basedir)
98
        self.assertEqual('subdir', relpath)
99
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
100
101
class SampleTreeFormat(workingtree.WorkingTreeFormat):
102
    """A sample format
103
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
104
    this format is initializable, unsupported to aid in testing the
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
105
    open and open_downlevel routines.
106
    """
107
108
    def get_format_string(self):
109
        """See WorkingTreeFormat.get_format_string()."""
110
        return "Sample tree format."
111
3123.5.3 by Aaron Bentley
Get tests passing with accelerator_tree
112
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
3136.1.5 by Aaron Bentley
Fix sample workingtree format
113
                   accelerator_tree=None, hardlink=False):
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
114
        """Sample branches cannot be created."""
115
        t = a_bzrdir.get_workingtree_transport(self)
1955.3.13 by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings.
116
        t.put_bytes('format', self.get_format_string())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
117
        return 'A tree'
118
119
    def is_supported(self):
120
        return False
121
122
    def open(self, transport, _found=False):
123
        return "opened tree."
124
125
126
class TestWorkingTreeFormat(TestCaseWithTransport):
127
    """Tests for the WorkingTreeFormat facility."""
128
129
    def test_find_format(self):
130
        # is the right format object found for a working tree?
131
        # create a branch with a few known format objects.
132
        self.build_tree(["foo/", "bar/"])
133
        def check_format(format, url):
134
            dir = format._matchingbzrdir.initialize(url)
135
            dir.create_repository()
136
            dir.create_branch()
137
            format.initialize(dir)
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
138
            t = transport.get_transport(url)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
139
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
140
            self.failUnless(isinstance(found_format, format.__class__))
141
        check_format(workingtree.WorkingTreeFormat3(), "bar")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
142
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
143
    def test_find_format_no_tree(self):
144
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
145
        self.assertRaises(errors.NoWorkingTree,
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
146
                          workingtree.WorkingTreeFormat.find_format,
147
                          dir)
148
149
    def test_find_format_unknown_format(self):
150
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
151
        dir.create_repository()
152
        dir.create_branch()
153
        SampleTreeFormat().initialize(dir)
154
        self.assertRaises(errors.UnknownFormatError,
155
                          workingtree.WorkingTreeFormat.find_format,
156
                          dir)
157
158
    def test_register_unregister_format(self):
159
        format = SampleTreeFormat()
160
        # make a control dir
161
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
162
        dir.create_repository()
163
        dir.create_branch()
164
        # make a branch
165
        format.initialize(dir)
166
        # register a format for it.
167
        workingtree.WorkingTreeFormat.register_format(format)
168
        # which branch.Open will refuse (not supported)
169
        self.assertRaises(errors.UnsupportedFormatError, workingtree.WorkingTree.open, '.')
170
        # but open_downlevel will work
171
        self.assertEqual(format.open(dir), workingtree.WorkingTree.open_downlevel('.'))
172
        # unregister the format
173
        workingtree.WorkingTreeFormat.unregister_format(format)
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
174
175
176
class TestWorkingTreeFormat3(TestCaseWithTransport):
177
    """Tests specific to WorkingTreeFormat3."""
178
179
    def test_disk_layout(self):
180
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
181
        control.create_repository()
182
        control.create_branch()
183
        tree = workingtree.WorkingTreeFormat3().initialize(control)
184
        # we want:
185
        # format 'Bazaar-NG Working Tree format 3'
186
        # inventory = blank inventory
187
        # pending-merges = ''
188
        # stat-cache = ??
189
        # no inventory.basis yet
190
        t = control.get_workingtree_transport(None)
1553.5.81 by Martin Pool
Revert change to WorkingTreeFormat3 format string; too many things want it the old way
191
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
192
                             t.get('format').read())
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
193
        self.assertEqualDiff(t.get('inventory').read(),
2100.3.12 by Aaron Bentley
Stop generating unique roots for WorkingTree3
194
                              '<inventory format="5">\n'
1731.1.33 by Aaron Bentley
Revert no-special-root changes
195
                              '</inventory>\n',
196
                             )
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
197
        self.assertEqualDiff('### bzr hashcache v5\n',
198
                             t.get('stat-cache').read())
199
        self.assertFalse(t.has('inventory.basis'))
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
200
        # no last-revision file means 'None' or 'NULLREVISION'
201
        self.assertFalse(t.has('last-revision'))
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
202
        # TODO RBC 20060210 do a commit, check the inventory.basis is created
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
203
        # correctly and last-revision file becomes present.
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
204
205
    def test_uses_lockdir(self):
206
        """WorkingTreeFormat3 uses its own LockDir:
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
207
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
208
            - lock is a directory
209
            - when the WorkingTree is locked, LockDir can see that
210
        """
211
        t = self.get_transport()
212
        url = self.get_url()
213
        dir = bzrdir.BzrDirMetaFormat1().initialize(url)
214
        repo = dir.create_repository()
215
        branch = dir.create_branch()
1558.10.1 by Aaron Bentley
Handle lockdirs over NFS properly
216
        try:
217
            tree = workingtree.WorkingTreeFormat3().initialize(dir)
218
        except errors.NotLocalUrl:
219
            raise TestSkipped('Not a local URL')
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
220
        self.assertIsDirectory('.bzr', t)
221
        self.assertIsDirectory('.bzr/checkout', t)
222
        self.assertIsDirectory('.bzr/checkout/lock', t)
223
        our_lock = LockDir(t, '.bzr/checkout/lock')
224
        self.assertEquals(our_lock.peek(), None)
1553.5.75 by Martin Pool
Additional WorkingTree LockDir test
225
        tree.lock_write()
226
        self.assertTrue(our_lock.peek())
227
        tree.unlock()
228
        self.assertEquals(our_lock.peek(), None)
1534.10.6 by Aaron Bentley
Conflict serialization working for WorkingTree3
229
1815.2.2 by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests.
230
    def test_missing_pending_merges(self):
231
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
232
        control.create_repository()
233
        control.create_branch()
234
        tree = workingtree.WorkingTreeFormat3().initialize(control)
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
235
        tree._transport.delete("pending-merges")
1908.6.11 by Robert Collins
Remove usage of tree.pending_merges().
236
        self.assertEqual([], tree.get_parent_ids())
1815.2.2 by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests.
237
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
238
239
class TestFormat2WorkingTree(TestCaseWithTransport):
240
    """Tests that are specific to format 2 trees."""
241
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
242
    def create_format2_tree(self, url):
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
243
        return self.make_branch_and_tree(
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
244
            url, format=bzrdir.BzrDirFormat6())
1534.10.6 by Aaron Bentley
Conflict serialization working for WorkingTree3
245
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
246
    def test_conflicts(self):
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
247
        # test backwards compatability
248
        tree = self.create_format2_tree('.')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
249
        self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
250
                          None)
251
        file('lala.BASE', 'wb').write('labase')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
252
        expected = conflicts.ContentsConflict('lala')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
253
        self.assertEqual(list(tree.conflicts()), [expected])
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
254
        file('lala', 'wb').write('la')
255
        tree.add('lala', 'lala-id')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
256
        expected = conflicts.ContentsConflict('lala', file_id='lala-id')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
257
        self.assertEqual(list(tree.conflicts()), [expected])
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
258
        file('lala.THIS', 'wb').write('lathis')
259
        file('lala.OTHER', 'wb').write('laother')
260
        # When "text conflict"s happen, stem, THIS and OTHER are text
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
261
        expected = conflicts.TextConflict('lala', file_id='lala-id')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
262
        self.assertEqual(list(tree.conflicts()), [expected])
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
263
        os.unlink('lala.OTHER')
264
        os.mkdir('lala.OTHER')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
265
        expected = conflicts.ContentsConflict('lala', file_id='lala-id')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
266
        self.assertEqual(list(tree.conflicts()), [expected])
1713.2.3 by Robert Collins
Combine ignore rules into a single regex preventing pathological behaviour during add.
267
268
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
269
class InstrumentedTree(object):
270
    """A instrumented tree to check the needs_tree_write_lock decorator."""
271
272
    def __init__(self):
273
        self._locks = []
274
275
    def lock_tree_write(self):
276
        self._locks.append('t')
277
278
    @needs_tree_write_lock
279
    def method_with_tree_write_lock(self, *args, **kwargs):
280
        """A lock_tree_write decorated method that returns its arguments."""
281
        return args, kwargs
282
283
    @needs_tree_write_lock
284
    def method_that_raises(self):
285
        """This method causes an exception when called with parameters.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
286
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
287
        This allows the decorator code to be checked - it should still call
288
        unlock.
289
        """
290
291
    def unlock(self):
292
        self._locks.append('u')
293
294
295
class TestInstrumentedTree(TestCase):
296
297
    def test_needs_tree_write_lock(self):
298
        """@needs_tree_write_lock should be semantically transparent."""
299
        tree = InstrumentedTree()
300
        self.assertEqual(
301
            'method_with_tree_write_lock',
302
            tree.method_with_tree_write_lock.__name__)
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
303
        self.assertDocstring(
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
304
            "A lock_tree_write decorated method that returns its arguments.",
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
305
            tree.method_with_tree_write_lock)
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
306
        args = (1, 2, 3)
307
        kwargs = {'a':'b'}
308
        result = tree.method_with_tree_write_lock(1,2,3, a='b')
309
        self.assertEqual((args, kwargs), result)
310
        self.assertEqual(['t', 'u'], tree._locks)
311
        self.assertRaises(TypeError, tree.method_that_raises, 'foo')
312
        self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
313
314
3017.2.1 by Aaron Bentley
Revert now resolves conflicts recursively (#102739)
315
class TestRevert(TestCaseWithTransport):
316
317
    def test_revert_conflicts_recursive(self):
318
        this_tree = self.make_branch_and_tree('this-tree')
319
        self.build_tree_contents([('this-tree/foo/',),
320
                                  ('this-tree/foo/bar', 'bar')])
321
        this_tree.add(['foo', 'foo/bar'])
322
        this_tree.commit('created foo/bar')
323
        other_tree = this_tree.bzrdir.sprout('other-tree').open_workingtree()
324
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
325
        other_tree.commit('changed bar')
326
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
327
        this_tree.commit('changed qux')
328
        this_tree.merge_from_branch(other_tree.branch)
329
        self.assertEqual(1, len(this_tree.conflicts()))
330
        this_tree.revert(['foo'])
331
        self.assertEqual(0, len(this_tree.conflicts()))
332
333
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
334
class TestAutoResolve(TestCaseWithTransport):
335
336
    def test_auto_resolve(self):
337
        base = self.make_branch_and_tree('base')
338
        self.build_tree_contents([('base/hello', 'Hello')])
339
        base.add('hello', 'hello_id')
340
        base.commit('Hello')
341
        other = base.bzrdir.sprout('other').open_workingtree()
342
        self.build_tree_contents([('other/hello', 'hELLO')])
343
        other.commit('Case switch')
344
        this = base.bzrdir.sprout('this').open_workingtree()
345
        self.failUnlessExists('this/hello')
346
        self.build_tree_contents([('this/hello', 'Hello World')])
347
        this.commit('Add World')
348
        this.merge_from_branch(other.branch)
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
349
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
350
                         this.conflicts())
351
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
352
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
353
                         this.conflicts())
354
        self.build_tree_contents([('this/hello', '<<<<<<<')])
355
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
356
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
357
                         this.conflicts())
358
        self.build_tree_contents([('this/hello', '=======')])
359
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
360
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
361
                         this.conflicts())
362
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
363
        remaining, resolved = this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
364
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
365
                         this.conflicts())
366
        self.assertEqual([], resolved)
367
        self.build_tree_contents([('this/hello', 'hELLO wORLD')])
368
        remaining, resolved = this.auto_resolve()
369
        self.assertEqual([], this.conflicts())
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
370
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
371
                         resolved)
372
        self.failIfExists('this/hello.BASE')
2120.7.3 by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved
373
374
    def test_auto_resolve_dir(self):
375
        tree = self.make_branch_and_tree('tree')
376
        self.build_tree(['tree/hello/'])
377
        tree.add('hello', 'hello-id')
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
378
        file_conflict = conflicts.TextConflict('file', 'hello-id')
2120.7.3 by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved
379
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
380
        tree.auto_resolve()
3140.1.4 by Aaron Bentley
Add WorkingTree.find_trees
381
382
383
class TestFindTrees(TestCaseWithTransport):
384
385
    def test_find_trees(self):
386
        self.make_branch_and_tree('foo')
387
        self.make_branch_and_tree('foo/bar')
388
        # Sticking a tree inside a control dir is heinous, so let's skip it
389
        self.make_branch_and_tree('foo/.bzr/baz')
390
        self.make_branch('qux')
391
        trees = workingtree.WorkingTree.find_trees('.')
392
        self.assertEqual(2, len(list(trees)))