/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
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
18
from bzrlib import (
19
    bzrdir,
20
    conflicts,
21
    errors,
5662.3.3 by Jelmer Vernooij
add tests
22
    symbol_versioning,
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
23
    transport,
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
24
    workingtree,
25
    )
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
26
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.
27
from bzrlib.mutabletree import needs_tree_write_lock
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
28
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
29
from bzrlib.workingtree import (
30
    TreeEntry,
31
    TreeDirectory,
32
    TreeFile,
33
    TreeLink,
34
    )
1399.1.12 by Robert Collins
add new test script
35
2255.2.121 by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file
36
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
37
class TestTreeDirectory(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
38
39
    def test_kind_character(self):
40
        self.assertEqual(TreeDirectory().kind_character(), '/')
41
42
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
43
class TestTreeEntry(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
44
45
    def test_kind_character(self):
46
        self.assertEqual(TreeEntry().kind_character(), '???')
47
48
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
49
class TestTreeFile(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
50
51
    def test_kind_character(self):
52
        self.assertEqual(TreeFile().kind_character(), '')
53
54
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
55
class TestTreeLink(TestCaseWithTransport):
1399.1.12 by Robert Collins
add new test script
56
57
    def test_kind_character(self):
58
        self.assertEqual(TreeLink().kind_character(), '')
59
60
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
61
class TestDefaultFormat(TestCaseWithTransport):
62
63
    def test_get_set_default_format(self):
5662.3.3 by Jelmer Vernooij
add tests
64
        old_format = workingtree.format_registry.get_default()
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
65
        # default is 3
66
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
5662.3.3 by Jelmer Vernooij
add tests
67
        workingtree.format_registry.set_default(SampleTreeFormat())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
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:
5662.3.3 by Jelmer Vernooij
add tests
77
            workingtree.format_registry.set_default(old_format)
78
        self.assertEqual(old_format, workingtree.format_registry.get_default())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
79
5816.2.1 by Jelmer Vernooij
Allow lazily setting default for working trees.
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
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
101
    def test_open(self):
102
        tree = self.make_branch_and_tree('.')
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
103
        open_direct = workingtree.WorkingTree.open('.')
3753.1.1 by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing.
104
        self.assertEqual(tree.basedir, open_direct.basedir)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
105
        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.
106
        self.assertEqual(tree.basedir, open_no_args.basedir)
107
108
    def test_open_containing(self):
109
        tree = self.make_branch_and_tree('.')
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
110
        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.
111
        self.assertEqual(tree.basedir, open_direct.basedir)
112
        self.assertEqual('', relpath)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
113
        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.
114
        self.assertEqual(tree.basedir, open_no_args.basedir)
115
        self.assertEqual('', relpath)
3753.1.2 by John Arbash Meinel
Switch to using the class attribute, rather than the instance
116
        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.
117
        self.assertEqual(tree.basedir, open_subdir.basedir)
118
        self.assertEqual('subdir', relpath)
119
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
120
121
class SampleTreeFormat(workingtree.WorkingTreeFormat):
122
    """A sample format
123
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
124
    this format is initializable, unsupported to aid in testing the
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
125
    open and open_downlevel routines.
126
    """
127
128
    def get_format_string(self):
129
        """See WorkingTreeFormat.get_format_string()."""
130
        return "Sample tree format."
131
3123.5.3 by Aaron Bentley
Get tests passing with accelerator_tree
132
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
3136.1.5 by Aaron Bentley
Fix sample workingtree format
133
                   accelerator_tree=None, hardlink=False):
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
134
        """Sample branches cannot be created."""
135
        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.
136
        t.put_bytes('format', self.get_format_string())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
137
        return 'A tree'
138
139
    def is_supported(self):
140
        return False
141
142
    def open(self, transport, _found=False):
143
        return "opened tree."
144
145
5642.2.4 by Jelmer Vernooij
add tests.
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
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
166
class TestWorkingTreeFormat(TestCaseWithTransport):
167
    """Tests for the WorkingTreeFormat facility."""
168
169
    def test_find_format(self):
170
        # is the right format object found for a working tree?
171
        # create a branch with a few known format objects.
172
        self.build_tree(["foo/", "bar/"])
173
        def check_format(format, url):
174
            dir = format._matchingbzrdir.initialize(url)
175
            dir.create_repository()
176
            dir.create_branch()
177
            format.initialize(dir)
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
178
            t = transport.get_transport(url)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
179
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
180
            self.assertIsInstance(found_format, format.__class__)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
181
        check_format(workingtree.WorkingTreeFormat3(), "bar")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
182
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
183
    def test_find_format_no_tree(self):
184
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
185
        self.assertRaises(errors.NoWorkingTree,
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
186
                          workingtree.WorkingTreeFormat.find_format,
187
                          dir)
188
189
    def test_find_format_unknown_format(self):
190
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
191
        dir.create_repository()
192
        dir.create_branch()
193
        SampleTreeFormat().initialize(dir)
194
        self.assertRaises(errors.UnknownFormatError,
195
                          workingtree.WorkingTreeFormat.find_format,
196
                          dir)
197
198
    def test_register_unregister_format(self):
199
        format = SampleTreeFormat()
200
        # make a control dir
201
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
202
        dir.create_repository()
203
        dir.create_branch()
204
        # make a branch
205
        format.initialize(dir)
206
        # register a format for it.
5662.3.3 by Jelmer Vernooij
add tests
207
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
208
            workingtree.WorkingTreeFormat.register_format, format)
209
        self.assertTrue(format in 
210
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
211
                workingtree.WorkingTreeFormat.get_formats))
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
212
        # which branch.Open will refuse (not supported)
