~ubuntu-branches/ubuntu/oneiric/bzrtools/oneiric

« back to all changes in this revision

Viewing changes to tests/test_conflict_diff.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-02-17 17:58:10 UTC
  • mfrom: (4.1.49 lucid)
  • Revision ID: james.westby@ubuntu.com-20100217175810-nu0sf358eec4cqkm
Tags: 2.1.0-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.tests import TestCaseWithTransport
22
22
from bzrlib.plugins.bzrtools import errors
23
23
from bzrlib.plugins.bzrtools.conflict_diff import (
24
 
    conflict_diff,
25
 
    get_old_lines,
 
24
    ConflictDiffer
26
25
)
27
26
 
28
27
 
32
31
        self.build_tree_contents(
33
32
            [('foo.THIS', 'this\n'), ('foo.BASE', 'base\n')])
34
33
        s = StringIO()
35
 
        conflict_diff(s, 'foo', 'this')
 
34
        ConflictDiffer().conflict_diff(s, 'foo', 'this')
36
35
        self.assertEqual('--- foo.BASE\n+++ foo.THIS\n'
37
36
                         '@@ -1,1 +1,1 @@\n'
38
37
                         '-base\n+this\n\n', s.getvalue())
41
40
        tree = self.make_branch_and_tree('.')
42
41
        self.build_tree_contents([('foo', 'base\n')])
43
42
        tree.add('foo')
44
 
        e = self.assertRaises(errors.NoConflictFiles, get_old_lines, 'foo',
 
43
        e = self.assertRaises(errors.NoConflictFiles,
 
44
                              ConflictDiffer().get_old_lines,
 
45
                              'foo',
45
46
                              'foo.BASE')
46
47
        self.assertEqual('foo.BASE does not exist and there are no pending'
47
48
                         ' merges.', str(e))
48
49
 
49
50
    def test_get_old_lines(self):
50
51
        self.build_tree_contents([('foo.BASE', 'base\n')])
51
 
        old_lines = get_old_lines('foo', 'foo.BASE')
 
52
        old_lines = ConflictDiffer().get_old_lines('foo', 'foo.BASE')
52
53
        self.assertEqual(['base\n'], old_lines)
53
54
 
54
55
    def test_get_old_lines_no_base(self):
63
64
        tree.commit('Changed foo text')
64
65
        tree.merge_from_branch(other.branch)
65
66
        os.unlink('tree/foo.BASE')
66
 
        old_lines = get_old_lines('tree/foo', 'tree/foo.BASE')
 
67
        old_lines = ConflictDiffer().get_old_lines('tree/foo', 'tree/foo.BASE')
67
68
        self.assertEqual(['base\n'], old_lines)