~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-03 17:08:05 UTC
  • mfrom: (3144.4.2 resolve-parent-kind)
  • Revision ID: pqm@pqm.ubuntu.com-20080103170805-t22jan69n4n5kkub
Handle conflicts in parent file kind gracefully (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from bzrlib.bzrdir import BzrDir
29
29
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
30
 
                              UnversionedParent, ParentLoop, DeletingParent,)
 
30
                              UnversionedParent, ParentLoop, DeletingParent,
 
31
                              NonDirectoryParent)
31
32
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
32
33
                           ReusingTransform, CantMoveRoot, 
33
34
                           PathsNotVersionedError, ExistingLimbo,
623
624
        self.assertEqual(conflicts_s[6], 'Conflict moving oz/emeraldcity into'
624
625
                                         ' oz/emeraldcity.  Cancelled move.')
625
626
 
 
627
    def prepare_wrong_parent_kind(self):
 
628
        tt, root = self.get_transform()
 
629
        tt.new_file('parent', root, 'contents', 'parent-id')
 
630
        tt.apply()
 
631
        tt, root = self.get_transform()
 
632
        parent_id = tt.trans_id_file_id('parent-id')
 
633
        tt.new_file('child,', parent_id, 'contents2', 'file-id')
 
634
        return tt
 
635
 
 
636
    def test_find_conflicts_wrong_parent_kind(self):
 
637
        tt = self.prepare_wrong_parent_kind()
 
638
        tt.find_conflicts()
 
639
 
 
640
    def test_resolve_conflicts_wrong_existing_parent_kind(self):
 
641
        tt = self.prepare_wrong_parent_kind()
 
642
        raw_conflicts = resolve_conflicts(tt)
 
643
        self.assertEqual(set([('non-directory parent', 'Created directory',
 
644
                         'new-3')]), raw_conflicts)
 
645
        cooked_conflicts = cook_conflicts(raw_conflicts, tt)
 
646
        self.assertEqual([NonDirectoryParent('Created directory', 'parent.new',
 
647
        'parent-id')], cooked_conflicts)
 
648
        tt.apply()
 
649
        self.assertEqual(None, self.wt.path2id('parent'))
 
650
        self.assertEqual('parent-id', self.wt.path2id('parent.new'))
 
651
 
 
652
    def test_resolve_conflicts_wrong_new_parent_kind(self):
 
653
        tt, root = self.get_transform()
 
654
        parent_id = tt.new_directory('parent', root, 'parent-id')
 
655
        tt.new_file('child,', parent_id, 'contents2', 'file-id')
 
656
        tt.apply()
 
657
        tt, root = self.get_transform()
 
658
        parent_id = tt.trans_id_file_id('parent-id')
 
659
        tt.delete_contents(parent_id)
 
660
        tt.create_file('contents', parent_id)
 
661
        raw_conflicts = resolve_conflicts(tt)
 
662
        self.assertEqual(set([('non-directory parent', 'Created directory',
 
663
                         'new-3')]), raw_conflicts)
 
664
        tt.apply()
 
665
        self.assertEqual(None, self.wt.path2id('parent'))
 
666
        self.assertEqual('parent-id', self.wt.path2id('parent.new'))
 
667
 
 
668
    def test_resolve_conflicts_wrong_parent_kind_unversioned(self):
 
669
        tt, root = self.get_transform()
 
670
        parent_id = tt.new_directory('parent', root)
 
671
        tt.new_file('child,', parent_id, 'contents2')
 
672
        tt.apply()
 
673
        tt, root = self.get_transform()
 
674
        parent_id = tt.trans_id_tree_path('parent')
 
675
        tt.delete_contents(parent_id)
 
676
        tt.create_file('contents', parent_id)
 
677
        resolve_conflicts(tt)
 
678
        tt.apply()
 
679
        self.assertIs(None, self.wt.path2id('parent'))
 
680
        self.assertIs(None, self.wt.path2id('parent.new'))
 
681
 
626
682
    def test_moving_versioned_directories(self):
627
683
        create, root = self.get_transform()
628
684
        kansas = create.new_directory('kansas', root, 'kansas-id')