~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-04 12:10:51 UTC
  • mfrom: (5819.1.4 777007-developer-doc)
  • Revision ID: pqm@pqm.ubuntu.com-20110504121051-aovlsmqiivjmc4fc
(jelmer) Small fixes to developer documentation. (Jonathan Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
 
18
 
from cStringIO import StringIO
19
 
import os
20
 
 
21
 
from bzrlib import ignores
22
 
import bzrlib
23
 
from bzrlib.branch import Branch
24
 
from bzrlib import bzrdir, conflicts, errors, workingtree
25
 
from bzrlib.bzrdir import BzrDir
26
 
from bzrlib.errors import NotBranchError, NotVersionedError
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 
 
18
from bzrlib import (
 
19
    bzrdir,
 
20
    conflicts,
 
21
    errors,
 
22
    symbol_versioning,
 
23
    transport,
 
24
    workingtree,
 
25
    )
27
26
from bzrlib.lockdir import LockDir
28
27
from bzrlib.mutabletree import needs_tree_write_lock
29
 
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
30
 
from bzrlib.symbol_versioning import zero_thirteen
31
28
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
32
 
from bzrlib.trace import mutter
33
 
from bzrlib.transport import get_transport
34
29
from bzrlib.workingtree import (
35
30
    TreeEntry,
36
31
    TreeDirectory,
37
32
    TreeFile,
38
33
    TreeLink,
39
 
    WorkingTree,
40
34
    )
41
35
 
 
36
 
42
37
class TestTreeDirectory(TestCaseWithTransport):
43
38
 
44
39
    def test_kind_character(self):
66
61
class TestDefaultFormat(TestCaseWithTransport):
67
62
 
68
63
    def test_get_set_default_format(self):
69
 
        old_format = workingtree.WorkingTreeFormat.get_default_format()
70
 
        # default is 3
71
 
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
72
 
        workingtree.WorkingTreeFormat.set_default_format(SampleTreeFormat())
73
 
        try:
74
 
            # the default branch format is used by the meta dir format
75
 
            # which is not the default bzrdir format at this point
76
 
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
77
 
            dir.create_repository()
78
 
            dir.create_branch()
79
 
            result = dir.create_workingtree()
80
 
            self.assertEqual(result, 'A tree')
81
 
        finally:
82
 
            workingtree.WorkingTreeFormat.set_default_format(old_format)
83
 
        self.assertEqual(old_format, workingtree.WorkingTreeFormat.get_default_format())
 
64
        old_format = workingtree.format_registry.get_default()
 
65
        # default is 3
 
66
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
 
67
        workingtree.format_registry.set_default(SampleTreeFormat())
 
68
        try:
 
69
            # the default branch format is used by the meta dir format
 
70
            # which is not the default bzrdir format at this point
 
71
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
 
72
            dir.create_repository()
 
73
            dir.create_branch()
 
74
            result = dir.create_workingtree()
 
75
            self.assertEqual(result, 'A tree')
 
76
        finally:
 
77
            workingtree.format_registry.set_default(old_format)
 
78
        self.assertEqual(old_format, workingtree.format_registry.get_default())
 
79
 
 
80
    def test_get_set_default_format_by_key(self):
 
81
        old_format = workingtree.format_registry.get_default()
 
82
        # default is 3
 
83
        format = SampleTreeFormat()
 
84
        workingtree.format_registry.register(format)
 
85
        self.addCleanup(workingtree.format_registry.remove, format)
 
86
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
 
87
        workingtree.format_registry.set_default_key(format.get_format_string())
 
88
        try:
 
89
            # the default branch format is used by the meta dir format
 
90
            # which is not the default bzrdir format at this point
 
91
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
 
92
            dir.create_repository()
 
93
            dir.create_branch()
 
94
            result = dir.create_workingtree()
 
95
            self.assertEqual(result, 'A tree')
 
96
        finally:
 
97
            workingtree.format_registry.set_default_key(
 
98
                old_format.get_format_string())
 
99
        self.assertEqual(old_format, workingtree.format_registry.get_default())
 
100
 
 
101
    def test_open(self):
 
102
        tree = self.make_branch_and_tree('.')
 
103
        open_direct = workingtree.WorkingTree.open('.')
 
104
        self.assertEqual(tree.basedir, open_direct.basedir)
 
105
        open_no_args = workingtree.WorkingTree.open()
 
106
        self.assertEqual(tree.basedir, open_no_args.basedir)
 
107
 
 
108
    def test_open_containing(self):
 
109
        tree = self.make_branch_and_tree('.')
 
110
        open_direct, relpath = workingtree.WorkingTree.open_containing('.')
 
111
        self.assertEqual(tree.basedir, open_direct.basedir)
 
112
        self.assertEqual('', relpath)
 
113
        open_no_args, relpath = workingtree.WorkingTree.open_containing()
 
114
        self.assertEqual(tree.basedir, open_no_args.basedir)
 
115
        self.assertEqual('', relpath)
 
116
        open_subdir, relpath = workingtree.WorkingTree.open_containing('subdir')
 
117
        self.assertEqual(tree.basedir, open_subdir.basedir)
 
118
        self.assertEqual('subdir', relpath)
84
119
 
85
120
 
86
121
class SampleTreeFormat(workingtree.WorkingTreeFormat):
87
122
    """A sample format
88
123
 
89
 
    this format is initializable, unsupported to aid in testing the 
 
124
    this format is initializable, unsupported to aid in testing the
90
125
    open and open_downlevel routines.
91
126
    """
92
127
 
94
129
        """See WorkingTreeFormat.get_format_string()."""
95
130
        return "Sample tree format."
96
131
 
97
 
    def initialize(self, a_bzrdir, revision_id=None):
 
132
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
 
133
                   accelerator_tree=None, hardlink=False):
