/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/test_diff.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-21 21:39:33 UTC
  • mfrom: (5102 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5143.
  • Revision ID: jelmer@samba.org-20100321213933-fexeh9zcoz8oaju2
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005-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
45
45
from bzrlib.revisiontree import RevisionTree
46
46
from bzrlib.revisionspec import RevisionSpec
47
47
 
 
48
from bzrlib.tests.test_win32utils import BackslashDirSeparatorFeature
 
49
 
48
50
 
49
51
class _AttribFeature(Feature):
50
52
 
63
65
AttribFeature = _AttribFeature()
64
66
 
65
67
 
66
 
class _CompiledPatienceDiffFeature(Feature):
67
 
 
68
 
    def _probe(self):
69
 
        try:
70
 
            import bzrlib._patiencediff_c
71
 
        except ImportError:
72
 
            return False
73
 
        return True
74
 
 
75
 
    def feature_name(self):
76
 
        return 'bzrlib._patiencediff_c'
77
 
 
78
 
CompiledPatienceDiffFeature = _CompiledPatienceDiffFeature()
 
68
compiled_patiencediff_feature = tests.ModuleAvailableFeature(
 
69
                                    'bzrlib._patiencediff_c')
79
70
 
80
71
 
81
72
def udiff_lines(old, new, allow_binary=False):
1156
1147
 
1157
1148
class TestPatienceDiffLib_c(TestPatienceDiffLib):
1158
1149
 
1159
 
    _test_needs_features = [CompiledPatienceDiffFeature]
 
1150
    _test_needs_features = [compiled_patiencediff_feature]
1160
1151
 
1161
1152
    def setUp(self):
1162
1153
        super(TestPatienceDiffLib_c, self).setUp()
1252
1243
 
1253
1244
class TestPatienceDiffLibFiles_c(TestPatienceDiffLibFiles):
1254
1245
 
1255
 
    _test_needs_features = [CompiledPatienceDiffFeature]
 
1246
    _test_needs_features = [compiled_patiencediff_feature]
1256
1247
 
1257
1248
    def setUp(self):
1258
1249
        super(TestPatienceDiffLibFiles_c, self).setUp()
1264
1255
class TestUsingCompiledIfAvailable(TestCase):
1265
1256
 
1266
1257
    def test_PatienceSequenceMatcher(self):
1267
 
        if CompiledPatienceDiffFeature.available():
 
1258
        if compiled_patiencediff_feature.available():
1268
1259
            from bzrlib._patiencediff_c import PatienceSequenceMatcher_c
1269
1260
            self.assertIs(PatienceSequenceMatcher_c,
1270
1261
                          bzrlib.patiencediff.PatienceSequenceMatcher)
1274
1265
                          bzrlib.patiencediff.PatienceSequenceMatcher)
1275
1266
 
1276
1267
    def test_unique_lcs(self):
1277
 
        if CompiledPatienceDiffFeature.available():
 
1268
        if compiled_patiencediff_feature.available():
1278
1269
            from bzrlib._patiencediff_c import unique_lcs_c
1279
1270
            self.assertIs(unique_lcs_c,
1280
1271
                          bzrlib.patiencediff.unique_lcs)
1284
1275
                          bzrlib.patiencediff.unique_lcs)
1285
1276
 
1286
1277
    def test_recurse_matches(self):
1287
 
        if CompiledPatienceDiffFeature.available():
 
1278
        if compiled_patiencediff_feature.available():
1288
1279
            from bzrlib._patiencediff_c import recurse_matches_c
1289
1280
            self.assertIs(recurse_matches_c,
1290
1281
                          bzrlib.patiencediff.recurse_matches)
1303
1294
            diff_obj.command_template)
1304
1295
 
1305
1296
    def test_from_string_u5(self):
1306
 
        diff_obj = DiffFromTool.from_string('diff -u\\ 5', None, None, None)
 
1297
        diff_obj = DiffFromTool.from_string('diff "-u 5"', None, None, None)
1307
1298
        self.addCleanup(diff_obj.finish)
1308
1299
        self.assertEqual(['diff', '-u 5', '@old_path', '@new_path'],
1309
1300
                         diff_obj.command_template)
1310
1301
        self.assertEqual(['diff', '-u 5', 'old-path', 'new-path'],
1311
1302
                         diff_obj._get_command('old-path', 'new-path'))
 
1303
        
 
1304
    def test_from_string_path_with_backslashes(self):
 
1305
        self.requireFeature(BackslashDirSeparatorFeature)
 
1306
        tool = 'C:\\Tools\\Diff.exe'
 
1307
        diff_obj = DiffFromTool.from_string(tool, None, None, None)
 
1308
        self.addCleanup(diff_obj.finish)
 
1309
        self.assertEqual(['C:\\Tools\\Diff.exe', '@old_path', '@new_path'],
 
1310
                         diff_obj.command_template)
 
1311
        self.assertEqual(['C:\\Tools\\Diff.exe', 'old-path', 'new-path'],
 
1312
                         diff_obj._get_command('old-path', 'new-path'))
1312
1313
 
1313
1314
    def test_execute(self):
1314
1315
        output = StringIO()