Rev 4941: (vila) Unicode path support for FTP transports in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jan 7 17:46:28 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4941 [merge]
revision-id: pqm at pqm.ubuntu.com-20100107174625-iza3wa6kf020jgd1
parent: pqm at pqm.ubuntu.com-20100107170244-3cgdapvuokgf8l42
parent: v.ladeuil+lp at free.fr-20100107162838-y3jeabrbw96d6ctq
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-01-07 17:46:25 +0000
message:
(vila) Unicode path support for FTP transports
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/tests/ftp_server/medusa_based.py ftpserver.py-20071019102346-61jbvdkrr70igauv-1
bzrlib/tests/ftp_server/pyftpdlib_based.py pyftpdlib_based.py-20090227151014-882k9q34m1gwnhvi-1
bzrlib/tests/per_transport.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/transport/ftp/__init__.py ftp.py-20051116161804-58dc9506548c2a53
=== modified file 'NEWS'
--- a/NEWS 2010-01-07 17:02:44 +0000
+++ b/NEWS 2010-01-07 17:46:25 +0000
@@ -61,6 +61,9 @@
returns ``EINTR`` by calling ``PyErr_CheckSignals``. This affected the
optional ``_readdir_pyx`` extension. (Andrew Bennetts, #495023)
+* FTP transports support Unicode paths by encoding/decoding them as utf8.
+ (Vincent Ladeuil, #472161)
+
* Give a clearer message if the lockdir disappears after being apparently
successfully taken. (Martin Pool, #498378)
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2010-01-06 22:17:10 +0000
+++ b/bzrlib/osutils.py 2010-01-07 17:46:25 +0000
@@ -202,13 +202,15 @@
:param old: The old path, to rename from
:param new: The new path, to rename to
:param rename_func: The potentially non-atomic rename function
- :param unlink_func: A way to delete the target file if the full rename succeeds
+ :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))
+ tmp_name = u'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/medusa_based.py'
--- a/bzrlib/tests/ftp_server/medusa_based.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/ftp_server/medusa_based.py 2010-01-07 16:27:12 +0000
@@ -213,6 +213,8 @@
class FTPTestServer(transport.Server):
"""Common code for FTP server facilities."""
+ no_unicode_support = True
+
def __init__(self):
self._root = None
self._ftp_server = None
=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- a/bzrlib/tests/ftp_server/pyftpdlib_based.py 2009-10-06 08:24:14 +0000
+++ b/bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-01-07 14:05:12 +0000
@@ -50,14 +50,15 @@
def listdir(self, path):
"""List the content of a directory."""
- # FIXME: need tests with unicode paths
return [osutils.safe_utf8(s) for s in os.listdir(path)]
def fs2ftp(self, fspath):
p = ftpserver.AbstractedFS.fs2ftp(self, fspath)
- # FIXME: need tests with unicode paths
return osutils.safe_utf8(p)
+ def ftp2fs(self, ftppath):
+ p = osutils.safe_unicode(ftppath)
+ return ftpserver.AbstractedFS.ftp2fs(self, p)
class BzrConformingFTPHandler(ftpserver.FTPHandler):
=== modified file 'bzrlib/tests/per_transport.py'
--- a/bzrlib/tests/per_transport.py 2009-10-05 12:50:34 +0000
+++ b/bzrlib/tests/per_transport.py 2010-01-07 16:27:12 +0000
@@ -1497,6 +1497,10 @@
u'\u65e5', # Kanji person
]
+ no_unicode_support = getattr(self._server, 'no_unicode_support', False)
+ if no_unicode_support:
+ raise tests.KnownFailure("test server cannot handle unicode paths")
+
try:
self.build_tree(files, transport=t, line_endings='binary')
except UnicodeError:
=== modified file 'bzrlib/transport/ftp/__init__.py'
--- a/bzrlib/transport/ftp/__init__.py 2009-10-06 08:24:14 +0000
+++ b/bzrlib/transport/ftp/__init__.py 2010-01-07 14:05:12 +0000
@@ -205,17 +205,6 @@
#raise TransportError(msg='Error for path: %s' % (path,), orig_error=e)
raise
- def _remote_path(self, relpath):
- # XXX: It seems that ftplib does not handle Unicode paths
- # at the same time, medusa won't handle utf8 paths So if
- # we .encode(utf8) here (see ConnectedTransport
- # implementation), then we get a Server failure. while
- # if we use str(), we get a UnicodeError, and the test
- # suite just skips testing UnicodePaths.
- relative = str(urlutils.unescape(relpath))
- remote_path = self._combine_paths(self._path, relative)
- return remote_path
-
def has(self, relpath):
"""Does the target location exist?"""
# FIXME jam 20060516 We *do* ask about directories in the test suite
More information about the bazaar-commits
mailing list