98
134
        """Sample branches cannot be created."""
99
135
        t = a_bzrdir.get_workingtree_transport(self)
100
136
        t.put_bytes('format', self.get_format_string())
107
143
        return "opened tree."
108
144
 
109
145
 
 
146
class SampleExtraTreeFormat(workingtree.WorkingTreeFormat):
 
147
    """A sample format that does not support use in a metadir.
 
148
 
 
149
    """
 
150
 
 
151
    def get_format_string(self):
 
152
        # Not usable in a metadir, so no format string
 
153
        return None
 
154
 
 
155
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
 
156
                   accelerator_tree=None, hardlink=False):
 
157
        raise NotImplementedError(self.initialize)
 
158
 
 
159
    def is_supported(self):
 
160
        return False
 
161
 
 
162
    def open(self, transport, _found=False):
 
163
        raise NotImplementedError(self.open)
 
164
 
 
165
 
110
166
class TestWorkingTreeFormat(TestCaseWithTransport):
111
167
    """Tests for the WorkingTreeFormat facility."""
112
168
 
 
169
    def test_find_format_string(self):
 
170
        # is the right format object found for a working tree?
 
171
        branch = self.make_branch('branch')
 
172
        self.assertRaises(errors.NoWorkingTree,
 
173
            workingtree.WorkingTreeFormat.find_format_string, branch.bzrdir)
 
174
        transport = branch.bzrdir.get_workingtree_transport(None)
 
175
        transport.mkdir('.')
 
176
        transport.put_bytes("format", "some format name")
 
177
        # The format does not have to be known by Bazaar,
 
178
        # find_format_string just retrieves the name
 
179
        self.assertEquals("some format name",
 
180
            workingtree.WorkingTreeFormat.find_format_string(branch.bzrdir))
 
181
 
113
182
    def test_find_format(self):
114
183
        # is the right format object found for a working tree?
115
184
        # create a branch with a few known format objects.
119
188
            dir.create_repository()
120
189
            dir.create_branch()
121
190
            format.initialize(dir)
