Rev 2471: (robertc) ``WorkingTree4._iter_changes`` should not descend into unversioned directories. (John Arbash Meinel, #110399) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Apr 30 06:44:18 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2471
revision-id: pqm at pqm.ubuntu.com-20070430054416-kl8x12cim7g45lap
parent: pqm at pqm.ubuntu.com-20070430042900-o9x8ggxoevt9s9fi
parent: robertc at robertcollins.net-20070430051358-8cp7kvp1q0tqhxx0
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-04-30 06:44:16 +0100
message:
(robertc) ``WorkingTree4._iter_changes`` should not descend into unversioned directories. (John Arbash Meinel, #110399)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 2466.4.4
merged: robertc at robertcollins.net-20070430051358-8cp7kvp1q0tqhxx0
parent: john at arbash-meinel.com-20070426230146-ip22905t91xhkjs9
parent: pqm at pqm.ubuntu.com-20070430042900-o9x8ggxoevt9s9fi
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Mon 2007-04-30 15:13:58 +1000
message:
Merge Johns fix for bug 110399.
------------------------------------------------------------
revno: 2466.4.3
merged: john at arbash-meinel.com-20070426230146-ip22905t91xhkjs9
parent: john at arbash-meinel.com-20070426225601-ae4qfcb8bzcfomny
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: iter_changes_ignores_unknowns
timestamp: Thu 2007-04-26 18:01:46 -0500
message:
Fix bug #110399 by changing _iter_changes to never descend into unknown directories.
There was a bug when a versioned directory had no versioned children.
It would descend into all unknown subdirs.
This was originally fixed when 'want_unchanged=True', but now it is
also fixed when 'want_unchanged=False'.
We really should have an intertree test for this, but to detect
descent, we spy on walkdirs, which WT3 doesn't use.
------------------------------------------------------------
revno: 2466.4.2
merged: john at arbash-meinel.com-20070426225601-ae4qfcb8bzcfomny
parent: john at arbash-meinel.com-20070426224632-6nrmxl1kfbji3c63
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: iter_changes_ignores_unknowns
timestamp: Thu 2007-04-26 17:56:01 -0500
message:
Clean up the (failing) test so that the last thing
to fail is what I'm fixing.
------------------------------------------------------------
revno: 2466.4.1
merged: john at arbash-meinel.com-20070426224632-6nrmxl1kfbji3c63
parent: pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: iter_changes_ignores_unknowns
timestamp: Thu 2007-04-26 17:46:32 -0500
message:
Add a (failing) test that exposes how _iter_changes is accidentally walking into unversioned directories.
=== modified file 'NEWS'
--- a/NEWS 2007-04-30 03:48:51 +0000
+++ b/NEWS 2007-04-30 05:13:58 +0000
@@ -17,6 +17,9 @@
* Also handle when you rename a file and create a file where it used
to be. (John Arbash Meinel, #110256)
+ * ``WorkingTree4._iter_changes`` should not descend into unversioned
+ directories. (John Arbash Meinel, #110399)
+
bzr 0.16rc1 2007-04-26
NOTES WHEN UPGRADING:
=== modified file 'bzrlib/tests/test_workingtree_4.py'
--- a/bzrlib/tests/test_workingtree_4.py 2007-04-20 04:19:55 +0000
+++ b/bzrlib/tests/test_workingtree_4.py 2007-04-26 22:56:01 +0000
@@ -24,6 +24,7 @@
dirstate,
errors,
inventory,
+ osutils,
workingtree_4,
)
from bzrlib.lockdir import LockDir
@@ -523,3 +524,53 @@
# having checked this is on, the tree interface, and intertree
# interface tests, will proceed to test the subtree support of
# workingtree_4.
+
+ def test_iter_changes_ignores_unversioned_dirs(self):
+ """_iter_changes should not descend into unversioned directories."""
+ tree = self.make_branch_and_tree('.', format='dirstate')
+ # We have an unversioned directory at the root, a versioned one with
+ # other versioned files and an unversioned directory, and another
+ # versioned dir with nothing but an unversioned directory.
+ self.build_tree(['unversioned/',
+ 'unversioned/a',
+ 'unversioned/b/',
+ 'versioned/',
+ 'versioned/unversioned/',
+ 'versioned/unversioned/a',
+ 'versioned/unversioned/b/',
+ 'versioned2/',
+ 'versioned2/a',
+ 'versioned2/unversioned/',
+ 'versioned2/unversioned/a',
+ 'versioned2/unversioned/b/',
+ ])
+ tree.add(['versioned', 'versioned2', 'versioned2/a'])
+ tree.commit('one', rev_id='rev-1')
+ # Trap osutils._walkdirs_utf8 to spy on what dirs have been accessed.
+ returned = []
+ orig_walkdirs = osutils._walkdirs_utf8
+ def reset():
+ osutils._walkdirs_utf8 = orig_walkdirs
+ self.addCleanup(reset)
+ def walkdirs_spy(*args, **kwargs):
+ for val in orig_walkdirs(*args, **kwargs):
+ returned.append(val[0][0])
+ yield val
+ osutils._walkdirs_utf8 = walkdirs_spy
+
+ basis = tree.basis_tree()
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ basis.lock_read()
+ self.addCleanup(basis.unlock)
+ changes = [c[1] for c in
+ tree._iter_changes(basis, want_unversioned=True)]
+ self.assertEqual([(None, 'unversioned'),
+ (None, 'versioned/unversioned'),
+ (None, 'versioned2/unversioned'),
+ ], changes)
+ self.assertEqual(['', 'versioned', 'versioned2'], returned)
+ del returned[:] # reset
+ changes = [c[1] for c in tree._iter_changes(basis)]
+ self.assertEqual([], changes)
+ self.assertEqual(['', 'versioned', 'versioned2'], returned)
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-04-26 21:11:50 +0000
+++ b/bzrlib/workingtree_4.py 2007-04-30 05:13:58 +0000
@@ -2132,10 +2132,10 @@
# new unknown files or directories.
# if (B) then we should ignore it, because we don't
# recurse into unknown directories.
- if want_unversioned:
- path_index = 0
- while path_index < len(current_dir_info[1]):
- current_path_info = current_dir_info[1][path_index]
+ path_index = 0
+ while path_index < len(current_dir_info[1]):
+ current_path_info = current_dir_info[1][path_index]
+ if want_unversioned:
if current_path_info[2] == 'directory':
if self.target._directory_is_tree_reference(
current_path_info[0].decode('utf8')):
@@ -2152,13 +2152,13 @@
(None, utf8_decode_or_none(current_path_info[1])),
(None, current_path_info[2]),
(None, new_executable))
- # dont descend into this unversioned path if it is
- # a dir
- if current_path_info[2] in ('directory',
- 'tree-reference'):
- del current_dir_info[1][path_index]
- path_index -= 1
- path_index += 1
+ # dont descend into this unversioned path if it is
+ # a dir
+ if current_path_info[2] in ('directory',
+ 'tree-reference'):
+ del current_dir_info[1][path_index]
+ path_index -= 1
+ path_index += 1
# This dir info has been handled, go to the next
try:
More information about the bazaar-commits
mailing list