59
59
def test_diff(self):
60
60
tree = self.make_example_branch()
61
self.build_tree_contents([('hello', 'hello world!')])
61
self.build_tree_contents([('hello', b'hello world!')])
62
62
tree.commit(message='fixing hello')
63
63
output = self.run_bzr('diff -r 2..3', retcode=1)[0]
64
64
self.assertTrue('\n+hello world!' in output)
76
76
def test_diff_prefix(self):
77
77
"""diff --prefix appends to filenames in output"""
78
78
self.make_example_branch()
79
self.build_tree_contents([('hello', 'hello world!\n')])
79
self.build_tree_contents([('hello', b'hello world!\n')])
80
80
out, err = self.run_bzr('diff --prefix old/:new/', retcode=1)
81
81
self.assertEqual(err, '')
82
82
self.assertEqualDiff(subst_dates(out), '''\
98
98
def test_diff_p1(self):
99
99
"""diff -p1 produces lkml-style diffs"""
100
100
self.make_example_branch()
101
self.build_tree_contents([('hello', 'hello world!\n')])
101
self.build_tree_contents([('hello', b'hello world!\n')])
102
102
out, err = self.run_bzr('diff -p1', retcode=1)
103
103
self.assertEqual(err, '')
104
104
self.assertEqualDiff(subst_dates(out), '''\
114
114
def test_diff_p0(self):
115
115
"""diff -p0 produces diffs with no prefix"""
116
116
self.make_example_branch()
117
self.build_tree_contents([('hello', 'hello world!\n')])
117
self.build_tree_contents([('hello', b'hello world!\n')])
118
118
out, err = self.run_bzr('diff -p0', retcode=1)
119
119
self.assertEqual(err, '')
120
120
self.assertEqualDiff(subst_dates(out), '''\
175
175
branch1_tree.add('file2')
176
176
branch1_tree.commit(message='add file and file2')
177
177
branch2_tree = branch1_tree.controldir.sprout('branch2').open_workingtree()
178
self.build_tree_contents([('branch2/file', 'new content\n')])
178
self.build_tree_contents([('branch2/file', b'new content\n')])
179
179
branch2_tree.commit(message='update file')
180
180
return branch1_tree, branch2_tree
250
250
def test_diff_revno_branches(self):
251
251
self.example_branches()
252
252
branch2_tree = workingtree.WorkingTree.open_containing('branch2')[0]
253
self.build_tree_contents([('branch2/file', 'even newer content')])
253
self.build_tree_contents([('branch2/file', b'even newer content')])
254
254
branch2_tree.commit(message='update file once more')
256
256
out, err = self.run_bzr('diff -r revno:1:branch2..revno:1:branch1',
271
271
def example_branch2(self):
272
272
branch1_tree = self.make_branch_and_tree('branch1')
273
self.build_tree_contents([('branch1/file1', 'original line\n')])
273
self.build_tree_contents([('branch1/file1', b'original line\n')])
274
274
branch1_tree.add('file1')
275
275
branch1_tree.commit(message='first commit')
276
self.build_tree_contents([('branch1/file1', 'repo line\n')])
276
self.build_tree_contents([('branch1/file1', b'repo line\n')])
277
277
branch1_tree.commit(message='second commit')
278
278
return branch1_tree
280
280
def test_diff_to_working_tree(self):
281
281
self.example_branch2()
282
self.build_tree_contents([('branch1/file1', 'new line')])
282
self.build_tree_contents([('branch1/file1', b'new line')])
283
283
output = self.run_bzr('diff -r 1.. branch1', retcode=1)
284
284
self.assertContainsRe(output[0], '\n\\-original line\n\\+new line\n')
286
286
def test_diff_to_working_tree_in_subdir(self):
287
287
self.example_branch2()
288
self.build_tree_contents([('branch1/file1', 'new line')])
288
self.build_tree_contents([('branch1/file1', b'new line')])
289
289
os.mkdir('branch1/dir1')
290
290
output = self.run_bzr('diff -r 1..', retcode=1,
291
291
working_dir='branch1/dir1')
318
318
diff_format_registry.register("boo", BooDiffTree, "Scary diff format")
319
319
self.addCleanup(diff_format_registry.remove, "boo")
320
320
self.make_example_branch()
321
self.build_tree_contents([('hello', 'hello world!\n')])
321
self.build_tree_contents([('hello', b'hello world!\n')])
322
322
output = self.run_bzr('diff --format=boo', retcode=1)
323
323
self.assertTrue("BOO!" in output[0])
324
324
output = self.run_bzr('diff -Fboo', retcode=1)
361
361
def test_diff_label_added(self):
362
362
tree = super(TestDiffLabels, self).make_example_branch()
363
self.build_tree_contents([('barbar', 'barbar')])
363
self.build_tree_contents([('barbar', b'barbar')])
364
364
tree.add('barbar')
365
365
diff = self.run_bzr('diff', retcode=1)
366
366
self.assertTrue("=== added file 'barbar'" in diff[0])
368
368
def test_diff_label_modified(self):
369
369
super(TestDiffLabels, self).make_example_branch()
370
self.build_tree_contents([('hello', 'barbar')])
370
self.build_tree_contents([('hello', b'barbar')])
371
371
diff = self.run_bzr('diff', retcode=1)
372
372
self.assertTrue("=== modified file 'hello'" in diff[0])
409
409
"""Test that the options are passed correctly to an external diff process"""
410
410
self.requireFeature(features.diff_feature)
411
411
self.make_example_branch()
412
self.build_tree_contents([('hello', 'Foo\n')])
412
self.build_tree_contents([('hello', b'Foo\n')])
413
413
out, err = self.run_bzr('diff --diff-options -i --using diff',
415
415
self.assertEqual("=== modified file 'hello'\n", out)
421
421
def test_diff_output(self):
422
422
# check that output doesn't mangle line-endings
423
423
self.make_example_branch()
424
self.build_tree_contents([('hello', 'hello world!\n')])
424
self.build_tree_contents([('hello', b'hello world!\n')])
425
425
output = self.run_bzr_subprocess('diff', retcode=1)[0]
426
426
self.assertTrue('\n+hello world!\n' in output)