122
 
            t = get_transport(url)
 
191
            t = transport.get_transport(url)
123
192
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
124
 
            self.failUnless(isinstance(found_format, format.__class__))
 
193
            self.assertIsInstance(found_format, format.__class__)
125
194
        check_format(workingtree.WorkingTreeFormat3(), "bar")
126
 
        
 
195
 
127
196
    def test_find_format_no_tree(self):
128
197
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
129
198
        self.assertRaises(errors.NoWorkingTree,
148
217
        # make a branch
149
218
        format.initialize(dir)
150
219
        # register a format for it.
151
 
        workingtree.WorkingTreeFormat.register_format(format)
 
220
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
221
            workingtree.WorkingTreeFormat.register_format, format)
 
222
        self.assertTrue(format in 
 
223
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
224
                workingtree.WorkingTreeFormat.get_formats))
152
225
        # which branch.Open will refuse (not supported)
153
226
        self.assertRaises(errors.UnsupportedFormatError, workingtree.WorkingTree.open, '.')
154
227
        # but open_downlevel will work
155
228
        self.assertEqual(format.open(dir), workingtree.WorkingTree.open_downlevel('.'))
156
229
        # unregister the format
157
 
        workingtree.WorkingTreeFormat.unregister_format(format)
 
230
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
231
            workingtree.WorkingTreeFormat.unregister_format, format)
 
232
        self.assertFalse(format in
 
233
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
234
                workingtree.WorkingTreeFormat.get_formats))
 
235
 
 
236
 
 
237
class TestWorkingTreeFormatRegistry(TestCase):
 
238
 
 
239
    def setUp(self):
 
240
        super(TestWorkingTreeFormatRegistry, self).setUp()
 
241
        self.registry = workingtree.WorkingTreeFormatRegistry()
 
242
 
 
243
    def test_register_unregister_format(self):
 
244
        format = SampleTreeFormat()
 
245
        self.registry.register(format)
 
246
        self.assertEquals(format, self.registry.get("Sample tree format."))
 
247
        self.registry.remove(format)
 
248
        self.assertRaises(KeyError, self.registry.get, "Sample tree format.")
 
249
 
 
250
    def test_get_all(self):
 
251
        format = SampleTreeFormat()
 
252
        self.assertEquals([], self.registry._get_all())
 
253
        self.registry.register(format)
 
254
        self.assertEquals([format], self.registry._get_all())
 
255
 
 
256
    def test_register_extra(self):
 
257
        format = SampleExtraTreeFormat()
 
258
        self.assertEquals([], self.registry._get_all())
 
259
        self.registry.register_extra(format)
 
260
        self.assertEquals([format], self.registry._get_all())
 
261
 
 
262
    def test_register_extra_lazy(self):
 
263
        self.assertEquals([], self.registry._get_all())
 
264
        self.registry.register_extra_lazy("bzrlib.tests.test_workingtree",
 
265
            "SampleExtraTreeFormat")
 
266
        formats = self.registry._get_all()
 
267
        self.assertEquals(1, len(formats))
 
268
        self.assertIsInstance(formats[0], SampleExtraTreeFormat)
158
269
 
159
270
 
160
271
class TestWorkingTreeFormat3(TestCaseWithTransport):
174
285
        t = control.get_workingtree_transport(None)
175
286
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
176
287
                             t.get('format').read())
177
 
        # self.assertContainsRe(t.get('inventory').read(), 
178
 
        #                       '<inventory file_id="[^"]*" format="5">\n'
179
 
        #                       '</inventory>\n',
180
 
        #                      )
181
 
        # WorkingTreeFormat3 doesn't default to creating a unique root id,
182
 
        # because it is incompatible with older bzr versions
