587
587
bar1_abspath = self.wt.abspath('bar')
588
588
self.assertEqual([bar1_abspath], stat_paths)
590
def test_iter_changes(self):
591
transform, root = self.get_transform()
592
transform.new_file('old', root, 'blah', 'id-1', True)
594
transform, root = self.get_transform()
596
self.assertEqual([], list(transform._iter_changes()))
597
old = transform.trans_id_tree_file_id('id-1')
598
transform.unversion_file(old)
599
self.assertEqual([('id-1', 'old', False, (True, False),
600
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
601
(True, True))], list(transform._iter_changes()))
602
transform.new_directory('new', root, 'id-1')
603
self.assertEqual([('id-1', 'new', True, (True, True),
604
('TREE_ROOT', 'TREE_ROOT'), ('old', 'new'),
605
('file', 'directory'),
606
(True, False))], list(transform._iter_changes()))
610
def test_iter_changes_new(self):
611
transform, root = self.get_transform()
612
transform.new_file('old', root, 'blah')
614
transform, root = self.get_transform()
616
old = transform.trans_id_tree_path('old')
617
transform.version_file('id-1', old)
618
self.assertEqual([('id-1', 'old', False, (False, True),
619
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
620
(False, False))], list(transform._iter_changes()))
624
def test_iter_changes_modifications(self):
625
transform, root = self.get_transform()
626
transform.new_file('old', root, 'blah', 'id-1')
627
transform.new_file('new', root, 'blah')
628
transform.new_directory('subdir', root, 'subdir-id')
630
transform, root = self.get_transform()
632
old = transform.trans_id_tree_path('old')
633
subdir = transform.trans_id_tree_file_id('subdir-id')
634
new = transform.trans_id_tree_path('new')
635
self.assertEqual([], list(transform._iter_changes()))
638
transform.delete_contents(old)
639
self.assertEqual([('id-1', 'old', True, (True, True),
640
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', None),
641
(False, False))], list(transform._iter_changes()))
644
transform.create_file('blah', old)
645
self.assertEqual([('id-1', 'old', True, (True, True),
646
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
647
(False, False))], list(transform._iter_changes()))
648
transform.cancel_deletion(old)
649
self.assertEqual([('id-1', 'old', True, (True, True),
650
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
651
(False, False))], list(transform._iter_changes()))
652
transform.cancel_creation(old)
654
# move file_id to a different file
655
self.assertEqual([], list(transform._iter_changes()))
656
transform.unversion_file(old)
657
transform.version_file('id-1', new)
658
transform.adjust_path('old', root, new)
659
self.assertEqual([('id-1', 'old', True, (True, True),
660
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
661
(False, False))], list(transform._iter_changes()))
662
transform.cancel_versioning(new)
663
transform._removed_id = set()
666
self.assertEqual([], list(transform._iter_changes()))
667
transform.set_executability(True, old)
668
self.assertEqual([('id-1', 'old', False, (True, True),
669
('TREE_ROOT', 'TREE_ROOT'), ('old', 'old'), ('file', 'file'),
670
(False, True))], list(transform._iter_changes()))
671
transform.set_executability(None, old)
674
self.assertEqual([], list(transform._iter_changes()))
675
transform.adjust_path('new', root, old)
676
transform._new_parent = {}
677
self.assertEqual([('id-1', 'new', False, (True, True),
678
('TREE_ROOT', 'TREE_ROOT'), ('old', 'new'), ('file', 'file'),
679
(False, False))], list(transform._iter_changes()))
680
transform._new_name = {}
683
self.assertEqual([], list(transform._iter_changes()))
684
transform.adjust_path('new', subdir, old)
685
transform._new_name = {}
686
self.assertEqual([('id-1', 'subdir/old', False, (True, True),
687
('TREE_ROOT', 'subdir-id'), ('old', 'old'), ('file', 'file'),
688
(False, False))], list(transform._iter_changes()))
689
transform._new_path = {}
694
def test_iter_changes_modified_bleed(self):
695
"""Modified flag should not bleed from one change to another"""
696
# unfortunately, we have no guarantee that file1 (which is modified)
697
# will be applied before file2. And if it's applied after file2, it
698
# obviously can't bleed into file2's change output. But for now, it
700
transform, root = self.get_transform()
701
transform.new_file('file1', root, 'blah', 'id-1')
702
transform.new_file('file2', root, 'blah', 'id-2')
704
transform, root = self.get_transform()
706
transform.delete_contents(transform.trans_id_file_id('id-1'))
707
transform.set_executability(True,
708
transform.trans_id_file_id('id-2'))
709
self.assertEqual([('id-1', u'file1', True, (True, True),
710
('TREE_ROOT', 'TREE_ROOT'), ('file1', u'file1'),
711
('file', None), (False, False)),
712
('id-2', u'file2', False, (True, True),
713
('TREE_ROOT', 'TREE_ROOT'), ('file2', u'file2'),
714
('file', 'file'), (False, True))],
715
list(transform._iter_changes()))
719
def test_iter_changes_pointless(self):
720
"""Ensure that no-ops are not treated as modifications"""
721
transform, root = self.get_transform()
722
transform.new_file('old', root, 'blah', 'id-1')
723
transform.new_directory('subdir', root, 'subdir-id')
725
transform, root = self.get_transform()
727
old = transform.trans_id_tree_path('old')
728
subdir = transform.trans_id_tree_file_id('subdir-id')
729
self.assertEqual([], list(transform._iter_changes()))
730
transform.delete_contents(subdir)
731
transform.create_directory(subdir)
732
transform.set_executability(False, old)
733
transform.unversion_file(old)
734
transform.version_file('id-1', old)
735
transform.adjust_path('old', root, old)
736
self.assertEqual([], list(transform._iter_changes()))
591
740
class TransformGroup(object):
592
741
def __init__(self, dirname, root_id):