213
        self.assertRaises(errors.UnsupportedFormatError, workingtree.WorkingTree.open, '.')
214
        # but open_downlevel will work
215
        self.assertEqual(format.open(dir), workingtree.WorkingTree.open_downlevel('.'))
216
        # unregister the format
5662.3.3 by Jelmer Vernooij
add tests
217
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
218
            workingtree.WorkingTreeFormat.unregister_format, format)
219
        self.assertFalse(format in
220
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
221
                workingtree.WorkingTreeFormat.get_formats))
222
223
224
class TestWorkingTreeFormatRegistry(TestCase):
225
226
    def setUp(self):
227
        super(TestWorkingTreeFormatRegistry, self).setUp()
228
        self.registry = workingtree.WorkingTreeFormatRegistry()
229
230
    def test_register_unregister_format(self):
231
        format = SampleTreeFormat()
232
        self.registry.register(format)
233
        self.assertEquals(format, self.registry.get("Sample tree format."))
234
        self.registry.remove(format)
235
        self.assertRaises(KeyError, self.registry.get, "Sample tree format.")
236
237
    def test_get_all(self):
238
        format = SampleTreeFormat()
239
        self.assertEquals([], self.registry._get_all())
240
        self.registry.register(format)
241
        self.assertEquals([format], self.registry._get_all())
242
243
    def test_register_extra(self):
5642.2.4 by Jelmer Vernooij
add tests.
244
        format = SampleExtraTreeFormat()
5662.3.3 by Jelmer Vernooij
add tests
245
        self.assertEquals([], self.registry._get_all())
246
        self.registry.register_extra(format)
247
        self.assertEquals([format], self.registry._get_all())
248
249
    def test_register_extra_lazy(self):
250
        self.assertEquals([], self.registry._get_all())
251
        self.registry.register_extra_lazy("bzrlib.tests.test_workingtree",
252
            "SampleExtraTreeFormat")
253
        formats = self.registry._get_all()
254
        self.assertEquals(1, len(formats))
255
        self.assertIsInstance(formats[0], SampleExtraTreeFormat)
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
256
257
258
class TestWorkingTreeFormat3(TestCaseWithTransport):
259
    """Tests specific to WorkingTreeFormat3."""
260
261
    def test_disk_layout(self):
262
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
263
        control.create_repository()
264
        control.create_branch()
265
        tree = workingtree.WorkingTreeFormat3().initialize(control)
266
        # we want:
267
        # format 'Bazaar-NG Working Tree format 3'