183
 
        self.assertContainsRe(t.get('inventory').read(),
 
288
        self.assertEqualDiff(t.get('inventory').read(),
184
289
                              '<inventory format="5">\n'
185
290
                              '</inventory>\n',
186
291
                             )
189
294
        self.assertFalse(t.has('inventory.basis'))
190
295
        # no last-revision file means 'None' or 'NULLREVISION'
191
296
        self.assertFalse(t.has('last-revision'))
192
 
        # TODO RBC 20060210 do a commit, check the inventory.basis is created 
 
297
        # TODO RBC 20060210 do a commit, check the inventory.basis is created
193
298
        # correctly and last-revision file becomes present.
194
299
 
195
300
    def test_uses_lockdir(self):
196
301
        """WorkingTreeFormat3 uses its own LockDir:
197
 
            
 
302
 
198
303
            - lock is a directory
199
304
            - when the WorkingTree is locked, LockDir can see that
200
305
        """
222
327
        control.create_repository()
223
328
        control.create_branch()
224
329
        tree = workingtree.WorkingTreeFormat3().initialize(control)
225
 
        tree._control_files._transport.delete("pending-merges")
 
330
        tree._transport.delete("pending-merges")
226
331
        self.assertEqual([], tree.get_parent_ids())
227
332
 
228
333
 
229
 
class TestFormat2WorkingTree(TestCaseWithTransport):
230
 
    """Tests that are specific to format 2 trees."""
231
 
 
232
 
    def create_format2_tree(self, url):
233
 
        return self.make_branch_and_tree(
234
 
            url, format=bzrlib.bzrdir.BzrDirFormat6())
235
 
 
236
 
    def test_conflicts(self):
237
 
        # test backwards compatability
238
 
        tree = self.create_format2_tree('.')
239
 
        self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
240
 
                          None)
241
 
        file('lala.BASE', 'wb').write('labase')
242
 
        expected = conflicts.ContentsConflict('lala')
243
 
        self.assertEqual(list(tree.conflicts()), [expected])
244
 
        file('lala', 'wb').write('la')
245
 
        tree.add('lala', 'lala-id')
246
 
        expected = conflicts.ContentsConflict('lala', file_id='lala-id')
247
 
        self.assertEqual(list(tree.conflicts()), [expected])
248
 
        file('lala.THIS', 'wb').write('lathis')
249
 
        file('lala.OTHER', 'wb').write('laother')
250
 
        # When "text conflict"s happen, stem, THIS and OTHER are text
251
 
        expected = conflicts.TextConflict('lala', file_id='lala-id')
252
 
        self.assertEqual(list(tree.conflicts()), [expected])
253
 
        os.unlink('lala.OTHER')
254
 
        os.mkdir('lala.OTHER')
255
 
        expected = conflicts.ContentsConflict('lala', file_id='lala-id')
256
 
        self.assertEqual(list(tree.conflicts()), [expected])
257
 
 
258
 
 
259
 
class TestNonFormatSpecificCode(TestCaseWithTransport):
260
 
    """This class contains tests of workingtree that are not format specific."""
261
 
 
262
 
    def test_gen_file_id(self):
263
 
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_file_id,
264
 
                                      'filename')
265
 
        self.assertStartsWith(file_id, 'filename-')
266
 
 
267
 
    def test_gen_root_id(self):
268
 
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_root_id)
269
 
        self.assertStartsWith(file_id, 'tree_root-')
270
 
        
271
 
    def test__translate_ignore_rule(self):
272
 
        tree = self.make_branch_and_tree('.')
273
 
        # translation should return the regex, the number of groups in it,
274
 
        # and the original rule in a tuple.
275
 
        # there are three sorts of ignore rules:
276
 
        # root only - regex is the rule itself without the leading ./
277
 
        self.assertEqual(
278
 
            "(rootdirrule$)", 
279
 
            tree._translate_ignore_rule("./rootdirrule"))
280
 
        # full path - regex is the rule itself
281
 
        self.assertEqual(
282
 
            "(path\\/to\\/file$)",
283
 
            tree._translate_ignore_rule("path/to/file"))
284
 
        # basename only rule - regex is a rule that ignores everything up
