~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-07-07 15:03:14 UTC
  • mto: (5355.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5356.
  • Revision ID: v.ladeuil+lp@free.fr-20100707150314-7i5po3dwg8umiv8x
Fix remaining sphinx_conf references.

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
21
21
import os
22
22
import re
23
23
 
24
 
import bzrlib
25
 
from bzrlib import workingtree
26
 
from bzrlib.branch import Branch
27
 
from bzrlib.tests import TestSkipped
28
 
from bzrlib.tests.blackbox import ExternalBase
 
24
from bzrlib import (
 
25
    tests,
 
26
    workingtree,
 
27
    )
 
28
from bzrlib.diff import (
 
29
    DiffTree,
 
30
    format_registry as diff_format_registry,
 
31
    )
29
32
 
30
33
 
31
34
def subst_dates(string):
34
37
                  'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
35
38
 
36
39
 
37
 
class DiffBase(ExternalBase):
 
40
class DiffBase(tests.TestCaseWithTransport):
38
41
    """Base class with common setup method"""
39
42
 
40
43
    def make_example_branch(self):
133
136
        out, err = self.run_bzr('diff -r 1..23..123', retcode=3,
134
137
            error_regexes=('one or two revision specifiers',))
135
138
 
 
139
    def test_diff_using_and_format(self):
 
140
        out, err = self.run_bzr('diff --format=default --using=mydi', retcode=3,
 
141
            error_regexes=('are mutually exclusive',))
 
142
 
136
143
    def test_diff_nonexistent_revision(self):
137
144
        out, err = self.run_bzr('diff -r 123', retcode=3,
138
145
            error_regexes=("Requested revision: '123' does not "
298
305
        output = self.run_bzr('diff -r 1.. branch1', retcode=1)
299
306
        self.assertContainsRe(output[0], '\n\\-original line\n\\+repo line\n')
300
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
 
301
324
 
302
325
class TestCheckoutDiff(TestDiff):
303
326
 
355
378
 
356
379
    def test_external_diff(self):
357
380
        """Test that we can spawn an external diff process"""
 
381
        self.disable_missing_extensions_warning()
358
382
        # We have to use run_bzr_subprocess, because we need to
359
383
        # test writing directly to stdout, (there was a bug in
360
384
        # subprocess.py that we had to workaround).
366
390
                                           universal_newlines=True,
367
391
                                           retcode=None)
368
392
        if 'Diff is not installed on this machine' in err:
369
 
            raise TestSkipped("No external 'diff' is available")
 
393
            raise tests.TestSkipped("No external 'diff' is available")
370
394
        self.assertEqual('', err)
371
395
        # We have to skip the stuff in the middle, because it depends
372
396
        # on time.time()