Rev 3486: (jam) Bug #135320, keep symlink lines in ascii, not Unicode in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jun 9 17:03:54 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3486
revision-id:pqm at pqm.ubuntu.com-20080609160347-bbytjk1914u9qast
parent: pqm at pqm.ubuntu.com-20080609074519-afx3xh7bd8wqzjy0
parent: john at arbash-meinel.com-20080605214739-uf050pk6fdgm5xbp
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-06-09 17:03:47 +0100
message:
(jam) Bug #135320, keep symlink lines in ascii, not Unicode
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
------------------------------------------------------------
revno: 3477.1.1.1.2
revision-id:john at arbash-meinel.com-20080605214739-uf050pk6fdgm5xbp
parent: john at arbash-meinel.com-20080605211911-2xtal2ehwcqkcymy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: symlink_unicode_135320
timestamp: Thu 2008-06-05 16:47:39 -0500
message:
Change how we handle unicode targets, and add a NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
------------------------------------------------------------
revno: 3477.1.1.1.1
revision-id:john at arbash-meinel.com-20080605211911-2xtal2ehwcqkcymy
parent: john at arbash-meinel.com-20080605210642-zoc3nelx84xmsxuf
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: symlink_unicode_135320
timestamp: Thu 2008-06-05 16:19:11 -0500
message:
Assert that we properly encode inv_entry.symlink_target, (bug #135320)
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
=== modified file 'NEWS'
--- a/NEWS 2008-06-06 19:07:50 +0000
+++ b/NEWS 2008-06-09 16:03:47 +0000
@@ -22,6 +22,11 @@
* Sanitize branch nick before using it as an attachment filename in
``bzr send``. (Lukáš Lalinský, #210218)
+ * Squash ``inv_entry.symlink_target`` to a plain string when
+ generating DirState details. This prevents from getting a
+ ``UnicodeError`` when you have symlinks and non-ascii filenames.
+ (John Arbash Meinel, #135320)
+
IMPROVEMENTS:
* Added the 'alias' command to set/unset and display aliases. (Tim Penhey)
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2008-05-08 04:12:06 +0000
+++ b/bzrlib/dirstate.py 2008-06-05 21:47:39 +0000
@@ -1825,7 +1825,8 @@
raise
return result
- def _inv_entry_to_details(self, inv_entry):
+ @staticmethod
+ def _inv_entry_to_details(inv_entry):
"""Convert an inventory entry (from a revision tree) to state details.
:param inv_entry: An inventory entry whose sha1 and link targets can be
@@ -1841,7 +1842,8 @@
size = 0
executable = False
elif kind == 'symlink':
- fingerprint = inv_entry.symlink_target or ''
+ # We don't support non-ascii targets for symlinks yet.
+ fingerprint = str(inv_entry.symlink_target or '')
size = 0
executable = False
elif kind == 'file':
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2008-04-24 07:22:53 +0000
+++ b/bzrlib/tests/test_dirstate.py 2008-06-05 21:47:39 +0000
@@ -23,6 +23,7 @@
from bzrlib import (
dirstate,
errors,
+ inventory,
osutils,
)
from bzrlib.memorytree import MemoryTree
@@ -2514,3 +2515,26 @@
state._discard_merge_parents()
state._validate()
self.assertEqual(exp_dirblocks, state._dirblocks)
+
+
+class Test_InvEntryToDetails(TestCaseWithDirState):
+
+ def assertDetails(self, expected, inv_entry):
+ details = dirstate.DirState._inv_entry_to_details(inv_entry)
+ self.assertEqual(expected, details)
+ # details should always allow join() and always be a plain str when
+ # finished
+ (minikind, fingerprint, size, executable, tree_data) = details
+ self.assertIsInstance(minikind, str)
+ self.assertIsInstance(fingerprint, str)
+ self.assertIsInstance(tree_data, str)
+
+ def test_unicode_symlink(self):
+ # In general, the code base doesn't support a target that contains
+ # non-ascii characters. So we just assert tha
+ inv_entry = inventory.InventoryLink('link-file-id', 'name',
+ 'link-parent-id')
+ inv_entry.revision = 'link-revision-id'
+ inv_entry.symlink_target = u'link-target'
+ details = self.assertDetails(('l', 'link-target', 0, False,
+ 'link-revision-id'), inv_entry)
More information about the bazaar-commits
mailing list