15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
from bzrlib import tests
20
25
from bzrlib.bzrdir import BzrDir
21
26
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
22
27
UnversionedParent, ParentLoop, DeletingParent,)
30
35
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths,
31
36
resolve_conflicts, cook_conflicts,
32
37
find_interesting, build_tree, get_backup_name)
33
import bzrlib.urlutils as urlutils
35
40
class TestTreeTransform(TestCaseInTempDir):
535
540
self.assertTrue(wt.is_executable('soc'))
536
541
self.assertTrue(wt.is_executable('sac'))
543
def test_preserve_mode(self):
544
"""File mode is preserved when replacing content"""
545
if sys.platform == 'win32':
546
raise TestSkipped('chmod has no effect on win32')
547
transform, root = self.get_transform()
548
transform.new_file('file1', root, 'contents', 'file1-id', True)
550
self.assertTrue(self.wt.is_executable('file1-id'))
551
transform, root = self.get_transform()
552
file1_id = transform.trans_id_tree_file_id('file1-id')
553
transform.delete_contents(file1_id)
554
transform.create_file('contents2', file1_id)
556
self.assertTrue(self.wt.is_executable('file1-id'))
558
def test__set_mode_stats_correctly(self):
559
"""_set_mode stats to determine file mode."""
560
if sys.platform == 'win32':
561
raise TestSkipped('chmod has no effect on win32')
565
def instrumented_stat(path):
566
stat_paths.append(path)
567
return real_stat(path)
569
transform, root = self.get_transform()
571
bar1_id = transform.new_file('bar', root, 'bar contents 1\n',
572
file_id='bar-id-1', executable=False)
575
transform, root = self.get_transform()
576
bar1_id = transform.trans_id_tree_path('bar')
577
bar2_id = transform.trans_id_tree_path('bar2')
579
os.stat = instrumented_stat
580
transform.create_file('bar2 contents\n', bar2_id, mode_id=bar1_id)
585
bar1_abspath = self.wt.abspath('bar')
586
self.assertEqual([bar1_abspath], stat_paths)
539
589
class TransformGroup(object):
540
590
def __init__(self, dirname):
731
781
self.assertIs(os.path.lexists(this.wt.abspath('b/h1.OTHER')), False)
732
782
self.assertEqual(this.wt.id2path('i'), pathjoin('b/i1.OTHER'))
734
785
class TestBuildTree(tests.TestCaseWithTransport):
736
787
def test_build_tree(self):