269
269
"+contents of branch1/file\n"
270
270
"\n", subst_dates(out))
272
def test_diff_color_always(self):
273
from ...terminal import colorstring
274
from ... import colordiff
275
self.overrideAttr(colordiff, 'GLOBAL_COLORDIFFRC', None)
276
self.example_branches()
277
branch2_tree = workingtree.WorkingTree.open_containing('branch2')[0]
278
self.build_tree_contents([('branch2/file', b'even newer content')])
279
branch2_tree.commit(message='update file once more')
281
out, err = self.run_bzr('diff --color=always -r revno:2:branch2..revno:1:branch1',
283
self.assertEqual('', err)
284
self.assertEqualDiff((
285
colorstring(b"=== modified file 'file'\n", 'darkyellow') +
286
colorstring(b"--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n", 'darkred') +
287
colorstring(b"+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n", 'darkblue') +
288
colorstring(b"@@ -1 +1 @@\n", 'darkgreen') +
289
colorstring(b"-new content\n", 'darkred') +
290
colorstring(b"+contents of branch1/file\n", 'darkblue') +
291
colorstring(b"\n", 'darkwhite')).decode(),
272
294
def example_branch2(self):
273
295
branch1_tree = self.make_branch_and_tree('branch1')
274
296
self.build_tree_contents([('branch1/file1', b'original line\n')])
325
347
output = self.run_bzr('diff -Fboo', retcode=1)
326
348
self.assertTrue("BOO!" in output[0])
350
def test_binary_diff_remove(self):
351
tree = self.make_branch_and_tree('.')
352
self.build_tree_contents([('a', b'\x00' * 20)])
354
tree.commit('add binary file')
356
output = self.run_bzr('diff', retcode=1)
358
"=== removed file 'a'\nBinary files old/a and new/a differ\n",
361
def test_moved_away(self):
363
tree = self.make_branch_and_tree('.')
364
self.build_tree_contents([('a', 'asdf\n')])
367
tree.rename_one('a', 'b')
368
self.build_tree_contents([('a', 'qwer\n')])
370
output, error = self.run_bzr('diff -p0', retcode=1)
371
self.assertEqualDiff("""\
373
--- a\tYYYY-MM-DD HH:MM:SS +ZZZZ
374
+++ a\tYYYY-MM-DD HH:MM:SS +ZZZZ
378
=== renamed file 'a' => 'b'
379
""", subst_dates(output))
329
382
class TestCheckoutDiff(TestDiff):