268
        # inventory = blank inventory
269
        # pending-merges = ''
270
        # stat-cache = ??
271
        # no inventory.basis yet
272
        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
273
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
274
                             t.get('format').read())
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
275
        self.assertEqualDiff(t.get('inventory').read(),
2100.3.12 by Aaron Bentley
Stop generating unique roots for WorkingTree3
276
                              '<inventory format="5">\n'
1731.1.33 by Aaron Bentley
Revert no-special-root changes
277
                              '</inventory>\n',
278
                             )
1534.4.51 by Robert Collins
Test the disk layout of format3 working trees.
279
        self.assertEqualDiff('### bzr hashcache v5\n',
280
                             t.get('stat-cache').read())
281
        self.assertFalse(t.has('inventory.basis'))
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
282
        # no last-revision file means 'None' or 'NULLREVISION'
283
        self.assertFalse(t.has('last-revision'))
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
284
        # 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.
285
        # correctly and last-revision file becomes present.
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
286
287
    def test_uses_lockdir(self):
288
        """WorkingTreeFormat3 uses its own LockDir:
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
289
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
290
            - lock is a directory
291
            - when the WorkingTree is locked, LockDir can see that
292
        """
293
        t = self.get_transport()
294
        url = self.get_url()
295
        dir = bzrdir.BzrDirMetaFormat1().initialize(url)
296
        repo = dir.create_repository()
297
        branch = dir.create_branch()
1558.10.1 by Aaron Bentley
Handle lockdirs over NFS properly
298
        try:
299
            tree = workingtree.WorkingTreeFormat3().initialize(dir)
300
        except errors.NotLocalUrl:
301
            raise TestSkipped('Not a local URL')
1553.5.74 by Martin Pool
Convert WorkingTree format3 to use LockDirs
302
        self.assertIsDirectory('.bzr', t)
303
        self.assertIsDirectory('.bzr/checkout', t)
304
        self.assertIsDirectory('.bzr/checkout/lock', t)
305
        our_lock = LockDir(t, '.bzr/checkout/lock')
306
        self.assertEquals(our_lock.peek(), None)
1553.5.75 by Martin Pool
Additional WorkingTree LockDir test
307
        tree.lock_write()
308
        self.assertTrue(our_lock.peek())
309
        tree.unlock()
310
        self.assertEquals(our_lock.peek(), None)
1534.10.6 by Aaron Bentley
Conflict serialization working for WorkingTree3
311
1815.2.2 by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests.
312
    def test_missing_pending_merges(self):
313
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
314
        control.create_repository()
315
        control.create_branch()
316
        tree = workingtree.WorkingTreeFormat3().initialize(control)
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
317
        tree._transport.delete("pending-merges")
1908.6.11 by Robert Collins
Remove usage of tree.pending_merges().
318
        self.assertEqual([], tree.get_parent_ids())
1815.2.2 by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests.
319
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
320
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
321
class InstrumentedTree(object):
322
    """A instrumented tree to check the needs_tree_write_lock decorator."""
323
324
    def __init__(self):
325
        self._locks = []
326
327
    def lock_tree_write(self):
328
        self._locks.append('t')
329
330
    @needs_tree_write_lock
331
    def method_with_tree_write_lock(self, *args, **kwargs):
332
        """A lock_tree_write decorated method that returns its arguments."""
333
        return args, kwargs
334
335
    @needs_tree_write_lock
336
    def method_that_raises(self):
337
        """This method causes an exception when called with parameters.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
338
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
339
        This allows the decorator code to be checked - it should still call
340
        unlock.
341
        """
342
343
    def unlock(self):
344
        self._locks.append('u')
345
346
347
class TestInstrumentedTree(TestCase):
348
349
    def test_needs_tree_write_lock(self):
350
        """@needs_tree_write_lock should be semantically transparent."""
351
        tree = InstrumentedTree()
