~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_conflict_diff.py

  • Committer: Aaron Bentley
  • Date: 2011-02-01 23:25:27 UTC
  • mfrom: (749.1.1 2.3)
  • Revision ID: aaron@aaronbentley.com-20110201232527-8yjkmelpj1udx4w7
Merged 2.3 into bzrtools.dev.

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)