Rev 2362: Add an overzealous test, for Unicode support of _iter_changes. in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/iter_changes_unicode_unknowns
John Arbash Meinel
john at arbash-meinel.com
Thu Mar 15 22:35:55 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/iter_changes_unicode_unknowns
------------------------------------------------------------
revno: 2362
revision-id: john at arbash-meinel.com-20070315223535-d3d4964oe1hc8zhg
parent: john at arbash-meinel.com-20070315205112-g98xrtulgesi9kdy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: iter_changes_unicode_unknowns
timestamp: Thu 2007-03-15 17:35:35 -0500
message:
Add an overzealous test, for Unicode support of _iter_changes.
For both knowns and unknowns.
And include a basic, if suboptimal, fix.
I would rather defer the decoding until we've determined that we are going to return the tuple.
There is still something broken with added files, but I'll get to that.
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-03-15 15:12:45 +0000
+++ b/bzrlib/tests/__init__.py 2007-03-15 22:35:35 +0000
@@ -711,8 +711,13 @@
return ''.join(difflines)
def assertEqual(self, a, b, message=''):
- if a == b:
- return
+ try:
+ if a == b:
+ return
+ except UnicodeError, e:
+ # If we can't compare without getting a UnicodeError, then
+ # obviously they are different
+ mutter('UnicodeError: %s', e)
if message:
message += '\n'
raise AssertionError("%snot equal:\na = %s\nb = %s\n"
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py 2007-03-15 20:51:12 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py 2007-03-15 22:35:35 +0000
@@ -1052,20 +1052,39 @@
])
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
- def test_trees_with_unknowns(self):
+ def test_trees_with_unknowns_and_unicode(self):
tree1 = self.make_branch_and_tree('tree1')
tree2 = self.make_to_branch_and_tree('tree2')
root_id = tree1.get_root_id()
tree2.set_root_id(root_id)
- self.build_tree(['tree1/a/',
- 'tree2/a/',
- 'tree2/a/unknown_dir/',
- 'tree2/a/unknown_file',
- 'tree2/a/unknown_dir/file',
- 'tree2/unknown_root_file',
+ # u'\u03b1' == GREEK SMALL LETTER ALPHA
+ # u'\u03c9' == GREEK SMALL LETTER OMEGA
+ a_id = u'\u03b1-id'.encode('utf8')
+ mod_id = u'\u03c9_mod_id'.encode('utf8')
+ rename_id = u'\u03c9_rename_id'.encode('utf8')
+ removed_id = u'\u03c9_removed_id'.encode('utf8')
+ added_id = u'\u03c9_added_id'.encode('utf8')
+ self.build_tree([u'tree1/\u03b1/',
+ u'tree1/\u03b1/\u03c9-modified',
+ u'tree1/\u03b1/\u03c9-removed',
+ u'tree2/\u03b1/',
+ u'tree2/\u03b1/unknown_dir/',
+ u'tree2/\u03b1/unknown_file',
+ u'tree2/\u03b1/unknown_dir/file',
+ # u'tree2/\u03b1/\u03c9-added',
+ u'tree2/\u03b1/\u03c9-modified',
+ u'tree2/\u03c9-unknown_root_file',
])
- tree1.add(['a'], ['a-id'])
- tree2.add(['a'], ['a-id'])
+ self.build_tree_contents([(u'tree1/\u03c9-source', 'contents\n'),
+ (u'tree2/\u03b1/\u03c9-target', 'contents\n'),
+ ])
+ tree1.add([u'\u03b1', u'\u03b1/\u03c9-modified', u'\u03c9-source',
+ u'\u03b1/\u03c9-removed'],
+ [a_id, mod_id, rename_id, removed_id])
+ tree2.add([u'\u03b1', u'\u03b1/\u03c9-modified',
+ u'\u03b1/\u03c9-target'], #, u'\u03b1/\u03c9-added'],
+ [a_id, mod_id, rename_id])# , added_id])
+
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
tree1.lock_read()
self.addCleanup(tree1.unlock)
@@ -1073,10 +1092,14 @@
self.addCleanup(tree2.unlock)
expected = sorted([
self.unchanged(tree1, root_id),
- self.unchanged(tree1, 'a-id'),
- self.unversioned(tree2, 'a/unknown_dir'),
- self.unversioned(tree2, 'a/unknown_file'),
- self.unversioned(tree2, 'unknown_root_file'),
+ self.unchanged(tree1, a_id),
+ # self.added(tree2, added_id),
+ self.deleted(tree1, removed_id),
+ self.renamed(tree1, tree2, rename_id, False),
+ self.content_changed(tree1, mod_id),
+ self.unversioned(tree2, u'\u03b1/unknown_dir'),
+ self.unversioned(tree2, u'\u03b1/unknown_file'),
+ self.unversioned(tree2, u'\u03c9-unknown_root_file'),
# a/unknown_dir/file should not be included because we should not
# recurse into unknown_dir
# self.unversioned(tree2, 'a/unknown_dir/file'),
@@ -1086,3 +1109,20 @@
include_unchanged=True,
require_versioned=False,
want_unversioned=True))
+
+ # We should also be able to select just a subset
+ expected = sorted([
+ self.unchanged(tree1, a_id),
+ # self.added(tree2, added_id),
+ self.deleted(tree1, removed_id),
+ self.renamed(tree1, tree2, rename_id, False),
+ self.content_changed(tree1, mod_id),
+ self.unversioned(tree2, u'\u03b1/unknown_dir'),
+ self.unversioned(tree2, u'\u03b1/unknown_file'),
+ ])
+ self.assertEqual(expected,
+ self.do_iter_changes(tree1, tree2,
+ specific_files=[u'\u03b1'],
+ include_unchanged=True,
+ require_versioned=False,
+ want_unversioned=True))
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-03-13 13:38:34 +0000
+++ b/bzrlib/workingtree_4.py 2007-03-15 22:35:35 +0000
@@ -1913,7 +1913,7 @@
return ((entry[0][2], (old_path, path), content_change,
(True, True),
(source_parent_id, target_parent_id),
- (old_basename, entry[0][1]),
+ (utf8_decode(old_basename)[0], utf8_decode(entry[0][1])[0]),
(_minikind_to_kind[source_minikind], target_kind),
(source_exec, target_exec)),)
elif source_minikind in 'a' and target_minikind in 'fdlt':
@@ -1938,7 +1938,7 @@
(False, True),
(None, parent_id),
(None, entry[0][1]),
- (None, path_info[2]),
+ (None, utf8_decode(path_info[2])[0]),
(None, target_exec)),)
else:
# but its not on disk: we deliberately treat this as just
@@ -1957,7 +1957,7 @@
return ((entry[0][2], (old_path, None), True,
(True, False),
(parent_id, None),
- (entry[0][1], None),
+ (utf8_decode(entry[0][1])[0], None),
(_minikind_to_kind[source_minikind], None),
(source_details[3], None)),)
elif source_minikind in 'fdlt' and target_minikind in 'r':
@@ -1983,11 +1983,12 @@
# TODO: the pending list should be lexically sorted? the
# interface doesn't require it.
current_root = search_specific_files.pop()
+ current_root_unicode = current_root.decode('utf8')
searched_specific_files.add(current_root)
# process the entries for this containing directory: the rest will be
# found by their parents recursively.
root_entries = _entries_for_path(current_root)
- root_abspath = self.target.abspath(current_root)
+ root_abspath = self.target.abspath(current_root_unicode)
try:
root_stat = os.lstat(root_abspath)
except OSError, e:
@@ -2029,13 +2030,13 @@
((utf8_decode(result[1][0])[0]),
utf8_decode(result[1][1])[0]),) + result[2:]
yield result
- if want_unversioned and not path_handled:
+ if want_unversioned and not path_handled and root_dir_info:
new_executable = bool(
stat.S_ISREG(root_dir_info[3].st_mode)
and stat.S_IEXEC & root_dir_info[3].st_mode)
- yield (None, (None, current_root), True, (False, False),
+ yield (None, (None, current_root_unicode), True, (False, False),
(None, None),
- (None, splitpath(current_root)[-1]),
+ (None, splitpath(current_root_unicode)[-1]),
(None, root_dir_info[2]), (None, new_executable))
initial_key = (current_root, '', '')
block_index, _ = state._find_block_index_from_key(initial_key)
@@ -2225,11 +2226,12 @@
stat.S_ISREG(current_path_info[3].st_mode)
and stat.S_IEXEC & current_path_info[3].st_mode)
if want_unversioned:
- yield (None, (None, current_path_info[0]),
+ yield (None,
+ (None, utf8_decode(current_path_info[0])[0]),
True,
(False, False),
(None, None),
- (None, current_path_info[1]),
+ (None, utf8_decode(current_path_info[1])[0]),
(None, current_path_info[2]),
(None, new_executable))
# dont descend into this unversioned path if it is
More information about the bazaar-commits
mailing list