352
        self.assertEqual(
353
            'method_with_tree_write_lock',
354
            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
355
        self.assertDocstring(
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
356
            "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
357
            tree.method_with_tree_write_lock)
1997.1.1 by Robert Collins
Add WorkingTree.lock_tree_write.
358
        args = (1, 2, 3)
359
        kwargs = {'a':'b'}
360
        result = tree.method_with_tree_write_lock(1,2,3, a='b')
361
        self.assertEqual((args, kwargs), result)
362
        self.assertEqual(['t', 'u'], tree._locks)
363
        self.assertRaises(TypeError, tree.method_that_raises, 'foo')
364
        self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
365
366
3017.2.1 by Aaron Bentley
Revert now resolves conflicts recursively (#102739)
367
class TestRevert(TestCaseWithTransport):
368
369
    def test_revert_conflicts_recursive(self):
370
        this_tree = self.make_branch_and_tree('this-tree')
371
        self.build_tree_contents([('this-tree/foo/',),
372
                                  ('this-tree/foo/bar', 'bar')])
373
        this_tree.add(['foo', 'foo/bar'])
374
        this_tree.commit('created foo/bar')
375
        other_tree = this_tree.bzrdir.sprout('other-tree').open_workingtree()
376
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
377
        other_tree.commit('changed bar')
378
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
379
        this_tree.commit('changed qux')
380
        this_tree.merge_from_branch(other_tree.branch)
381
        self.assertEqual(1, len(this_tree.conflicts()))
382
        this_tree.revert(['foo'])
383
        self.assertEqual(0, len(this_tree.conflicts()))
384
385
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
386
class TestAutoResolve(TestCaseWithTransport):
387
388
    def test_auto_resolve(self):
389
        base = self.make_branch_and_tree('base')
390
        self.build_tree_contents([('base/hello', 'Hello')])
391
        base.add('hello', 'hello_id')
392
        base.commit('Hello')
393
        other = base.bzrdir.sprout('other').open_workingtree()
394
        self.build_tree_contents([('other/hello', 'hELLO')])
395
        other.commit('Case switch')
396
        this = base.bzrdir.sprout('this').open_workingtree()
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
397
        self.assertPathExists('this/hello')
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
398
        self.build_tree_contents([('this/hello', 'Hello World')])
399
        this.commit('Add World')
400
        this.merge_from_branch(other.branch)
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
401
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
402
                         this.conflicts())
403
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
404
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
405
                         this.conflicts())
406
        self.build_tree_contents([('this/hello', '<<<<<<<')])
407
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
408
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
409
                         this.conflicts())
410
        self.build_tree_contents([('this/hello', '=======')])
411
        this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
412
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
413
                         this.conflicts())
414
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
415
        remaining, resolved = this.auto_resolve()
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
416
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
417
                         this.conflicts())
418
        self.assertEqual([], resolved)
419
        self.build_tree_contents([('this/hello', 'hELLO wORLD')])
420
        remaining, resolved = this.auto_resolve()
421
        self.assertEqual([], this.conflicts())
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
422
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
2120.7.2 by Aaron Bentley
Move autoresolve functionality to workingtree
423
                         resolved)
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
424
        self.assertPathDoesNotExist('this/hello.BASE')
2120.7.3 by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved
425
426
    def test_auto_resolve_dir(self):
427
        tree = self.make_branch_and_tree('tree')
428
        self.build_tree(['tree/hello/'])
429
        tree.add('hello', 'hello-id')
5050.51.3 by Vincent Ladeuil
Fix test failing on pqm.
430
        file_conflict = conflicts.TextConflict('file', 'hello-id')
2120.7.3 by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved
431
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
432
        tree.auto_resolve()
3140.1.4 by Aaron Bentley
Add WorkingTree.find_trees
433
434
435
class TestFindTrees(TestCaseWithTransport):
436
437
    def test_find_trees(self):
438
        self.make_branch_and_tree('foo')
439
        self.make_branch_and_tree('foo/bar')
440
        # Sticking a tree inside a control dir is heinous, so let's skip it
441
        self.make_branch_and_tree('foo/.bzr/baz')
442
        self.make_branch('qux')
443
        trees = workingtree.WorkingTree.find_trees('.')
444
        self.assertEqual(2, len(list(trees)))