Rev 416: Fix the unicode revid/fileid warnings. in file:///home/jelmer/bzr-svn/0.3/

Jelmer Vernooij jelmer at samba.org
Sun Mar 11 01:19:37 GMT 2007


At file:///home/jelmer/bzr-svn/0.3/

------------------------------------------------------------
revno: 416
revision-id: jelmer at samba.org-20070311011931-ybkbi14bf2lykzv0
parent: jelmer at samba.org-20070304124653-qonoqatvu19wwn8p
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.3
timestamp: Sun 2007-03-11 02:19:31 +0100
message:
  Fix the unicode revid/fileid warnings.
modified:
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
=== modified file 'checkout.py'
--- a/checkout.py	2007-03-04 12:46:53 +0000
+++ b/checkout.py	2007-03-11 01:19:31 +0000
@@ -220,7 +220,7 @@
         def add_file_to_inv(relpath, id, revid, parent_id):
             """Add a file to the inventory."""
             if os.path.islink(self.abspath(relpath)):
-                file = InventoryLink(str(id), os.path.basename(relpath), str(parent_id))
+                file = InventoryLink(id, os.path.basename(relpath), parent_id)
                 file.revision = revid
                 file.symlink_target = os.readlink(self.abspath(relpath))
                 file.text_sha1 = None
@@ -228,7 +228,7 @@
                 file.executable = False
                 inv.add(file)
             else:
-                file = InventoryFile(str(id), os.path.basename(relpath), str(parent_id))
+                file = InventoryFile(id, os.path.basename(relpath), parent_id)
                 file.revision = revid
                 try:
                     data = fingerprint_file(open(self.abspath(relpath)))
@@ -284,17 +284,19 @@
         def add_dir_to_inv(relpath, wc, parent_id):
             entries = svn.wc.entries_read(wc, False)
             entry = entries[""]
+            assert parent_id is None or isinstance(parent_id, str), "%r is not a string" % parent_id
             (id, revid) = find_ids(entry, rootwc)
             if id is None:
                 mutter('no id for %r' % entry.url)
                 return
+            assert isinstance(id, str), "%r is not a string" % id
 
             # First handle directory itself
             if relpath == "":
                 inv.add_path("", 'directory', ROOT_ID)
                 inv.revision_id = revid
             else:
-                inventry = InventoryDirectory(str(id), os.path.basename(relpath), str(parent_id))
+                inventry = InventoryDirectory(id, os.path.basename(relpath), parent_id)
                 inventry.revision = revid
                 inv.add(inventry)
 
@@ -396,12 +398,12 @@
         if message_callback is not None:
             def log_message_func(items, pool):
                 """ Simple log message provider for unit tests. """
-                return str(message_callback(self))
+                return message_callback(self).encode("utf-8")
         else:
             assert isinstance(message, basestring)
             def log_message_func(items, pool):
                 """ Simple log message provider for unit tests. """
-                return str(message)
+                return message.encode("utf-8")
 
         self.client_ctx.log_msg_baton2 = log_message_func
         commit_info = svn.client.commit3(specific_files, True, False, self.client_ctx)
@@ -481,7 +483,7 @@
                 SVN_PROP_BZR_FILEIDS, "")
         existing = committed + "".join(map(lambda (path, id): "%s\t%s\n" % (path, id), new_entries.items()))
         if existing != "":
-            svn.wc.prop_set(SVN_PROP_BZR_FILEIDS, str(existing), self.basedir, subwc)
+            svn.wc.prop_set(SVN_PROP_BZR_FILEIDS, existing.encode("utf-8"), self.basedir, subwc)
         if wc is None:
             svn.wc.adm_close(subwc)
 

=== modified file 'fileids.py'
--- a/fileids.py	2007-01-03 11:19:26 +0000
+++ b/fileids.py	2007-03-11 01:19:31 +0000
@@ -113,7 +113,7 @@
     def load(self, revid):
         map = {}
         for filename,create_revid,id in self.cachedb.execute("select filename, create_revid, id from filemap where revid='%s'"%revid):
-            map[filename] = (id,create_revid)
+            map[filename] = (id.encode("utf-8"),create_revid.encode("utf-8"))
 
         return map
 

=== modified file 'repository.py'
--- a/repository.py	2007-01-09 02:16:31 +0000
+++ b/repository.py	2007-03-11 01:19:31 +0000
@@ -60,7 +60,7 @@
     assert "%" in unsafe
     r = [((c in unsafe) and (u'%%%02x' % ord(c)) or c)
          for c in id]
-    return unicode(''.join(r))
+    return unicode(''.join(r)).encode("utf-8")
 
 
 import urllib
@@ -108,7 +108,7 @@
     assert revnum >= 0
     if revnum == 0:
         return NULL_REVISION
-    return unicode("%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/"))))
+    return unicode("%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/")))).encode("utf-8")
 
 
 def svk_feature_to_revision_id(feature):

=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py	2007-01-16 03:56:05 +0000
+++ b/tests/test_fileids.py	2007-03-11 01:19:31 +0000
@@ -165,7 +165,7 @@
                          generate_file_id("svn-v2:2 at uuid-bp", dir+"filename"))
 
     def test_generate_file_id_special_char(self):
-        self.assertEqual(u"svn-v2:2 at uuid-bp-mypath\x2c\x8a", 
+        self.assertEqual(u"svn-v2:2 at uuid-bp-mypath\x2c\x8a".encode("utf-8"), 
                          generate_file_id("svn-v2:2 at uuid-bp", u"mypath\x2c\x8a"))
 
 class TestFileMapping(TestCase):




More information about the bazaar-commits mailing list