Rev 4563: (jam) Fix bug #394227, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jul 23 18:00:29 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4563 [merge]
revision-id: pqm at pqm.ubuntu.com-20090723170027-0tfrsqpe3tiqnpcb
parent: pqm at pqm.ubuntu.com-20090723044626-jyq6o3zy6ru11v0f
parent: john at arbash-meinel.com-20090723160117-k7wgyommqlgz6jzb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-07-23 18:00:27 +0100
message:
(jam) Fix bug #394227,
prevent osutils.relpath() from going into an infinite loop.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
=== modified file 'NEWS'
--- a/NEWS 2009-07-23 04:46:26 +0000
+++ b/NEWS 2009-07-23 17:00:27 +0000
@@ -70,6 +70,12 @@
lots of backtraces about ``UnknownSmartMethod``, ``do_chunk`` or
``do_end``. (Andrew Bennetts, #338561)
+* There was a bug in ``osutils.relpath`` that was only triggered on
+ Windows. Essentially if you were at the root of a drive, and did
+ something to a branch/repo on another drive, we would go into an
+ infinite loop while trying to find a 'relative path'.
+ (John Arbash Meinel, #394227)
+
* ``WorkingTree4.unversion`` will no longer fail to unversion ids which
were present in a parent tree but renamed in the working tree.
(Robert Collins, #187207)
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2009-07-08 14:37:25 +0000
+++ b/bzrlib/osutils.py 2009-07-23 16:01:17 +0000
@@ -1040,17 +1040,17 @@
s = []
head = rp
- while len(head) >= len(base):
+ while True:
+ if len(head) <= len(base) and head != base:
+ raise errors.PathNotChild(rp, base)
if head == base:
break
- head, tail = os.path.split(head)
+ head, tail = split(head)
if tail:
- s.insert(0, tail)
- else:
- raise errors.PathNotChild(rp, base)
+ s.append(tail)
if s:
- return pathjoin(*s)
+ return pathjoin(*reversed(s))
else:
return ''
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py 2009-07-15 01:13:20 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py 2009-07-23 15:58:22 +0000
@@ -255,6 +255,10 @@
if char is None:
raise TestSkipped('Cannot find suitable non-ascii character'
'for user_encoding (%s)' % osutils.get_user_encoding())
+ # TODO: jam 2009-07-23 This test seems to fail on Windows now. My best
+ # guess is that the change to use Unicode command lines means
+ # that we no longer pay any attention to LANG=C when decoding the
+ # commandline arguments.
out,err = self.run_bzr_subprocess('commit -m "%s"' % char,
retcode=1,
env_changes={'LANG': 'C'})
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2009-06-30 04:13:19 +0000
+++ b/bzrlib/tests/test_osutils.py 2009-07-23 16:01:17 +0000
@@ -625,6 +625,25 @@
self.assertEqual("1234", output.getvalue())
+class TestRelpath(tests.TestCase):
+
+ def test_simple_relpath(self):
+ cwd = osutils.getcwd()
+ subdir = cwd + '/subdir'
+ self.assertEqual('subdir', osutils.relpath(cwd, subdir))
+
+ def test_deep_relpath(self):
+ cwd = osutils.getcwd()
+ subdir = cwd + '/sub/subsubdir'
+ self.assertEqual('sub/subsubdir', osutils.relpath(cwd, subdir))
+
+ def test_not_relative(self):
+ self.assertRaises(errors.PathNotChild,
+ osutils.relpath, 'C:/path', 'H:/path')
+ self.assertRaises(errors.PathNotChild,
+ osutils.relpath, 'C:/', 'H:/path')
+
+
class TestSafeUnicode(tests.TestCase):
def test_from_ascii_string(self):
More information about the bazaar-commits
mailing list