~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: 2007-03-05 22:58:59 UTC
  • mfrom: (2120.7.7 autoconflicts)
  • Revision ID: pqm@pqm.ubuntu.com-20070305225859-31c72fc6c3778b82
resolve auto-resolves text conflicts by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
313
313
        self.assertEqual(['t', 'u'], tree._locks)
314
314
        self.assertRaises(TypeError, tree.method_that_raises, 'foo')
315
315
        self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
 
316
 
 
317
 
 
318
class TestAutoResolve(TestCaseWithTransport):
 
319
 
 
320
    def test_auto_resolve(self):
 
321
        base = self.make_branch_and_tree('base')
 
322
        self.build_tree_contents([('base/hello', 'Hello')])
 
323
        base.add('hello', 'hello_id')
 
324
        base.commit('Hello')
 
325
        other = base.bzrdir.sprout('other').open_workingtree()
 
326
        self.build_tree_contents([('other/hello', 'hELLO')])
 
327
        other.commit('Case switch')
 
328
        this = base.bzrdir.sprout('this').open_workingtree()
 
329
        self.failUnlessExists('this/hello')
 
330
        self.build_tree_contents([('this/hello', 'Hello World')])
 
331
        this.commit('Add World')
 
332
        this.merge_from_branch(other.branch)
 
333
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
334
                         this.conflicts())
 
335
        this.auto_resolve()
 
336
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
337
                         this.conflicts())
 
338
        self.build_tree_contents([('this/hello', '<<<<<<<')])
 
339
        this.auto_resolve()
 
340
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
341
                         this.conflicts())
 
342
        self.build_tree_contents([('this/hello', '=======')])
 
343
        this.auto_resolve()
 
344
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
345
                         this.conflicts())
 
346
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
 
347
        remaining, resolved = this.auto_resolve()
 
348
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
349
                         this.conflicts())
 
350
        self.assertEqual([], resolved)
 
351
        self.build_tree_contents([('this/hello', 'hELLO wORLD')])
 
352
        remaining, resolved = this.auto_resolve()
 
353
        self.assertEqual([], this.conflicts())
 
354
        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
 
355
                         resolved)
 
356
        self.failIfExists('this/hello.BASE')
 
357
 
 
358
    def test_auto_resolve_dir(self):
 
359
        tree = self.make_branch_and_tree('tree')
 
360
        self.build_tree(['tree/hello/'])
 
361
        tree.add('hello', 'hello-id')
 
362
        file_conflict = conflicts.TextConflict('file', 'hello_id')
 
363
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
 
364
        tree.auto_resolve()