~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_diff.py

  • Committer: Wouter van Heyst
  • Date: 2006-07-13 18:18:00 UTC
  • mfrom: (1863 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: larstiq@larstiq.dyndns.org-20060713181800-4e8c4f9326597d7f
[merge] bzr.dev 1863

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import bzrlib
25
25
from bzrlib.branch import Branch
 
26
from bzrlib import workingtree
26
27
from bzrlib.tests.blackbox import ExternalBase
27
28
 
28
29
 
37
38
    def make_example_branch(test):
38
39
        # FIXME: copied from test_too_much -- share elsewhere?
39
40
        test.runbzr('init')
40
 
        file('hello', 'wt').write('foo\n')
 
41
        file('hello', 'wb').write('foo\n')
41
42
        test.runbzr('add hello')
42
43
        test.runbzr('commit -m setup hello')
43
 
        file('goodbye', 'wt').write('baz\n')
 
44
        file('goodbye', 'wb').write('baz\n')
44
45
        test.runbzr('add goodbye')
45
46
        test.runbzr('commit -m setup goodbye')
46
47
 
60
61
    def test_diff_prefix(self):
61
62
        """diff --prefix appends to filenames in output"""
62
63
        self.make_example_branch()
63
 
        file('hello', 'wt').write('hello world!\n')
 
64
        file('hello', 'wb').write('hello world!\n')
64
65
        out, err = self.runbzr('diff --prefix old/:new/', retcode=1)
65
66
        self.assertEquals(err, '')
66
67
        self.assertEqualDiff(subst_dates(out), '''\
76
77
    def test_diff_p1(self):
77
78
        """diff -p1 produces lkml-style diffs"""
78
79
        self.make_example_branch()
79
 
        file('hello', 'wt').write('hello world!\n')
 
80
        file('hello', 'wb').write('hello world!\n')
80
81
        out, err = self.runbzr('diff -p1', retcode=1)
81
82
        self.assertEquals(err, '')
82
83
        self.assertEqualDiff(subst_dates(out), '''\
92
93
    def test_diff_p0(self):
93
94
        """diff -p0 produces diffs with no prefix"""
94
95
        self.make_example_branch()
95
 
        file('hello', 'wt').write('hello world!\n')
 
96
        file('hello', 'wb').write('hello world!\n')
96
97
        out, err = self.runbzr('diff -p0', retcode=1)
97
98
        self.assertEquals(err, '')
98
99
        self.assertEqualDiff(subst_dates(out), '''\
156
157
                              "+contents of branch1/file\n"
157
158
                              "\n", subst_dates(out))
158
159
 
 
160
    def test_diff_revno_branches(self):
 
161
        self.example_branches()
 
162
        print >> open('branch2/file', 'wb'), 'even newer content'
 
163
        self.run_bzr_captured(['commit', '-m', 'update file once more', 'branch2'])
 
164
 
 
165
        out, err = self.run_bzr_captured(['diff', '-r', 'revno:1:branch2..revno:1:branch1'],
 
166
                                         retcode=0)
 
167
        self.assertEquals('', err)
 
168
        self.assertEquals('', out)
 
169
        out, ett = self.run_bzr_captured(['diff', '-r', 'revno:2:branch2..revno:1:branch1'],
 
170
                                         retcode=1)
 
171
        self.assertEquals('', err)
 
172
        self.assertEqualDiff("=== modified file 'file'\n"
 
173
                              "--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
174
                              "+++ file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
175
                              "@@ -1,1 +1,1 @@\n"
 
176
                              "-new content\n"
 
177
                              "+contents of branch1/file\n"
 
178
                              "\n", subst_dates(out))
 
179
 
159
180
    def example_branch2(self):
160
181
        self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
161
182
        self.capture('init branch1')
173
194
        output = self.run_bzr_captured(['diff', '-r', '1..', 'branch1'], retcode=1)
174
195
        self.assertTrue('\n-original line\n+new line\n' in output[0])
175
196
 
 
197
    def test_diff_across_rename(self):
 
198
        """The working tree path should always be considered for diffing"""
 
199
        self.make_example_branch()
 
200
        self.run_bzr('diff', '-r', '0..1', 'hello', retcode=1)
 
201
        wt = workingtree.WorkingTree.open_containing('.')[0]
 
202
        wt.rename_one('hello', 'hello1')
 
203
        self.run_bzr('diff', 'hello1', retcode=1)
 
204
        self.run_bzr('diff', '-r', '0..1', 'hello1', retcode=1)
 
205
 
176
206
 
177
207
class TestCheckoutDiff(TestDiff):
178
208