Rev 2475: (John Arbash Meinel) Fix bug #111127 and bug #111288. WT4._iter_changes had difficulties with directories with '-', and filesystem renames. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue May 1 19:27:16 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2475
revision-id: pqm at pqm.ubuntu.com-20070501182714-71xp33bziogu3qu0
parent: pqm at pqm.ubuntu.com-20070430223205-x4uyrteryh0230fp
parent: john at arbash-meinel.com-20070430174510-qdteh5dy45gbj785
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-05-01 19:27:14 +0100
message:
(John Arbash Meinel) Fix bug #111127 and bug #111288. WT4._iter_changes had difficulties with directories with '-', and filesystem renames.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 2472.2.2
merged: john at arbash-meinel.com-20070430174510-qdteh5dy45gbj785
parent: john at arbash-meinel.com-20070430174107-jec5pf7b63kc2uj9
parent: john at arbash-meinel.com-20070430173412-538b3mvbh9b8db8l
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_fixes
timestamp: Mon 2007-04-30 12:45:10 -0500
message:
[merge] bugfix for bug #111288, resolve conflicts.
------------------------------------------------------------
revno: 2472.3.2
merged: john at arbash-meinel.com-20070430173412-538b3mvbh9b8db8l
parent: john at arbash-meinel.com-20070430172939-hvjgsm1pinoawdy5
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: renamed_file_111288
timestamp: Mon 2007-04-30 12:34:12 -0500
message:
Now that finding a file on disk which doesn't match
the dirblock doesn't claim 'path_handled', it is identical
to the case when the dirblock entry is marked as 'a' or 'r'.
So remove the extra else clause for simplicity.
------------------------------------------------------------
revno: 2472.3.1
merged: john at arbash-meinel.com-20070430172939-hvjgsm1pinoawdy5
parent: pqm at pqm.ubuntu.com-20070430083158-pitv7lbgdu0q8g6h
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: renamed_file_111288
timestamp: Mon 2007-04-30 12:29:39 -0500
message:
Fix bug #111288. When we don't have a match
don't consider the disk file processed. Because we need to
emit an 'unknown' record for it.
------------------------------------------------------------
revno: 2472.2.1
merged: john at arbash-meinel.com-20070430174107-jec5pf7b63kc2uj9
parent: pqm at pqm.ubuntu.com-20070430083158-pitv7lbgdu0q8g6h
parent: john at arbash-meinel.com-20070430170541-pdh0k81zpedgjl70
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_fixes
timestamp: Mon 2007-04-30 12:41:07 -0500
message:
[merge] fix for bug #111127
------------------------------------------------------------
revno: 2466.5.4
merged: john at arbash-meinel.com-20070430170541-pdh0k81zpedgjl70
parent: john at arbash-meinel.com-20070430162558-f040stduyrfflef9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mixed_names_111127
timestamp: Mon 2007-04-30 12:05:41 -0500
message:
Fix bug #11127 by splitting paths on '/'.
This adds a bit of overhead when paths don't match.
So conceptually we might want to cache the split value,
or return it from the underlying iterator.
However, we only need it when the current iterators don't match
so most of the time a simple 'x == y' is sufficient, since
equality is correct with or without the split().
So the computational overhead should be fine.
------------------------------------------------------------
revno: 2466.5.3
merged: john at arbash-meinel.com-20070430162558-f040stduyrfflef9
parent: john at arbash-meinel.com-20070430162242-3gds64wynnny2t57
parent: pqm at pqm.ubuntu.com-20070430083158-pitv7lbgdu0q8g6h
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mixed_names_111127
timestamp: Mon 2007-04-30 11:25:58 -0500
message:
[merge] bzr.dev 2472
------------------------------------------------------------
revno: 2466.5.2
merged: john at arbash-meinel.com-20070430162242-3gds64wynnny2t57
parent: john at arbash-meinel.com-20070430160855-z8zh7eb7r629ch6g
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mixed_names_111127
timestamp: Mon 2007-04-30 11:22:42 -0500
message:
Extend the test a bit to make sure the include_unchanged value is correct.
still (broken)
------------------------------------------------------------
revno: 2466.5.1
merged: john at arbash-meinel.com-20070430160855-z8zh7eb7r629ch6g
parent: pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: mixed_names_111127
timestamp: Mon 2007-04-30 11:08:55 -0500
message:
Add a (failing) test for bug 111127
=== modified file 'NEWS'
--- a/NEWS 2007-04-30 07:48:55 +0000
+++ b/NEWS 2007-04-30 17:45:10 +0000
@@ -1,4 +1,16 @@
IN DEVELOPMENT
+
+ BUGFIXES:
+
+ * Handle when you have 2 directories with similar names, but one has a
+ hyphen. (``'abc'`` versus ``'abc-2'``). The WT4._iter_changes
+ iterator was using direct comparison and ``'abc/a'`` sorts after
+ ``'abc-2'``, but ``('abc', 'a')`` sorts before ``('abc-2',)``.
+ (John Arbash Meinel, #111227)
+
+ * Handle when someone renames a file on disk without telling bzr.
+ Previously we would report the first file as missing, but not show
+ the new unknown file. (John Arbash Meinel, #111288)
bzr 0.16rc2 2007-04-30
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py 2007-04-26 20:45:53 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py 2007-04-30 17:45:10 +0000
@@ -867,6 +867,51 @@
specific_files=specific_files, require_versioned=False,
want_unversioned=True))
+ def test_similar_filenames(self):
+ """Test when we have a few files with similar names."""
+ tree1 = self.make_branch_and_tree('tree1')
+ tree2 = self.make_branch_and_tree('tree2')
+ tree2.set_root_id(tree1.get_root_id())
+
+ # The trees are actually identical, but they happen to contain
+ # similarly named files.
+ self.build_tree(['tree1/a/',
+ 'tree1/a/b/',
+ 'tree1/a/b/c/',
+ 'tree1/a/b/c/d/',
+ 'tree1/a-c/',
+ 'tree1/a-c/e/',
+ 'tree2/a/',
+ 'tree2/a/b/',
+ 'tree2/a/b/c/',
+ 'tree2/a/b/c/d/',
+ 'tree2/a-c/',
+ 'tree2/a-c/e/',
+ ])
+ tree1.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
+ ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
+ tree2.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
+ ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
+
+ tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+ self.assertEqual([], self.do_iter_changes(tree1, tree2,
+ want_unversioned=True))
+ expected = sorted([
+ self.unchanged(tree2, tree2.get_root_id()),
+ self.unchanged(tree2, 'a-id'),
+ self.unchanged(tree2, 'b-id'),
+ self.unchanged(tree2, 'c-id'),
+ self.unchanged(tree2, 'd-id'),
+ self.unchanged(tree2, 'a-c-id'),
+ self.unchanged(tree2, 'e-id'),
+ ])
+ self.assertEqual(expected,
+ self.do_iter_changes(tree1, tree2,
+ want_unversioned=True,
+ include_unchanged=True))
+
+
def test_unversioned_subtree_only_emits_root(self):
tree1 = self.make_branch_and_tree('tree1')
tree2 = self.make_to_branch_and_tree('tree2')
@@ -1354,3 +1399,34 @@
self.assertEqual(expected,
self.do_iter_changes(tree1, tree2,
want_unversioned=True))
+
+ def test_renamed_and_unknown(self):
+ """A file was moved on the filesystem, but not in bzr."""
+ 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)
+
+ # The final changes are:
+ # bzr add a b
+ # mv a a2
+
+ self.build_tree_contents([
+ ('tree1/a', 'a contents\n'),
+ ('tree1/b', 'b contents\n'),
+ ('tree2/a', 'a contents\n'),
+ ('tree2/b', 'b contents\n'),
+ ])
+ tree1.add(['a', 'b'], ['a-id', 'b-id'])
+ tree2.add(['a', 'b'], ['a-id', 'b-id'])
+ os.rename('tree2/a', 'tree2/a2')
+
+ tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
+
+ expected = sorted([
+ self.missing('a-id', 'a', 'a', tree2.get_root_id(), 'file'),
+ self.unversioned(tree2, 'a2'),
+ ])
+ self.assertEqual(expected,
+ self.do_iter_changes(tree1, tree2,
+ want_unversioned=True))
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-04-30 05:13:58 +0000
+++ b/bzrlib/workingtree_4.py 2007-04-30 17:45:10 +0000
@@ -2122,7 +2122,7 @@
current_block is not None):
if (current_dir_info and current_block
and current_dir_info[0][0] != current_block[0]):
- if current_dir_info[0][0] < current_block[0] :
+ if current_dir_info[0][0].split('/') < current_block[0].split('/'):
# filesystem data refers to paths not covered by the dirblock.
# this has two possibilities:
# A) it is versioned but empty, so there is no block for it
@@ -2256,8 +2256,14 @@
result[6],
result[7],
)
- elif current_entry[0][1] != current_path_info[1]:
- if current_path_info[1] < current_entry[0][1]:
+ elif (current_entry[0][1] != current_path_info[1]
+ or current_entry[1][target_index][0] in 'ar'):
+ # The current path on disk doesn't match the dirblock
+ # record. Either the dirblock is marked as absent, or
+ # the file on disk is not present at all in the
+ # dirblock. Either way, report about the dirblock
+ # entry, and let other code handle the filesystem one.
+ if current_path_info[1].split('/') < current_entry[0][1].split('/'):
# extra file on disk: pass for now, but only
# increment the path, not the entry
advance_entry = False
@@ -2268,7 +2274,6 @@
# this check should probably be outside the loop: one
# 'iterate two trees' api, and then _iter_changes filters
# unchanged pairs. - RBC 20070226
- path_handled = True
if (include_unchanged
or result[2] # content change
or result[3][0] != result[3][1] # versioned status
@@ -2289,33 +2294,6 @@
result[7],
)
advance_path = False
- elif current_entry[1][target_index][0] in 'ar':
- # The path matches, but the current entry is marked as
- # not being here. So we don't want to consider this
- # as a match. We still need to process the current
- # entry, though.
- advance_path = False
- path_handled = False
- for result in _process_entry(current_entry, None):
- if (include_unchanged
- or result[2] # content change
- or result[3][0] != result[3][1] # versioned status
- or result[4][0] != result[4][1] # parent id
- or result[5][0] != result[5][1] # name
- or result[6][0] != result[6][1] # kind
- or result[7][0] != result[7][1] # executable
- ):
- yield (result[0],
- (utf8_decode_or_none(result[1][0]),
- utf8_decode_or_none(result[1][1])),
- result[2],
- result[3],
- result[4],
- (utf8_decode_or_none(result[5][0]),
- utf8_decode_or_none(result[5][1])),
- result[6],
- result[7],
- )
else:
for result in _process_entry(current_entry, current_path_info):
# this check should probably be outside the loop: one
More information about the bazaar-commits
mailing list