41
42
import bzrlib._patiencediff_py
42
43
from bzrlib.tests import (Feature, TestCase, TestCaseWithTransport,
43
44
TestCaseInTempDir, TestSkipped)
45
from bzrlib.revisiontree import RevisionTree
46
from bzrlib.revisionspec import RevisionSpec
46
49
class _AttribFeature(Feature):
1382
1385
self.assertTrue(os.path.samefile('tree/newname', new_path))
1383
1386
# make sure we can create files with the same parent directories
1384
1387
diff_obj._prepare_files('file2-id', 'oldname2', 'newname2')
1390
class TestGetTreesAndBranchesToDiff(TestCaseWithTransport):
1392
def test_basic(self):
1393
tree = self.make_branch_and_tree('tree')
1394
(old_tree, new_tree,
1395
old_branch, new_branch,
1396
specific_files, extra_trees) = \
1397
get_trees_and_branches_to_diff(['tree'], None, None, None)
1399
self.assertIsInstance(old_tree, RevisionTree)
1400
#print dir (old_tree)
1401
self.assertEqual(_mod_revision.NULL_REVISION, old_tree.get_revision_id())
1402
self.assertEqual(tree.basedir, new_tree.basedir)
1403
self.assertEqual(tree.branch.base, old_branch.base)
1404
self.assertEqual(tree.branch.base, new_branch.base)
1405
self.assertIs(None, specific_files)
1406
self.assertIs(None, extra_trees)
1408
def test_with_rev_specs(self):
1409
tree = self.make_branch_and_tree('tree')
1410
self.build_tree_contents([('tree/file', 'oldcontent')])
1411
tree.add('file', 'file-id')
1412
tree.commit('old tree', timestamp=0, rev_id="old-id")
1413
self.build_tree_contents([('tree/file', 'newcontent')])
1414
tree.commit('new tree', timestamp=0, rev_id="new-id")
1416
revisions = [RevisionSpec.from_string('1'),
1417
RevisionSpec.from_string('2')]
1418
(old_tree, new_tree,
1419
old_branch, new_branch,
1420
specific_files, extra_trees) = \
1421
get_trees_and_branches_to_diff(['tree'], revisions, None, None)
1423
self.assertIsInstance(old_tree, RevisionTree)
1424
self.assertEqual("old-id", old_tree.get_revision_id())
1425
self.assertIsInstance(new_tree, RevisionTree)
1426
self.assertEqual("new-id", new_tree.get_revision_id())
1427
self.assertEqual(tree.branch.base, old_branch.base)
1428
self.assertEqual(tree.branch.base, new_branch.base)
1429
self.assertIs(None, specific_files)
1430
self.assertEqual(tree.basedir, extra_trees[0].basedir)