Rev 5068: (spiv) Fix regression on non-posix systems with directory renaming in in file:///home/pqm/archives/thelove/bzr/2.2/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jul 29 13:01:08 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.2/
------------------------------------------------------------
revno: 5068 [merge]
revision-id: pqm at pqm.ubuntu.com-20100729120106-psygyxky8i3jh7j7
parent: pqm at pqm.ubuntu.com-20100729092809-ppsnhr9bx1nnavti
parent: gzlist at googlemail.com-20100721103831-jgvg37f6aantz6kn
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Thu 2010-07-29 13:01:06 +0100
message:
(spiv) Fix regression on non-posix systems with directory renaming in
transform (Martin [gz])
modified:
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2010-05-13 17:32:55 +0000
+++ b/bzrlib/tests/test_transform.py 2010-07-21 10:38:31 +0000
@@ -859,10 +859,14 @@
myfile = create.new_file('myfile', root_id, 'myfile-text',
'myfile-id')
create.apply()
- # make the file and directory readonly in the hope this will prevent
- # renames
- osutils.make_readonly(self.wt.abspath('first-dir'))
- osutils.make_readonly(self.wt.abspath('myfile'))
+ if os.name == "posix" and sys.platform != "cygwin":
+ # posix filesystems fail on renaming if the readonly bit is set
+ osutils.make_readonly(self.wt.abspath('first-dir'))
+ elif os.name == "nt":
+ # windows filesystems fail on renaming open files
+ self.addCleanup(file(self.wt.abspath('myfile')).close)
+ else:
+ self.skip("Don't know how to force a permissions error on rename")
# now transform to rename
rename_transform, root_id = self.get_transform()
file_trans_id = rename_transform.trans_id_file_id('myfile-id')
@@ -870,13 +874,15 @@
rename_transform.adjust_path('newname', dir_id, file_trans_id)
e = self.assertRaises(errors.TransformRenameFailed,
rename_transform.apply)
- # Looks like:
+ # On nix looks like:
# "Failed to rename .../work/.bzr/checkout/limbo/new-1
# to .../first-dir/newname: [Errno 13] Permission denied"
- # so the first filename is not visible in it; we expect a strerror but
- # it may vary per OS and language so it's not checked here
+ # On windows looks like:
+ # "Failed to rename .../work/myfile to
+ # .../work/.bzr/checkout/limbo/new-1: [Errno 13] Permission denied"
+ # The strerror will vary per OS and language so it's not checked here
self.assertContainsRe(str(e),
- "Failed to rename .*first-dir.newname:")
+ "Failed to rename .*(first-dir.newname:|myfile)")
def test_set_executability_order(self):
"""Ensure that executability behaves the same, no matter what order.
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2010-05-29 15:40:14 +0000
+++ b/bzrlib/transform.py 2010-07-21 09:15:47 +0000
@@ -1182,7 +1182,7 @@
if trans_id not in self._new_contents:
continue
new_path = self._limbo_name(trans_id)
- osutils.rename(old_path, new_path)
+ os.rename(old_path, new_path)
for descendant in self._limbo_descendants(trans_id):
desc_path = self._limbo_files[descendant]
desc_path = new_path + desc_path[len(old_path):]
@@ -2935,8 +2935,8 @@
def rename(self, from_, to):
"""Rename a file from one path to another."""
try:
- osutils.rename(from_, to)
- except (IOError, OSError), e:
+ os.rename(from_, to)
+ except OSError, e:
if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
raise errors.FileExists(to, str(e))
# normal OSError doesn't include filenames so it's hard to see where
@@ -2958,8 +2958,8 @@
"""Reverse all renames that have been performed"""
for from_, to in reversed(self.past_renames):
try:
- osutils.rename(to, from_)
- except (OSError, IOError), e:
+ os.rename(to, from_)
+ except OSError, e:
raise errors.TransformRenameFailed(to, from_, str(e), e.errno)
# after rollback, don't reuse _FileMover
past_renames = None
More information about the bazaar-commits
mailing list