Handle long file names with unicode characters correctly on python2.4 (#129334)
authorJelmer Vernooij <jelmer@samba.org>
Sun, 23 Sep 2007 23:48:30 +0000 (01:48 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 23 Sep 2007 23:48:30 +0000 (01:48 +0200)
NEWS
fileids.py
tests/test_fileids.py

diff --git a/NEWS b/NEWS
index d64ef9d3343a01457c432b151c163c5b33c93647..63c069dfa0e0fc4bd52bdee6a0a30390f94b608e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ bzr-svn 0.4.4        UNRELEASED
    * Handle NULL_REVISION in SvnRepository.copy_content(). Fixes compatibility 
      with bzr merge-into.
 
+  BUG FIXES
+
+   * Handle long file names with unicode characters correctly on python2.4 (#129334)
+
 bzr-svn 0.4.3  2007-09-15
  
   PERFORMANCE
index a04af2132ee3f3451ff684157ddb7fe06d23d0c4..3d52fd3cbf054e9db881cb9bf3b4613a249e485a 100644 (file)
@@ -39,7 +39,7 @@ def generate_svn_file_id(uuid, revnum, branch, path):
     if len(ret) > 150:
         ret = "%d@%s:%s;%s" % (revnum, uuid, 
                             escape_svn_path(branch),
-                            sha.new(path).hexdigest())
+                            sha.new(path.encode('utf-8')).hexdigest())
     assert isinstance(ret, str)
     return osutils.safe_file_id(ret)
 
index a472f261e9601f7069e740198648013ec6db9634..798c96eb4b16ba9afe1cd5425ac453a0c86eba5a 100644 (file)
@@ -178,6 +178,11 @@ class TestFileIdGenerator(TestCase):
         self.assertEqual("2@uuid:bp;" + sha1(dir+"filename"), 
                 generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp", "bla"), dir+"filename"))
 
+    def test_generate_file_id_long_nordic(self):
+        dir = "this/is/a" + ("/very"*40) + "/long/path/"
+        self.assertEqual("2@uuid:bp;" + sha1((dir+u"filename\x2c\x8a").encode('utf-8')), 
+                generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp", "bla"), dir+u"filename\x2c\x8a"))
+
     def test_generate_revid_special_char_ascii(self):
         self.assertEqual("2@uuid:bp:mypath%2C%8A", 
                 generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp", "bla"), "mypath\x2c\x8a"))