~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Aaron Bentley
  • Date: 2007-06-03 15:56:59 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-20070603155659-rimfmfeyw7zgbgzm
Ensure we only reuse limbo names appropriately

Show diffs side-by-side

added added

removed removed

Lines of Context:
852
852
            self.fail("Can't handle contents with no name")
853
853
        transform.finalize()
854
854
 
 
855
    def test_reuse_name(self):
 
856
        """Avoid reusing the same limbo name for different files"""
 
857
        transform, root = self.get_transform()
 
858
        oz = transform.new_directory('oz', root)
 
859
        elphaba1 = transform.new_directory('elphaba', oz)
 
860
        try:
 
861
            elphaba2 = transform.new_directory('elphaba', oz)
 
862
        except OSError:
 
863
            self.fail('Tranform tried to use the same limbo name twice')
 
864
        transform.adjust_path('galinda', oz, elphaba2)
 
865
        transform.apply()
 
866
        # limbo/oz => oz, limbo/new-3 => oz/galinda
 
867
        self.assertEqual(2, transform.rename_count)
 
868
 
 
869
    def test_reuse_when_first_moved(self):
 
870
        """Don't avoid direct paths when it is safe to use them"""
 
871
        transform, root = self.get_transform()
 
872
        oz = transform.new_directory('oz', root)
 
873
        elphaba1 = transform.new_directory('elphaba', oz)
 
874
        transform.adjust_path('galinda', oz, elphaba1)
 
875
        elphaba2 = transform.new_directory('elphaba', oz)
 
876
        transform.apply()
 
877
        # limbo/oz => oz
 
878
        self.assertEqual(1, transform.rename_count)
 
879
 
 
880
    def test_reuse_after_cancel(self):
 
881
        """Don't avoid direct paths when it is safe to use them"""
 
882
        transform, root = self.get_transform()
 
883
        oz = transform.new_directory('oz', root)
 
884
        elphaba1 = transform.new_directory('elphaba', oz)
 
885
        transform.cancel_creation(oz)
 
886
        transform.create_directory(oz)
 
887
        elphaba2 = transform.new_directory('elphaba', oz)
 
888
        transform.adjust_path('galinda', oz, elphaba1)
 
889
        transform.apply()
 
890
        # limbo/oz => oz, limbo/new-1 => oz/elphaba
 
891
        self.assertEqual(2, transform.rename_count)
 
892
 
855
893
 
856
894
class TransformGroup(object):
857
895
    def __init__(self, dirname, root_id):