~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(gz) Backslash escape selftest output when printing to non-unicode consoles
 (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
    tests,
26
26
    workingtree,
27
27
    )
 
28
from bzrlib.diff import (
 
29
    DiffTree,
 
30
    format_registry as diff_format_registry,
 
31
    )
 
32
from bzrlib.tests import (
 
33
    features,
 
34
    )
28
35
 
29
36
 
30
37
def subst_dates(string):
132
139
        out, err = self.run_bzr('diff -r 1..23..123', retcode=3,
133
140
            error_regexes=('one or two revision specifiers',))
134
141
 
 
142
    def test_diff_using_and_format(self):
 
143
        out, err = self.run_bzr('diff --format=default --using=mydi', retcode=3,
 
144
            error_regexes=('are mutually exclusive',))
 
145
 
135
146
    def test_diff_nonexistent_revision(self):
136
147
        out, err = self.run_bzr('diff -r 123', retcode=3,
137
148
            error_regexes=("Requested revision: '123' does not "
297
308
        output = self.run_bzr('diff -r 1.. branch1', retcode=1)
298
309
        self.assertContainsRe(output[0], '\n\\-original line\n\\+repo line\n')
299
310
 
 
311
    def test_custom_format(self):
 
312
        class BooDiffTree(DiffTree):
 
313
 
 
314
            def show_diff(self, specific_files, extra_trees=None):
 
315
                self.to_file.write("BOO!\n")
 
316
                return super(BooDiffTree, self).show_diff(specific_files,
 
317
                    extra_trees)
 
318
 
 
319
        diff_format_registry.register("boo", BooDiffTree, 
 
320
            "Scary diff format")
 
321
        self.addCleanup(diff_format_registry.remove, "boo")
 
322
        self.make_example_branch()
 
323
        self.build_tree_contents([('hello', 'hello world!\n')])
 
324
        output = self.run_bzr('diff --format=boo', retcode=1)
 
325
        self.assertTrue("BOO!" in output[0])
300
326
 
301
327
class TestCheckoutDiff(TestDiff):
302
328
 
376
402
        self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
377
403
                                 "+baz\n\n")
378
404
 
 
405
    def test_external_diff_options_and_using(self):
 
406
        """Test that the options are passed correctly to an external diff process"""
 
407
        self.requireFeature(features.diff_feature)
 
408
        self.make_example_branch()
 
409
        self.build_tree_contents([('hello', 'Foo\n')])
 
410
        out, err = self.run_bzr('diff --diff-options -i --using diff',
 
411
                                    retcode=1)
 
412
        self.assertEquals("=== modified file 'hello'\n", out)
 
413
        self.assertEquals('', err)
 
414
 
379
415
 
380
416
class TestDiffOutput(DiffBase):
381
417