/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2010-04-05 21:56:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5132.
  • Revision ID: jelmer@samba.org-20100405215639-blaww00wgf2jgl82
Add test for custom diff format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    tests,
26
26
    workingtree,
27
27
    )
 
28
from bzrlib.diff import (
 
29
    DiffTree,
 
30
    format_registry as diff_format_registry,
 
31
    )
28
32
 
29
33
 
30
34
def subst_dates(string):
301
305
        output = self.run_bzr('diff -r 1.. branch1', retcode=1)
302
306
        self.assertContainsRe(output[0], '\n\\-original line\n\\+repo line\n')
303
307
 
 
308
    def test_custom_format(self):
 
309
        class BooDiffTree(DiffTree):
 
310
 
 
311
            def show_diff(self, specific_files, extra_trees=None):
 
312
                self.to_file.write("BOO!\n")
 
313
                return super(BooDiffTree, self).show_diff(specific_files,
 
314
                    extra_trees)
 
315
 
 
316
        diff_format_registry.register("boo", BooDiffTree, 
 
317
            "Scary diff format")
 
318
        self.addCleanup(diff_format_registry.remove, "boo")
 
319
        self.make_example_branch()
 
320
        self.build_tree_contents([('hello', 'hello world!\n')])
 
321
        output = self.run_bzr('diff --format=boo', retcode=1)
 
322
        self.assertTrue("BOO!" in output[0])
 
323
 
304
324
 
305
325
class TestCheckoutDiff(TestDiff):
306
326