Rev 5170: (vila) Fix bt.test_diff imports in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Apr 21 12:48:42 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5170 [merge]
revision-id: pqm at pqm.ubuntu.com-20100421114839-4elxlyab2r06ryj3
parent: pqm at pqm.ubuntu.com-20100421050502-7540qdf2nxuvlq0c
parent: v.ladeuil+lp at free.fr-20100421084320-nbw59sgn3j4dh2io
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-04-21 12:48:39 +0100
message:
(vila) Fix bt.test_diff imports
modified:
bzrlib/tests/test_diff.py testdiff.py-20050727164403-d1a3496ebb12e339
=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py 2010-04-19 04:10:53 +0000
+++ b/bzrlib/tests/test_diff.py 2010-04-20 14:04:54 +0000
@@ -15,41 +15,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
-import os.path
from cStringIO import StringIO
import subprocess
import sys
-from tempfile import TemporaryFile
+import tempfile
-from bzrlib import tests
-from bzrlib.diff import (
- DiffFromTool,
- DiffPath,
- DiffSymlink,
- DiffTree,
- DiffText,
- external_diff,
- internal_diff,
- show_diff_trees,
- get_trees_and_branches_to_diff,
- get_trees_and_branches_to_diff_locked,
+from bzrlib import (
+ diff,
+ errors,
+ osutils,
+ patiencediff,
+ _patiencediff_py,
+ revision as _mod_revision,
+ revisionspec,
+ revisiontree,
+ tests,
+ transform,
)
-from bzrlib.errors import BinaryFile, NoDiff, ExecutableMissing
-import bzrlib.osutils as osutils
-import bzrlib.revision as _mod_revision
-import bzrlib.transform as transform
-import bzrlib.patiencediff
-import bzrlib._patiencediff_py
-from bzrlib.tests import (Feature, TestCase, TestCaseWithTransport,
- TestCaseInTempDir, TestSkipped)
-from bzrlib.revisiontree import RevisionTree
-from bzrlib.revisionspec import RevisionSpec
from bzrlib.symbol_versioning import deprecated_in
-
-from bzrlib.tests.test_win32utils import BackslashDirSeparatorFeature
-
-
-class _AttribFeature(Feature):
+from bzrlib.tests import test_win32utils
+
+
+class _AttribFeature(tests.Feature):
def _probe(self):
if (sys.platform not in ('cygwin', 'win32')):
@@ -72,7 +59,7 @@
def udiff_lines(old, new, allow_binary=False):
output = StringIO()
- internal_diff('old', old, 'new', new, output, allow_binary)
+ diff.internal_diff('old', old, 'new', new, output, allow_binary)
output.seek(0, 0)
return output.readlines()
@@ -82,18 +69,18 @@
# StringIO has no fileno, so it tests a different codepath
output = StringIO()
else:
- output = TemporaryFile()
+ output = tempfile.TemporaryFile()
try:
- external_diff('old', old, 'new', new, output, diff_opts=['-u'])
- except NoDiff:
- raise TestSkipped('external "diff" not present to test')
+ diff.external_diff('old', old, 'new', new, output, diff_opts=['-u'])
+ except errors.NoDiff:
+ raise tests.TestSkipped('external "diff" not present to test')
output.seek(0, 0)
lines = output.readlines()
output.close()
return lines
-class TestDiff(TestCase):
+class TestDiff(tests.TestCase):
def test_add_nl(self):
"""diff generates a valid diff for patches that add a newline"""
@@ -135,10 +122,12 @@
## "Unterminated hunk header for patch:\n%s" % "".join(lines)
def test_binary_lines(self):
- self.assertRaises(BinaryFile, udiff_lines, [1023 * 'a' + '\x00'], [])
- self.assertRaises(BinaryFile, udiff_lines, [], [1023 * 'a' + '\x00'])
- udiff_lines([1023 * 'a' + '\x00'], [], allow_binary=True)
- udiff_lines([], [1023 * 'a' + '\x00'], allow_binary=True)
+ empty = []
+ uni_lines = [1023 * 'a' + '\x00']
+ self.assertRaises(errors.BinaryFile, udiff_lines, uni_lines , empty)
+ self.assertRaises(errors.BinaryFile, udiff_lines, empty, uni_lines)
+ udiff_lines(uni_lines , empty, allow_binary=True)
+ udiff_lines(empty, uni_lines, allow_binary=True)
def test_external_diff(self):
lines = external_udiff_lines(['boo\n'], ['goo\n'])
@@ -174,7 +163,7 @@
orig_path = os.environ['PATH']
try:
os.environ['PATH'] = ''
- self.assertRaises(NoDiff, external_diff,
+ self.assertRaises(errors.NoDiff, diff.external_diff,
'old', ['boo\n'], 'new', ['goo\n'],
StringIO(), diff_opts=['-u'])
finally:
@@ -183,8 +172,8 @@
def test_internal_diff_default(self):
# Default internal diff encoding is utf8
output = StringIO()
- internal_diff(u'old_\xb5', ['old_text\n'],
- u'new_\xe5', ['new_text\n'], output)
+ diff.internal_diff(u'old_\xb5', ['old_text\n'],
+ u'new_\xe5', ['new_text\n'], output)
lines = output.getvalue().splitlines(True)
self.check_patch(lines)
self.assertEquals(['--- old_\xc2\xb5\n',
@@ -198,9 +187,9 @@
def test_internal_diff_utf8(self):
output = StringIO()
- internal_diff(u'old_\xb5', ['old_text\n'],
- u'new_\xe5', ['new_text\n'], output,
- path_encoding='utf8')
+ diff.internal_diff(u'old_\xb5', ['old_text\n'],
+ u'new_\xe5', ['new_text\n'], output,
+ path_encoding='utf8')
lines = output.getvalue().splitlines(True)
self.check_patch(lines)
self.assertEquals(['--- old_\xc2\xb5\n',
@@ -214,9 +203,9 @@
def test_internal_diff_iso_8859_1(self):
output = StringIO()
- internal_diff(u'old_\xb5', ['old_text\n'],
- u'new_\xe5', ['new_text\n'], output,
- path_encoding='iso-8859-1')
+ diff.internal_diff(u'old_\xb5', ['old_text\n'],
+ u'new_\xe5', ['new_text\n'], output,
+ path_encoding='iso-8859-1')
lines = output.getvalue().splitlines(True)
self.check_patch(lines)
self.assertEquals(['--- old_\xb5\n',
@@ -230,26 +219,26 @@
def test_internal_diff_no_content(self):
output = StringIO()
- internal_diff(u'old', [], u'new', [], output)
+ diff.internal_diff(u'old', [], u'new', [], output)
self.assertEqual('', output.getvalue())
def test_internal_diff_no_changes(self):
output = StringIO()
- internal_diff(u'old', ['text\n', 'contents\n'],
- u'new', ['text\n', 'contents\n'],
- output)
+ diff.internal_diff(u'old', ['text\n', 'contents\n'],
+ u'new', ['text\n', 'contents\n'],
+ output)
self.assertEqual('', output.getvalue())
def test_internal_diff_returns_bytes(self):
import StringIO
output = StringIO.StringIO()
- internal_diff(u'old_\xb5', ['old_text\n'],
- u'new_\xe5', ['new_text\n'], output)
+ diff.internal_diff(u'old_\xb5', ['old_text\n'],
+ u'new_\xe5', ['new_text\n'], output)
self.failUnless(isinstance(output.getvalue(), str),
'internal_diff should return bytestrings')
-class TestDiffFiles(TestCaseInTempDir):
+class TestDiffFiles(tests.TestCaseInTempDir):
def test_external_diff_binary(self):
"""The output when using external diff should use diff's i18n error"""
@@ -268,7 +257,7 @@
self.assertEqual(out.splitlines(True) + ['\n'], lines)
-class TestShowDiffTreesHelper(TestCaseWithTransport):
+class TestShowDiffTreesHelper(tests.TestCaseWithTransport):
"""Has a helper for running show_diff_trees"""
def get_diff(self, tree1, tree2, specific_files=None, working_tree=None):
@@ -277,9 +266,10 @@
extra_trees = (working_tree,)
else:
extra_trees = ()
- show_diff_trees(tree1, tree2, output, specific_files=specific_files,
- extra_trees=extra_trees, old_label='old/',
- new_label='new/')
+ diff.show_diff_trees(tree1, tree2, output,
+ specific_files=specific_files,
+ extra_trees=extra_trees, old_label='old/',
+ new_label='new/')
return output.getvalue()
@@ -424,12 +414,12 @@
tree.commit('one', rev_id='rev-1')
self.build_tree_contents([('tree/file', 'new contents\n')])
- diff = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff, "=== modified file 'file'\n")
- self.assertContainsRe(diff, '--- old/file\t')
- self.assertContainsRe(diff, '\\+\\+\\+ new/file\t')
- self.assertContainsRe(diff, '-contents\n'
- '\\+new contents\n')
+ d = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(d, "=== modified file 'file'\n")
+ self.assertContainsRe(d, '--- old/file\t')
+ self.assertContainsRe(d, '\\+\\+\\+ new/file\t')
+ self.assertContainsRe(d, '-contents\n'
+ '\\+new contents\n')
def test_modified_file_in_renamed_dir(self):
"""Test when a file is modified in a renamed directory."""
@@ -441,15 +431,15 @@
tree.rename_one('dir', 'other')
self.build_tree_contents([('tree/other/file', 'new contents\n')])
- diff = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff, "=== renamed directory 'dir' => 'other'\n")
- self.assertContainsRe(diff, "=== modified file 'other/file'\n")
+ d = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(d, "=== renamed directory 'dir' => 'other'\n")
+ self.assertContainsRe(d, "=== modified file 'other/file'\n")
# XXX: This is technically incorrect, because it used to be at another
# location. What to do?
- self.assertContainsRe(diff, '--- old/dir/file\t')
- self.assertContainsRe(diff, '\\+\\+\\+ new/other/file\t')
- self.assertContainsRe(diff, '-contents\n'
- '\\+new contents\n')
+ self.assertContainsRe(d, '--- old/dir/file\t')
+ self.assertContainsRe(d, '\\+\\+\\+ new/other/file\t')
+ self.assertContainsRe(d, '-contents\n'
+ '\\+new contents\n')
def test_renamed_directory(self):
"""Test when only a directory is only renamed."""
@@ -460,10 +450,10 @@
tree.commit('one', rev_id='rev-1')
tree.rename_one('dir', 'newdir')
- diff = self.get_diff(tree.basis_tree(), tree)
+ d = self.get_diff(tree.basis_tree(), tree)
# Renaming a directory should be a single "you renamed this dir" even
# when there are files inside.
- self.assertEqual("=== renamed directory 'dir' => 'newdir'\n", diff)
+ self.assertEqual(d, "=== renamed directory 'dir' => 'newdir'\n")
def test_renamed_file(self):
"""Test when a file is only renamed."""
@@ -473,11 +463,11 @@
tree.commit('one', rev_id='rev-1')
tree.rename_one('file', 'newname')
- diff = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff, "=== renamed file 'file' => 'newname'\n")
+ d = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(d, "=== renamed file 'file' => 'newname'\n")
# We shouldn't have a --- or +++ line, because there is no content
# change
- self.assertNotContainsRe(diff, '---')
+ self.assertNotContainsRe(d, '---')
def test_renamed_and_modified_file(self):
"""Test when a file is only renamed."""
@@ -488,12 +478,12 @@
tree.rename_one('file', 'newname')
self.build_tree_contents([('tree/newname', 'new contents\n')])
- diff = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff, "=== renamed file 'file' => 'newname'\n")
- self.assertContainsRe(diff, '--- old/file\t')
- self.assertContainsRe(diff, '\\+\\+\\+ new/newname\t')
- self.assertContainsRe(diff, '-contents\n'
- '\\+new contents\n')
+ d = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(d, "=== renamed file 'file' => 'newname'\n")
+ self.assertContainsRe(d, '--- old/file\t')
+ self.assertContainsRe(d, '\\+\\+\\+ new/newname\t')
+ self.assertContainsRe(d, '-contents\n'
+ '\\+new contents\n')
def test_internal_diff_exec_property(self):
@@ -518,14 +508,18 @@
tree.rename_one('c', 'new-c')
tree.rename_one('d', 'new-d')
- diff = self.get_diff(tree.basis_tree(), tree)
+ d = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff, r"file 'a'.*\(properties changed:.*\+x to -x.*\)")
- self.assertContainsRe(diff, r"file 'b'.*\(properties changed:.*-x to \+x.*\)")
- self.assertContainsRe(diff, r"file 'c'.*\(properties changed:.*\+x to -x.*\)")
- self.assertContainsRe(diff, r"file 'd'.*\(properties changed:.*-x to \+x.*\)")
- self.assertNotContainsRe(diff, r"file 'e'")
- self.assertNotContainsRe(diff, r"file 'f'")
+ self.assertContainsRe(d, r"file 'a'.*\(properties changed:"
+ ".*\+x to -x.*\)")
+ self.assertContainsRe(d, r"file 'b'.*\(properties changed:"
+ ".*-x to \+x.*\)")
+ self.assertContainsRe(d, r"file 'c'.*\(properties changed:"
+ ".*\+x to -x.*\)")
+ self.assertContainsRe(d, r"file 'd'.*\(properties changed:"
+ ".*-x to \+x.*\)")
+ self.assertNotContainsRe(d, r"file 'e'")
+ self.assertNotContainsRe(d, r"file 'f'")
def test_binary_unicode_filenames(self):
@@ -547,14 +541,14 @@
tree.add([alpha], ['file-id'])
tree.add([omega], ['file-id-2'])
diff_content = StringIO()
- show_diff_trees(tree.basis_tree(), tree, diff_content)
- diff = diff_content.getvalue()
- self.assertContainsRe(diff, r"=== added file '%s'" % alpha_utf8)
- self.assertContainsRe(
- diff, "Binary files a/%s.*and b/%s.* differ\n" % (alpha_utf8, alpha_utf8))
- self.assertContainsRe(diff, r"=== added file '%s'" % omega_utf8)
- self.assertContainsRe(diff, r"--- a/%s" % (omega_utf8,))
- self.assertContainsRe(diff, r"\+\+\+ b/%s" % (omega_utf8,))
+ diff.show_diff_trees(tree.basis_tree(), tree, diff_content)
+ d = diff_content.getvalue()
+ self.assertContainsRe(d, r"=== added file '%s'" % alpha_utf8)
+ self.assertContainsRe(d, "Binary files a/%s.*and b/%s.* differ\n"
+ % (alpha_utf8, alpha_utf8))
+ self.assertContainsRe(d, r"=== added file '%s'" % omega_utf8)
+ self.assertContainsRe(d, r"--- a/%s" % (omega_utf8,))
+ self.assertContainsRe(d, r"\+\+\+ b/%s" % (omega_utf8,))
def test_unicode_filename(self):
"""Test when the filename are unicode."""
@@ -579,15 +573,15 @@
tree.add(['add_'+alpha], ['file-id'])
self.build_tree_contents([('tree/mod_'+alpha, 'contents_mod\n')])
- diff = self.get_diff(tree.basis_tree(), tree)
- self.assertContainsRe(diff,
+ d = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(d,
"=== renamed file 'ren_%s' => 'ren_%s'\n"%(autf8, outf8))
- self.assertContainsRe(diff, "=== added file 'add_%s'"%autf8)
- self.assertContainsRe(diff, "=== modified file 'mod_%s'"%autf8)
- self.assertContainsRe(diff, "=== removed file 'del_%s'"%autf8)
-
-
-class DiffWasIs(DiffPath):
+ self.assertContainsRe(d, "=== added file 'add_%s'"%autf8)
+ self.assertContainsRe(d, "=== modified file 'mod_%s'"%autf8)
+ self.assertContainsRe(d, "=== removed file 'del_%s'"%autf8)
+
+
+class DiffWasIs(diff.DiffPath):
def diff(self, file_id, old_path, new_path, old_kind, new_kind):
self.to_file.write('was: ')
@@ -597,17 +591,17 @@
pass
-class TestDiffTree(TestCaseWithTransport):
+class TestDiffTree(tests.TestCaseWithTransport):
def setUp(self):
- TestCaseWithTransport.setUp(self)
+ super(TestDiffTree, self).setUp()
self.old_tree = self.make_branch_and_tree('old-tree')
self.old_tree.lock_write()
self.addCleanup(self.old_tree.unlock)
self.new_tree = self.make_branch_and_tree('new-tree')
self.new_tree.lock_write()
self.addCleanup(self.new_tree.unlock)
- self.differ = DiffTree(self.old_tree, self.new_tree, StringIO())
+ self.differ = diff.DiffTree(self.old_tree, self.new_tree, StringIO())
def test_diff_text(self):
self.build_tree_contents([('old-tree/olddir/',),
@@ -618,7 +612,7 @@
('new-tree/newdir/newfile', 'new\n')])
self.new_tree.add('newdir')
self.new_tree.add('newdir/newfile', 'file-id')
- differ = DiffText(self.old_tree, self.new_tree, StringIO())
+ differ = diff.DiffText(self.old_tree, self.new_tree, StringIO())
differ.diff_text('file-id', None, 'old label', 'new label')
self.assertEqual(
'--- old label\n+++ new label\n@@ -1,1 +0,0 @@\n-old\n\n',
@@ -653,17 +647,17 @@
self.assertContainsRe(self.differ.to_file.getvalue(), '\+contents')
def test_diff_symlink(self):
- differ = DiffSymlink(self.old_tree, self.new_tree, StringIO())
+ differ = diff.DiffSymlink(self.old_tree, self.new_tree, StringIO())
differ.diff_symlink('old target', None)
self.assertEqual("=== target was 'old target'\n",
differ.to_file.getvalue())
- differ = DiffSymlink(self.old_tree, self.new_tree, StringIO())
+ differ = diff.DiffSymlink(self.old_tree, self.new_tree, StringIO())
differ.diff_symlink(None, 'new target')
self.assertEqual("=== target is 'new target'\n",
differ.to_file.getvalue())
- differ = DiffSymlink(self.old_tree, self.new_tree, StringIO())
+ differ = diff.DiffSymlink(self.old_tree, self.new_tree, StringIO())
differ.diff_symlink('old target', 'new target')
self.assertEqual("=== target changed 'old target' => 'new target'\n",
differ.to_file.getvalue())
@@ -719,13 +713,13 @@
def test_register_diff(self):
self.create_old_new()
- old_diff_factories = DiffTree.diff_factories
- DiffTree.diff_factories=old_diff_factories[:]
- DiffTree.diff_factories.insert(0, DiffWasIs.from_diff_tree)
+ old_diff_factories = diff.DiffTree.diff_factories
+ diff.DiffTree.diff_factories=old_diff_factories[:]
+ diff.DiffTree.diff_factories.insert(0, DiffWasIs.from_diff_tree)
try:
- differ = DiffTree(self.old_tree, self.new_tree, StringIO())
+ differ = diff.DiffTree(self.old_tree, self.new_tree, StringIO())
finally:
- DiffTree.diff_factories = old_diff_factories
+ diff.DiffTree.diff_factories = old_diff_factories
differ.diff('file-id', 'olddir/oldfile', 'newdir/newfile')
self.assertNotContainsRe(
differ.to_file.getvalue(),
@@ -736,8 +730,8 @@
def test_extra_factories(self):
self.create_old_new()
- differ = DiffTree(self.old_tree, self.new_tree, StringIO(),
- extra_factories=[DiffWasIs.from_diff_tree])
+ differ = diff.DiffTree(self.old_tree, self.new_tree, StringIO(),
+ extra_factories=[DiffWasIs.from_diff_tree])
differ.diff('file-id', 'olddir/oldfile', 'newdir/newfile')
self.assertNotContainsRe(
differ.to_file.getvalue(),
@@ -756,14 +750,14 @@
'.*a-file(.|\n)*b-file')
-class TestPatienceDiffLib(TestCase):
+class TestPatienceDiffLib(tests.TestCase):
def setUp(self):
super(TestPatienceDiffLib, self).setUp()
- self._unique_lcs = bzrlib._patiencediff_py.unique_lcs_py
- self._recurse_matches = bzrlib._patiencediff_py.recurse_matches_py
+ self._unique_lcs = _patiencediff_py.unique_lcs_py
+ self._recurse_matches = _patiencediff_py.recurse_matches_py
self._PatienceSequenceMatcher = \
- bzrlib._patiencediff_py.PatienceSequenceMatcher_py
+ _patiencediff_py.PatienceSequenceMatcher_py
def test_diff_unicode_string(self):
a = ''.join([unichr(i) for i in range(4000, 4500, 3)])
@@ -1076,7 +1070,7 @@
'how are you today?\n']
txt_b = ['hello there\n',
'how are you today?\n']
- unified_diff = bzrlib.patiencediff.unified_diff
+ unified_diff = patiencediff.unified_diff
psm = self._PatienceSequenceMatcher
self.assertEquals(['--- \n',
'+++ \n',
@@ -1130,7 +1124,7 @@
'how are you today?\n']
txt_b = ['hello there\n',
'how are you today?\n']
- unified_diff = bzrlib.patiencediff.unified_diff
+ unified_diff = patiencediff.unified_diff
psm = self._PatienceSequenceMatcher
self.assertEquals(['--- a\t2008-08-08\n',
'+++ b\t2008-09-09\n',
@@ -1152,11 +1146,11 @@
def setUp(self):
super(TestPatienceDiffLib_c, self).setUp()
- import bzrlib._patiencediff_c
- self._unique_lcs = bzrlib._patiencediff_c.unique_lcs_c
- self._recurse_matches = bzrlib._patiencediff_c.recurse_matches_c
+ from bzrlib import _patiencediff_c
+ self._unique_lcs = _patiencediff_c.unique_lcs_c
+ self._recurse_matches = _patiencediff_c.recurse_matches_c
self._PatienceSequenceMatcher = \
- bzrlib._patiencediff_c.PatienceSequenceMatcher_c
+ _patiencediff_c.PatienceSequenceMatcher_c
def test_unhashable(self):
"""We should get a proper exception here."""
@@ -1172,12 +1166,12 @@
None, ['valid'], ['valid', []])
-class TestPatienceDiffLibFiles(TestCaseInTempDir):
+class TestPatienceDiffLibFiles(tests.TestCaseInTempDir):
def setUp(self):
super(TestPatienceDiffLibFiles, self).setUp()
self._PatienceSequenceMatcher = \
- bzrlib._patiencediff_py.PatienceSequenceMatcher_py
+ _patiencediff_py.PatienceSequenceMatcher_py
def test_patience_unified_diff_files(self):
txt_a = ['hello there\n',
@@ -1188,7 +1182,7 @@
open('a1', 'wb').writelines(txt_a)
open('b1', 'wb').writelines(txt_b)
- unified_diff_files = bzrlib.patiencediff.unified_diff_files
+ unified_diff_files = patiencediff.unified_diff_files
psm = self._PatienceSequenceMatcher
self.assertEquals(['--- a1\n',
'+++ b1\n',
@@ -1248,64 +1242,65 @@
def setUp(self):
super(TestPatienceDiffLibFiles_c, self).setUp()
- import bzrlib._patiencediff_c
+ from bzrlib import _patiencediff_c
self._PatienceSequenceMatcher = \
- bzrlib._patiencediff_c.PatienceSequenceMatcher_c
-
-
-class TestUsingCompiledIfAvailable(TestCase):
+ _patiencediff_c.PatienceSequenceMatcher_c
+
+
+class TestUsingCompiledIfAvailable(tests.TestCase):
def test_PatienceSequenceMatcher(self):
if compiled_patiencediff_feature.available():
from bzrlib._patiencediff_c import PatienceSequenceMatcher_c
self.assertIs(PatienceSequenceMatcher_c,
- bzrlib.patiencediff.PatienceSequenceMatcher)
+ patiencediff.PatienceSequenceMatcher)
else:
from bzrlib._patiencediff_py import PatienceSequenceMatcher_py
self.assertIs(PatienceSequenceMatcher_py,
- bzrlib.patiencediff.PatienceSequenceMatcher)
+ patiencediff.PatienceSequenceMatcher)
def test_unique_lcs(self):
if compiled_patiencediff_feature.available():
from bzrlib._patiencediff_c import unique_lcs_c
self.assertIs(unique_lcs_c,
- bzrlib.patiencediff.unique_lcs)
+ patiencediff.unique_lcs)
else:
from bzrlib._patiencediff_py import unique_lcs_py
self.assertIs(unique_lcs_py,
- bzrlib.patiencediff.unique_lcs)
+ patiencediff.unique_lcs)
def test_recurse_matches(self):
if compiled_patiencediff_feature.available():
from bzrlib._patiencediff_c import recurse_matches_c
self.assertIs(recurse_matches_c,
- bzrlib.patiencediff.recurse_matches)
+ patiencediff.recurse_matches)
else:
from bzrlib._patiencediff_py import recurse_matches_py
self.assertIs(recurse_matches_py,
- bzrlib.patiencediff.recurse_matches)
-
-
-class TestDiffFromTool(TestCaseWithTransport):
+ patiencediff.recurse_matches)
+
+
+class TestDiffFromTool(tests.TestCaseWithTransport):
def test_from_string(self):
- diff_obj = DiffFromTool.from_string('diff', None, None, None)
+ diff_obj = diff.DiffFromTool.from_string('diff', None, None, None)
self.addCleanup(diff_obj.finish)
self.assertEqual(['diff', '@old_path', '@new_path'],
diff_obj.command_template)
def test_from_string_u5(self):
- diff_obj = DiffFromTool.from_string('diff "-u 5"', None, None, None)
+ diff_obj = diff.DiffFromTool.from_string('diff "-u 5"',
+ None, None, None)
self.addCleanup(diff_obj.finish)
self.assertEqual(['diff', '-u 5', '@old_path', '@new_path'],
diff_obj.command_template)
self.assertEqual(['diff', '-u 5', 'old-path', 'new-path'],
diff_obj._get_command('old-path', 'new-path'))
-
+
def test_from_string_path_with_backslashes(self):
- self.requireFeature(BackslashDirSeparatorFeature)
+ self.requireFeature(test_win32utils.BackslashDirSeparatorFeature)
tool = 'C:\\Tools\\Diff.exe'
- diff_obj = DiffFromTool.from_string(tool, None, None, None)
+ diff_obj = diff.DiffFromTool.from_string(tool, None, None, None)
self.addCleanup(diff_obj.finish)
self.assertEqual(['C:\\Tools\\Diff.exe', '@old_path', '@new_path'],
diff_obj.command_template)
@@ -1314,19 +1309,19 @@
def test_execute(self):
output = StringIO()
- diff_obj = DiffFromTool(['python', '-c',
- 'print "@old_path @new_path"'],
- None, None, output)
+ diff_obj = diff.DiffFromTool(['python', '-c',
+ 'print "@old_path @new_path"'],
+ None, None, output)
self.addCleanup(diff_obj.finish)
diff_obj._execute('old', 'new')
self.assertEqual(output.getvalue().rstrip(), 'old new')
def test_excute_missing(self):
- diff_obj = DiffFromTool(['a-tool-which-is-unlikely-to-exist'],
- None, None, None)
+ diff_obj = diff.DiffFromTool(['a-tool-which-is-unlikely-to-exist'],
+ None, None, None)
self.addCleanup(diff_obj.finish)
- e = self.assertRaises(ExecutableMissing, diff_obj._execute, 'old',
- 'new')
+ e = self.assertRaises(errors.ExecutableMissing, diff_obj._execute,
+ 'old', 'new')
self.assertEqual('a-tool-which-is-unlikely-to-exist could not be found'
' on this machine', str(e))
@@ -1342,9 +1337,9 @@
basis_tree = tree.basis_tree()
basis_tree.lock_read()
self.addCleanup(basis_tree.unlock)
- diff_obj = DiffFromTool(['python', '-c',
- 'print "@old_path @new_path"'],
- basis_tree, tree, output)
+ diff_obj = diff.DiffFromTool(['python', '-c',
+ 'print "@old_path @new_path"'],
+ basis_tree, tree, output)
diff_obj._prepare_files('file-id', 'file', 'file')
# The old content should be readonly
self.assertReadableByAttrib(diff_obj._root, 'old\\file',
@@ -1378,9 +1373,9 @@
self.addCleanup(old_tree.unlock)
tree.lock_read()
self.addCleanup(tree.unlock)
- diff_obj = DiffFromTool(['python', '-c',
- 'print "@old_path @new_path"'],
- old_tree, tree, output)
+ diff_obj = diff.DiffFromTool(['python', '-c',
+ 'print "@old_path @new_path"'],
+ old_tree, tree, output)
self.addCleanup(diff_obj.finish)
self.assertContainsRe(diff_obj._root, 'bzr-diff-[^/]*')
old_path, new_path = diff_obj._prepare_files('file-id', 'oldname',
@@ -1396,13 +1391,13 @@
diff_obj._prepare_files('file2-id', 'oldname2', 'newname2')
-class TestGetTreesAndBranchesToDiffLocked(TestCaseWithTransport):
+class TestGetTreesAndBranchesToDiffLocked(tests.TestCaseWithTransport):
def call_gtabtd(self, path_list, revision_specs, old_url, new_url):
"""Call get_trees_and_branches_to_diff_locked. Overridden by
TestGetTreesAndBranchesToDiff.
"""
- return get_trees_and_branches_to_diff_locked(
+ return diff.get_trees_and_branches_to_diff_locked(
path_list, revision_specs, old_url, new_url, self.addCleanup)
def test_basic(self):
@@ -1412,8 +1407,9 @@
specific_files, extra_trees) = self.call_gtabtd(
['tree'], None, None, None)
- self.assertIsInstance(old_tree, RevisionTree)
- self.assertEqual(_mod_revision.NULL_REVISION, old_tree.get_revision_id())
+ self.assertIsInstance(old_tree, revisiontree.RevisionTree)
+ self.assertEqual(_mod_revision.NULL_REVISION,
+ old_tree.get_revision_id())
self.assertEqual(tree.basedir, new_tree.basedir)
self.assertEqual(tree.branch.base, old_branch.base)
self.assertEqual(tree.branch.base, new_branch.base)
@@ -1428,16 +1424,16 @@
self.build_tree_contents([('tree/file', 'newcontent')])
tree.commit('new tree', timestamp=0, rev_id="new-id")
- revisions = [RevisionSpec.from_string('1'),
- RevisionSpec.from_string('2')]
+ revisions = [revisionspec.RevisionSpec.from_string('1'),
+ revisionspec.RevisionSpec.from_string('2')]
(old_tree, new_tree,
old_branch, new_branch,
specific_files, extra_trees) = self.call_gtabtd(
['tree'], revisions, None, None)
- self.assertIsInstance(old_tree, RevisionTree)
+ self.assertIsInstance(old_tree, revisiontree.RevisionTree)
self.assertEqual("old-id", old_tree.get_revision_id())
- self.assertIsInstance(new_tree, RevisionTree)
+ self.assertIsInstance(new_tree, revisiontree.RevisionTree)
self.assertEqual("new-id", new_tree.get_revision_id())
self.assertEqual(tree.branch.base, old_branch.base)
self.assertEqual(tree.branch.base, new_branch.base)
@@ -1452,6 +1448,6 @@
def call_gtabtd(self, path_list, revision_specs, old_url, new_url):
return self.applyDeprecated(
- deprecated_in((2, 2, 0)), get_trees_and_branches_to_diff,
+ deprecated_in((2, 2, 0)), diff.get_trees_and_branches_to_diff,
path_list, revision_specs, old_url, new_url)
More information about the bazaar-commits
mailing list