/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Aaron Bentley
  • Date: 2007-06-02 15:48:54 UTC
  • mto: (2502.1.10 fast-checkout)
  • mto: This revision was merged to the branch mainline in revision 2507.
  • Revision ID: aaron.bentley@utoronto.ca-20070602154854-dxx6c0hbjm2h1jel
Make the limited-renames functionality safer in the general case

Show diffs side-by-side

added added

removed removed

Lines of Context:
788
788
        transform2.apply()
789
789
        self.assertEqual(transform2.rename_count, 2)
790
790
 
 
791
    def test_change_parent(self):
 
792
        transform, root = self.get_transform()
 
793
        frexpar = transform.new_directory('frexpar', root)
 
794
        elphaba = transform.new_file('elphaba', frexpar, 'contents')
 
795
        oz = transform.new_directory('oz', root)
 
796
        transform.adjust_path('elphaba', oz, elphaba)
 
797
        transform.apply()
 
798
        self.failIfExists(self.wt.abspath('frexpar/elphaba'))
 
799
        self.failUnlessExists(self.wt.abspath('oz/elphaba'))
 
800
        # rename libbo/new1 => frexpar, rename limbo/new3 => oz
 
801
        # no rename for elphaba
 
802
        self.failUnlessEqual(2, transform.rename_count)
 
803
 
 
804
    def test_cancel_parent(self):
 
805
        """Cancelling a parent doesn't cause deletion of a non-empty directory
 
806
 
 
807
        This is like the test_change_parent, except that we cancel the parent
 
808
        before adjusting the path.  The transform must detect that the
 
809
        directory is non-empty, and move children to safe locations.
 
810
        """
 
811
        transform, root = self.get_transform()
 
812
        frexpar = transform.new_directory('frexpar', root)
 
813
        elphaba = transform.new_file('elphaba', frexpar, 'contents')
 
814
        nessarose = transform.new_file('nessarose', frexpar, 'contents')
 
815
        try:
 
816
            transform.cancel_creation(frexpar)
 
817
        except OSError:
 
818
            self.fail('Failed to move elphaba before deleting frexpar')
 
819
        transform.cancel_creation(nessarose)
 
820
        transform.create_directory(frexpar)
 
821
        try:
 
822
            transform.cancel_creation(frexpar)
 
823
        except OSError:
 
824
            self.fail('Transform still thinks nessarose is a child of frexpar')
 
825
        oz = transform.new_directory('oz', root)
 
826
        transform.adjust_path('elphaba', oz, elphaba)
 
827
        transform.apply()
 
828
        self.failIfExists(self.wt.abspath('frexpar'))
 
829
        self.failUnlessExists(self.wt.abspath('oz/elphaba'))
 
830
        # rename limbo/new-3 => oz, rename limbo/new-2 => elphaba
 
831
        self.failUnlessEqual(2, transform.rename_count)
 
832
 
 
833
    def test_adjust_and_cancel(self):
 
834
        transform, root = self.get_transform()
 
835
        frexpar = transform.new_directory('frexpar', root)
 
836
        elphaba = transform.new_file('elphaba', frexpar, 'contents')
 
837
        oz = transform.new_directory('oz', root)
 
838
        transform.adjust_path('elphaba', oz, elphaba)
 
839
        transform.cancel_creation(elphaba)
 
840
        try:
 
841
            transform.cancel_creation(frexpar)
 
842
        except OSError:
 
843
            self.fail('Transform still thinks elphaba is a child of frexpar')
 
844
        transform.finalize()
 
845
 
791
846
class TransformGroup(object):
792
847
    def __init__(self, dirname, root_id):
793
848
        self.name = dirname