/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_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-22 16:41:48 UTC
  • mto: This revision was merged to the branch mainline in revision 4563.
  • Revision ID: john@arbash-meinel.com-20090722164148-uv3t6ath2t2tlo68
Fix bug #394227, osutils.relpath() could get into an infinite loop.

If your current path was at the root of a drive (like 'C:/', and you did something
like 'bzr init-repo H:/repo', then the relpath code would spin forever, trying
to find the relative path to H:/repo from C:/. The problem was that
os.path.split() doesn't strip off the drive letter, so you end up comparing
C:/ to H:/, and neither is 'shorter' to say that we didn't match.

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
        self.assertEqual("1234", output.getvalue())
626
626
 
627
627
 
 
628
class TestRelpath(tests.TestCase):
 
629
 
 
630
    def test_simple_relpath(self):
 
631
        cwd = osutils.getcwd()
 
632
        subdir = cwd + '/subdir'
 
633
        self.assertEqual('subdir', osutils.relpath(cwd, subdir))
 
634
 
 
635
    def test_not_relative(self):
 
636
        self.assertRaises(errors.PathNotChild,
 
637
                          osutils.relpath, 'C:/path', 'H:/path')
 
638
        self.assertRaises(errors.PathNotChild,
 
639
                          osutils.relpath, 'C:/', 'H:/path')
 
640
 
 
641
 
628
642
class TestSafeUnicode(tests.TestCase):
629
643
 
630
644
    def test_from_ascii_string(self):