285
 
        # to the last / in the filename
286
 
        self.assertEqual(
287
 
            "((?:.*/)?(?!.*/)basenamerule$)",
288
 
            tree._translate_ignore_rule("basenamerule"))
289
 
 
290
 
    def test__combine_ignore_rules(self):
291
 
        tree = self.make_branch_and_tree('.')
292
 
        # the combined ignore regexs need the outer group indices
293
 
        # placed in a dictionary with the rules that were combined.
294
 
        # an empty set of rules
295
 
        # this is returned as a list of combined regex,rule sets, because
296
 
        # python has a limit of 100 combined regexes.
297
 
        compiled_rules = tree._combine_ignore_rules([])
298
 
        self.assertEqual([], compiled_rules)
299
 
        # one of each type of rule.
300
 
        compiled_rules = tree._combine_ignore_rules(
301
 
            ["rule1", "rule/two", "./three"])[0]
302
 
        # what type *is* the compiled regex to do an isinstance of ?
303
 
        self.assertEqual(3, compiled_rules[0].groups)
304
 
        self.assertEqual(
305
 
            {0:"rule1",1:"rule/two",2:"./three"},
306
 
            compiled_rules[1])
307
 
 
308
 
    def test__combine_ignore_rules_grouping(self):
309
 
        tree = self.make_branch_and_tree('.')
310
 
        # when there are too many rules, the output is split into groups of 100
311
 
        rules = []
312
 
        for index in range(198):
313
 
            rules.append('foo')
314
 
        self.assertEqual(2, len(tree._combine_ignore_rules(rules)))
315
 
 
316
 
    def test__get_ignore_rules_as_regex(self):
317
 
        tree = self.make_branch_and_tree('.')
318
 
        # Setup the default ignore list to be empty
319
 
        ignores._set_user_ignores([])
320
 
 
321
 
        # some plugins (shelf) modifies the DEFAULT_IGNORE list in memory
322
 
        # which causes this test to fail so force the DEFAULT_IGNORE
323
 
        # list to be empty
324
 
        orig_default = bzrlib.DEFAULT_IGNORE
325
 
        # Also make sure the runtime ignore list is empty
326
 
        orig_runtime = ignores._runtime_ignores
327
 
        try:
328
 
            bzrlib.DEFAULT_IGNORE = []
329
 
            ignores._runtime_ignores = set()
330
 
 
331
 
            self.build_tree_contents([('.bzrignore', 'CVS\n.hg\n')])
332
 
            reference_output = tree._combine_ignore_rules(
333
 
                                    set(['CVS', '.hg']))[0]
334
 
            regex_rules = tree._get_ignore_rules_as_regex()[0]
335
 
            self.assertEqual(len(reference_output[1]), regex_rules[0].groups)
336
 
            self.assertEqual(reference_output[1], regex_rules[1])
337
 
        finally:
338
 
            bzrlib.DEFAULT_IGNORE = orig_default
339
 
            ignores._runtime_ignores = orig_runtime
340
 
 
341
 
 
342
334
class InstrumentedTree(object):
343
335
    """A instrumented tree to check the needs_tree_write_lock decorator."""
344
336
 
356
348
    @needs_tree_write_lock
357
349
    def method_that_raises(self):
358
350
        """This method causes an exception when called with parameters.
359
 
        
 
351
 
360
352
        This allows the decorator code to be checked - it should still call
361
353
        unlock.
362
354
        """
373
365
        self.assertEqual(
374
366
            'method_with_tree_write_lock',
375
367
            tree.method_with_tree_write_lock.__name__)
376
 
        self.assertEqual(
 
368
        self.assertDocstring(
377
369
            "A lock_tree_write decorated method that returns its arguments.",
378
 
            tree.method_with_tree_write_lock.__doc__)
 
370
            tree.method_with_tree_write_lock)
379
371
        args = (1, 2, 3)
380
372
        kwargs = {'a':'b'}
