Rev 4956: (vila) Better fix for fancy_rename respecting callers file encoding in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jan 13 16:10:26 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4956 [merge]
revision-id: pqm at pqm.ubuntu.com-20100113161025-5qx4ky13h27x4kj3
parent: pqm at pqm.ubuntu.com-20100113002544-mztf6nwrfgqienjc
parent: v.ladeuil+lp at free.fr-20100113153022-1xkfjwo0uevmg1db
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-01-13 16:10:25 +0000
message:
  (vila) Better fix for fancy_rename respecting callers file encoding
modified:
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/tests/ftp_server/pyftpdlib_based.py pyftpdlib_based.py-20090227151014-882k9q34m1gwnhvi-1
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2010-01-07 17:46:25 +0000
+++ b/bzrlib/osutils.py	2010-01-13 15:30:22 +0000
@@ -205,12 +205,14 @@
     :param unlink_func: A way to delete the target file if the full rename
         succeeds
     """
-    new = safe_unicode(new)
     # sftp rename doesn't allow overwriting, so play tricks:
     base = os.path.basename(new)
     dirname = os.path.dirname(new)
-    tmp_name = u'tmp.%s.%.9f.%d.%s' % (base, time.time(),
-                                       os.getpid(), rand_chars(10))
+    # callers use different encodings for the paths so the following MUST
+    # respect that. We rely on python upcasting to unicode if new is unicode
+    # and keeping a str if not.
+    tmp_name = 'tmp.%s.%.9f.%d.%s' % (base, time.time(),
+                                      os.getpid(), rand_chars(10))
     tmp_name = pathjoin(dirname, tmp_name)
 
     # Rename the file out of the way, but keep track if it didn't exist

=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- a/bzrlib/tests/ftp_server/pyftpdlib_based.py	2010-01-08 03:35:09 +0000
+++ b/bzrlib/tests/ftp_server/pyftpdlib_based.py	2010-01-13 15:30:22 +0000
@@ -53,7 +53,7 @@
         return [osutils.safe_utf8(s) for s in os.listdir(path)]
 
     def fs2ftp(self, fspath):
-        p = ftpserver.AbstractedFS.fs2ftp(self, fspath)
+        p = ftpserver.AbstractedFS.fs2ftp(self, osutils.safe_unicode(fspath))
         return osutils.safe_utf8(p)
 
     def ftp2fs(self, ftppath):




More information about the bazaar-commits mailing list