Rev 842: Handle unicode strings in working tree inventory better. (#183853) in file:///data/jelmer/bzr-svn/0.4/
Jelmer Vernooij
jelmer at samba.org
Fri Jan 18 04:05:55 GMT 2008
At file:///data/jelmer/bzr-svn/0.4/
------------------------------------------------------------
revno: 842
revision-id:jelmer at samba.org-20080118033541-ppue6qsddp6sxm8s
parent: jelmer at samba.org-20080118031619-1d7gehl1w612qbf7
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-01-18 04:35:41 +0100
message:
Handle unicode strings in working tree inventory better. (#183853)
modified:
NEWS news-20061231030336-h9fhq245ie0de8bs-1
specs/unicode.txt unicode.txt-20080117193237-e9it2di8ed47svqo-1
tests/test_workingtree.py test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
workingtree.py workingtree.py-20060306120941-b083cb0fdd4a69de
=== modified file 'NEWS'
--- a/NEWS 2008-01-18 03:16:19 +0000
+++ b/NEWS 2008-01-18 03:35:41 +0000
@@ -4,6 +4,9 @@
* Consistently handle unicode characters. (#129334, #164381)
+ * Handle unicode strings appropriately when reading working tree
+ inventory. (#183853)
+
bzr-svn 0.4.6 2008-01-08
PERFORMANCE
=== modified file 'specs/unicode.txt'
--- a/specs/unicode.txt 2008-01-17 22:28:15 +0000
+++ b/specs/unicode.txt 2008-01-18 03:35:41 +0000
@@ -44,3 +44,8 @@
Since SQLite tends to return unicode strings, most strings need to be
encoded as utf8 before they are returned for use by other parts of the
code. The LogWalker object should take care of this.
+
+Working Trees
+~~~~~~~~~~~~~
+Bazaars working tree functions assume all relative paths are unicode,
+so the same convention will be used for bzr-svn's working tree-related code.
=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py 2008-01-17 23:19:19 +0000
+++ b/tests/test_workingtree.py 2008-01-18 03:35:41 +0000
@@ -1,4 +1,5 @@
# Copyright (C) 2006 Jelmer Vernooij <jelmer at samba.org>
+# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -57,6 +58,15 @@
self.assertTrue(inv.has_filename("bl"))
self.assertFalse(inv.has_filename("aa"))
+ def test_special_char(self):
+ self.make_client('a', 'dc')
+ self.build_tree({u"dc/I²C": "data"})
+ self.client_add("dc/I²C")
+ tree = self.open_checkout("dc")
+ inv = tree.read_working_inventory()
+ self.assertIsInstance(inv, Inventory)
+ self.assertTrue(inv.has_filename(u"I²C"))
+
def test_smart_add_file(self):
self.make_client('a', 'dc')
self.build_tree({"dc/bl": "data"})
=== modified file 'workingtree.py'
--- a/workingtree.py 2008-01-17 23:19:19 +0000
+++ b/workingtree.py 2008-01-18 03:35:41 +0000
@@ -239,6 +239,7 @@
def add_file_to_inv(relpath, id, revid, parent_id):
"""Add a file to the inventory."""
+ assert isinstance(relpath, unicode)
if os.path.islink(self.abspath(relpath)):
file = InventoryLink(id, os.path.basename(relpath), parent_id)
file.revision = revid
@@ -304,6 +305,7 @@
return ("NEW-" + escape_svn_path(entry.url[len(entry.repos):].strip("/")), None)
def add_dir_to_inv(relpath, wc, parent_id):
+ assert isinstance(relpath, unicode)
entries = svn.wc.entries_read(wc, False)
entry = entries[""]
assert parent_id is None or isinstance(parent_id, str), \
@@ -316,7 +318,7 @@
assert isinstance(id, str), "%r is not a string" % id
# First handle directory itself
- inv.add_path(relpath, 'directory', id, parent_id).revision = revid
+ inv.add_path(relpath.decode("utf-8"), 'directory', id, parent_id).revision = revid
if relpath == "":
inv.revision_id = revid
@@ -324,7 +326,7 @@
if name == "":
continue
- subrelpath = os.path.join(relpath, name)
+ subrelpath = os.path.join(relpath, name.decode("utf-8"))
entry = entries[name]
assert entry
@@ -345,7 +347,7 @@
rootwc = self._get_wc()
try:
- add_dir_to_inv("", rootwc, None)
+ add_dir_to_inv(u"", rootwc, None)
finally:
svn.wc.adm_close(rootwc)
More information about the bazaar-commits
mailing list