381
373
        result = tree.method_with_tree_write_lock(1,2,3, a='b')
383
375
        self.assertEqual(['t', 'u'], tree._locks)
384
376
        self.assertRaises(TypeError, tree.method_that_raises, 'foo')
385
377
        self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
 
378
 
 
379
 
 
380
class TestRevert(TestCaseWithTransport):
 
381
 
 
382
    def test_revert_conflicts_recursive(self):
 
383
        this_tree = self.make_branch_and_tree('this-tree')
 
384
        self.build_tree_contents([('this-tree/foo/',),
 
385
                                  ('this-tree/foo/bar', 'bar')])
 
386
        this_tree.add(['foo', 'foo/bar'])
 
387
        this_tree.commit('created foo/bar')
 
388
        other_tree = this_tree.bzrdir.sprout('other-tree').open_workingtree()
 
389
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
 
390
        other_tree.commit('changed bar')
 
391
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
 
392
        this_tree.commit('changed qux')
 
393
        this_tree.merge_from_branch(other_tree.branch)
 
394
        self.assertEqual(1, len(this_tree.conflicts()))
 
395
        this_tree.revert(['foo'])
 
396
        self.assertEqual(0, len(this_tree.conflicts()))
 
397
 
 
398
 
 
399
class TestAutoResolve(TestCaseWithTransport):
 
400
 
 
401
    def test_auto_resolve(self):
 
402
        base = self.make_branch_and_tree('base')
 
403
        self.build_tree_contents([('base/hello', 'Hello')])
 
404
        base.add('hello', 'hello_id')
 
405
        base.commit('Hello')
 
406
        other = base.bzrdir.sprout('other').open_workingtree()
 
407
        self.build_tree_contents([('other/hello', 'hELLO')])
 
408
        other.commit('Case switch')
 
409
        this = base.bzrdir.sprout('this').open_workingtree()
 
410
        self.assertPathExists('this/hello')
 
411
        self.build_tree_contents([('this/hello', 'Hello World')])
 
412
        this.commit('Add World')
 
413
        this.merge_from_branch(other.branch)
 
414
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
415
                         this.conflicts())
 
416
        this.auto_resolve()
 
417
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
418
                         this.conflicts())
 
419
        self.build_tree_contents([('this/hello', '<<<<<<<')])
 
420
        this.auto_resolve()
 
421
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
422
                         this.conflicts())
 
423
        self.build_tree_contents([('this/hello', '=======')])
 
424
        this.auto_resolve()
 
425
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
426
                         this.conflicts())
 
427
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
 
428
        remaining, resolved = this.auto_resolve()
 
429
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
430
                         this.conflicts())
 
431
        self.assertEqual([], resolved)
 
432
        self.build_tree_contents([('this/hello', 'hELLO wORLD')])
 
433
        remaining, resolved = this.auto_resolve()
 
434
        self.assertEqual([], this.conflicts())
 
435
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
436
                         resolved)
 
437
        self.assertPathDoesNotExist('this/hello.BASE')
 
438
 
 
439
    def test_auto_resolve_dir(self):
 
440
        tree = self.make_branch_and_tree('tree')
 
441
        self.build_tree(['tree/hello/'])
 
442
        tree.add('hello', 'hello-id')
 
443
        file_conflict = conflicts.TextConflict('file', 'hello-id')
 
444
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
 
445
        tree.auto_resolve()
 
446
 
 
447
 
 
448
class TestFindTrees(TestCaseWithTransport):
 
449
 
 
450
    def test_find_trees(self):
 
451
        self.make_branch_and_tree('foo')
 
452
        self.make_branch_and_tree('foo/bar')
 
453
        # Sticking a tree inside a control dir is heinous, so let's skip it
 
454
        self.make_branch_and_tree('foo/.bzr/baz')
 
455
        self.make_branch('qux')
 
456
        trees = workingtree.WorkingTree.find_trees('.')
 
457
        self.assertEqual(2, len(list(trees)))