20
20
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
21
21
UnversionedParent, ParentLoop)
22
22
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
23
ReusingTransform, CantMoveRoot, NotVersionedError,
24
ExistingLimbo, ImmortalLimbo, LockError)
23
ReusingTransform, CantMoveRoot,
24
PathsNotVersionedError, ExistingLimbo,
25
ImmortalLimbo, LockError)
25
26
from bzrlib.osutils import file_kind, has_symlinks, pathjoin
26
27
from bzrlib.merge import Merge3Merger
27
28
from bzrlib.tests import TestCaseInTempDir, TestSkipped, TestCase
28
29
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths,
29
30
resolve_conflicts, cook_conflicts,
30
31
find_interesting, build_tree, get_backup_name)
32
import bzrlib.urlutils as urlutils
32
34
class TestTreeTransform(TestCaseInTempDir):
34
37
super(TestTreeTransform, self).setUp()
35
38
self.wt = BzrDir.create_standalone_workingtree('.')
41
44
return transform, transform.trans_id_tree_file_id(self.wt.get_root_id())
43
46
def test_existing_limbo(self):
44
limbo_name = self.wt._control_files.controlfilename('limbo')
47
limbo_name = urlutils.local_path_from_url(
48
self.wt._control_files.controlfilename('limbo'))
45
49
transform, root = self.get_transform()
46
50
os.mkdir(pathjoin(limbo_name, 'hehe'))
47
51
self.assertRaises(ImmortalLimbo, transform.apply)
57
61
transform, root = self.get_transform()
58
62
self.assertIs(transform.get_tree_parent(root), ROOT_PARENT)
59
63
imaginary_id = transform.trans_id_tree_path('imaginary')
64
imaginary_id2 = transform.trans_id_tree_path('imaginary/')
65
self.assertEqual(imaginary_id, imaginary_id2)
60
66
self.assertEqual(transform.get_tree_parent(imaginary_id), root)
61
67
self.assertEqual(transform.final_kind(root), 'directory')
62
68
self.assertEqual(transform.final_file_id(root), self.wt.get_root_id())
488
494
self.assertEqual(find_interesting(wt, wt, ['vfile']),
489
495
set(['myfile-id']))
490
self.assertRaises(NotVersionedError, find_interesting, wt, wt,
496
self.assertRaises(PathsNotVersionedError, find_interesting, wt, wt,
499
def test_set_executability_order(self):
500
"""Ensure that executability behaves the same, no matter what order.
502
- create file and set executability simultaneously
503
- create file and set executability afterward
504
- unsetting the executability of a file whose executability has not been
505
declared should throw an exception (this may happen when a
506
merge attempts to create a file with a duplicate ID)
508
transform, root = self.get_transform()
510
transform.new_file('set_on_creation', root, 'Set on creation', 'soc',
512
sac = transform.new_file('set_after_creation', root, 'Set after creation', 'sac')
513
transform.set_executability(True, sac)
514
uws = transform.new_file('unset_without_set', root, 'Unset badly', 'uws')
515
self.assertRaises(KeyError, transform.set_executability, None, uws)
517
self.assertTrue(wt.is_executable('soc'))
518
self.assertTrue(wt.is_executable('sac'))
494
521
class TransformGroup(object):
495
522
def __init__(self, dirname):