Rev 398: The Python Subversion bindings have trouble dealing with unicode commit messages. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Mon Jan 15 00:40:09 GMT 2007


------------------------------------------------------------
revno: 398
revision-id: jelmer at samba.org-20070115003937-mxyoa82zy1t616pi
parent: jelmer at samba.org-20070114233809-pjrkm3wnr2ezy6eo
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Mon 2007-01-15 01:39:37 +0100
message:
  The Python Subversion bindings have trouble dealing with unicode commit messages.
modified:
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  tests/test_workingtree.py      test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
=== modified file 'checkout.py'
--- a/checkout.py	2007-01-14 23:38:09 +0000
+++ b/checkout.py	2007-01-15 00:39:37 +0000
@@ -396,12 +396,12 @@
         if message_callback is not None:
             def log_message_func(items, pool):
                 """ Simple log message provider for unit tests. """
-                return message_callback(self)
+                return str(message_callback(self))
         else:
             assert isinstance(message, basestring)
             def log_message_func(items, pool):
                 """ Simple log message provider for unit tests. """
-                return message
+                return str(message)
 
         self.client_ctx.log_msg_baton2 = log_message_func
         commit_info = svn.client.commit3(specific_files, True, False, self.client_ctx)
@@ -421,13 +421,15 @@
         return revid
 
     def add(self, files, ids=None):
+        import pdb
+        pdb.set_trace()
         if ids:
             ids = copy(ids)
             ids.reverse()
         assert isinstance(files, list)
-        wc = self._get_wc(write_lock=True)
-        try:
-            for f in files:
+        for f in files:
+            try:
+                wc = self._get_wc(os.path.dirname(f), write_lock=True)
                 try:
                     svn.wc.add2(os.path.join(self.basedir, f), wc, None, 0, 
                             None, None, None)
@@ -439,8 +441,8 @@
                     elif num == svn.core.SVN_ERR_WC_PATH_NOT_FOUND:
                         raise NoSuchFile(path=f)
                     raise
-        finally:
-            svn.wc.adm_close(wc)
+            finally:
+                svn.wc.adm_close(wc)
         self.read_working_inventory()
 
     def basis_tree(self):

=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py	2007-01-14 23:38:09 +0000
+++ b/tests/test_workingtree.py	2007-01-15 00:39:37 +0000
@@ -57,6 +57,26 @@
         self.assertTrue(inv.has_filename("bl"))
         self.assertFalse(inv.has_filename("aa"))
 
+    def test_add_not_recursive(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl/file": "data"})
+        tree = WorkingTree.open("dc")
+        tree.add(["bl"])
+
+        tree = WorkingTree.open("dc")
+        self.assertTrue(tree.inventory.has_filename("bl"))
+        self.assertFalse(tree.inventory.has_filename("bl/file"))
+
+    def test_add_nested(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl/file": "data"})
+        tree = WorkingTree.open("dc")
+        tree.add(["bl", "bl/file"])
+
+        tree = WorkingTree.open("dc")
+        self.assertTrue(tree.inventory.has_filename("bl"))
+        self.assertTrue(tree.inventory.has_filename("bl/file"))
+
     def test_lock_write(self):
         self.make_client('a', 'dc')
         tree = WorkingTree.open("dc")
@@ -271,6 +291,13 @@
         tree = WorkingTree.open("dc")
         self.assertEqual(['bl'], list(tree.unknowns()))
 
+    def test_unknown_not_added(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl": None})
+
+        tree = WorkingTree.open("dc")
+        self.assertFalse(tree.inventory.has_filename("bl"))
+
     def test_extras(self):
         self.make_client('a', 'dc')
         self.build_tree({"dc/bl": None})
@@ -338,6 +365,22 @@
         orig_tree = tree.basis_tree()
         tree.commit(message_callback=lambda x: "data")
 
+    def test_commit_callback_unicode(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl": "data"})
+        self.client_add("dc/bl")
+        tree = WorkingTree.open("dc")
+        orig_tree = tree.basis_tree()
+        tree.commit(message_callback=lambda x: u"data")
+
+    def test_commit_message_unicode(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl": "data"})
+        self.client_add("dc/bl")
+        tree = WorkingTree.open("dc")
+        orig_tree = tree.basis_tree()
+        tree.commit(message=u"data")
+
     def test_commit_nested(self):
         repos_url = self.make_client('a', 'dc')
         self.build_tree({"dc/branches/foobranch/file": "data"})




More information about the bazaar-commits mailing list