587
598
bar1_abspath = self.wt.abspath('bar')
588
599
self.assertEqual([bar1_abspath], stat_paths)
601
def test_iter_changes(self):
602
self.wt.set_root_id('eert_toor')
603
transform, root = self.get_transform()
604
transform.new_file('old', root, 'blah', 'id-1', True)
606
transform, root = self.get_transform()
608
self.assertEqual([], list(transform._iter_changes()))
609
old = transform.trans_id_tree_file_id('id-1')
610
transform.unversion_file(old)
611
self.assertEqual([('id-1', ('old', None), False, (True, False),
612
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
613
(True, True))], list(transform._iter_changes()))
614
transform.new_directory('new', root, 'id-1')
615
self.assertEqual([('id-1', ('old', 'new'), True, (True, True),
616
('eert_toor', 'eert_toor'), ('old', 'new'),
617
('file', 'directory'),
618
(True, False))], list(transform._iter_changes()))
622
def test_iter_changes_new(self):
623
self.wt.set_root_id('eert_toor')
624
transform, root = self.get_transform()
625
transform.new_file('old', root, 'blah')
627
transform, root = self.get_transform()
629
old = transform.trans_id_tree_path('old')
630
transform.version_file('id-1', old)
631
self.assertEqual([('id-1', (None, 'old'), False, (False, True),
632
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
633
(False, False))], list(transform._iter_changes()))
637
def test_iter_changes_modifications(self):
638
self.wt.set_root_id('eert_toor')
639
transform, root = self.get_transform()
640
transform.new_file('old', root, 'blah', 'id-1')
641
transform.new_file('new', root, 'blah')
642
transform.new_directory('subdir', root, 'subdir-id')
644
transform, root = self.get_transform()
646
old = transform.trans_id_tree_path('old')
647
subdir = transform.trans_id_tree_file_id('subdir-id')
648
new = transform.trans_id_tree_path('new')
649
self.assertEqual([], list(transform._iter_changes()))
652
transform.delete_contents(old)
653
self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
654
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', None),
655
(False, False))], list(transform._iter_changes()))
658
transform.create_file('blah', old)
659
self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
660
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
661
(False, False))], list(transform._iter_changes()))
662
transform.cancel_deletion(old)
663
self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
664
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
665
(False, False))], list(transform._iter_changes()))
666
transform.cancel_creation(old)
668
# move file_id to a different file
669
self.assertEqual([], list(transform._iter_changes()))
670
transform.unversion_file(old)
671
transform.version_file('id-1', new)
672
transform.adjust_path('old', root, new)
673
self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
674
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
675
(False, False))], list(transform._iter_changes()))
676
transform.cancel_versioning(new)
677
transform._removed_id = set()
680
self.assertEqual([], list(transform._iter_changes()))
681
transform.set_executability(True, old)
682
self.assertEqual([('id-1', ('old', 'old'), False, (True, True),
683
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
684
(False, True))], list(transform._iter_changes()))
685
transform.set_executability(None, old)
688
self.assertEqual([], list(transform._iter_changes()))
689
transform.adjust_path('new', root, old)
690
transform._new_parent = {}
691
self.assertEqual([('id-1', ('old', 'new'), False, (True, True),
692
('eert_toor', 'eert_toor'), ('old', 'new'), ('file', 'file'),
693
(False, False))], list(transform._iter_changes()))
694
transform._new_name = {}
697
self.assertEqual([], list(transform._iter_changes()))
698
transform.adjust_path('new', subdir, old)
699
transform._new_name = {}
700
self.assertEqual([('id-1', ('old', 'subdir/old'), False,
701
(True, True), ('eert_toor', 'subdir-id'), ('old', 'old'),
702
('file', 'file'), (False, False))],
703
list(transform._iter_changes()))
704
transform._new_path = {}
709
def test_iter_changes_modified_bleed(self):
710
self.wt.set_root_id('eert_toor')
711
"""Modified flag should not bleed from one change to another"""
712
# unfortunately, we have no guarantee that file1 (which is modified)
713
# will be applied before file2. And if it's applied after file2, it
714
# obviously can't bleed into file2's change output. But for now, it
716
transform, root = self.get_transform()
717
transform.new_file('file1', root, 'blah', 'id-1')
718
transform.new_file('file2', root, 'blah', 'id-2')
720
transform, root = self.get_transform()
722
transform.delete_contents(transform.trans_id_file_id('id-1'))
723
transform.set_executability(True,
724
transform.trans_id_file_id('id-2'))
725
self.assertEqual([('id-1', (u'file1', u'file1'), True, (True, True),
726
('eert_toor', 'eert_toor'), ('file1', u'file1'),
727
('file', None), (False, False)),
728
('id-2', (u'file2', u'file2'), False, (True, True),
729
('eert_toor', 'eert_toor'), ('file2', u'file2'),
730
('file', 'file'), (False, True))],
731
list(transform._iter_changes()))
735
def test_iter_changes_move_missing(self):
736
"""Test moving ids with no files around"""
737
self.wt.set_root_id('toor_eert')
738
# Need two steps because versioning a non-existant file is a conflict.
739
transform, root = self.get_transform()
740
transform.new_directory('floater', root, 'floater-id')
742
transform, root = self.get_transform()
743
transform.delete_contents(transform.trans_id_tree_path('floater'))
745
transform, root = self.get_transform()
746
floater = transform.trans_id_tree_path('floater')
748
transform.adjust_path('flitter', root, floater)
749
self.assertEqual([('floater-id', ('floater', 'flitter'), False,
750
(True, True), ('toor_eert', 'toor_eert'), ('floater', 'flitter'),
751
(None, None), (False, False))], list(transform._iter_changes()))
755
def test_iter_changes_pointless(self):
756
"""Ensure that no-ops are not treated as modifications"""
757
self.wt.set_root_id('eert_toor')
758
transform, root = self.get_transform()
759
transform.new_file('old', root, 'blah', 'id-1')
760
transform.new_directory('subdir', root, 'subdir-id')
762
transform, root = self.get_transform()
764
old = transform.trans_id_tree_path('old')
765
subdir = transform.trans_id_tree_file_id('subdir-id')
766
self.assertEqual([], list(transform._iter_changes()))
767
transform.delete_contents(subdir)
768
transform.create_directory(subdir)
769
transform.set_executability(False, old)
770
transform.unversion_file(old)
771
transform.version_file('id-1', old)
772
transform.adjust_path('old', root, old)
773
self.assertEqual([], list(transform._iter_changes()))
591
777
class TransformGroup(object):
592
778
def __init__(self, dirname, root_id):