Merge lp:~mbp/bzr/192859-2.0-symlinks into lp:bzr/2.0

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 4756
Proposed branch: lp:~mbp/bzr/192859-2.0-symlinks
Merge into: lp:bzr/2.0
Diff against target: 67 lines (+25/-12)
1 file modified
bzrlib/tests/per_workingtree/test_symlinks.py (+25/-12)
To merge this branch: bzr merge lp:~mbp/bzr/192859-2.0-symlinks
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+30180@code.launchpad.net

Commit message

cope with links changing into directories

Description of the change

This fixes another symlink problem case: adding a file under a directory that was a symlink in the basis revision.

The really right fix for this is to get away from wt inventory entries having a defined in-memory kind: their kind is whatever is on disk. But doing that would probably be much too big for 2.0. I might try a 2.3 branch for it later.

There may be more problem cases.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

My only comment is that the tests for "tree.smart_add(['tree/a/file'])", etc, don't actually assert the state of the final tree. Just that tree.smart_add() doesn't fail.

Which I think does prove that bug 192859 is fixed, but it would be more useful as an ongoing test to not just assert that the functions don't fail with an exception, but that they did have the expected effect (the tree now sees a dir, etc.)

review: Needs Fixing
Revision history for this message
Martin Pool (mbp) wrote :
Revision history for this message
Martin Pool (mbp) wrote :

I've added an additional test assertion, so I might merge this on the basis of John's tweak-type review.

Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/per_workingtree/test_symlinks.py'
2--- bzrlib/tests/per_workingtree/test_symlinks.py 2010-07-17 17:16:19 +0000
3+++ bzrlib/tests/per_workingtree/test_symlinks.py 2010-07-20 15:37:47 +0000
4@@ -21,6 +21,7 @@
5
6 from bzrlib import (
7 builtins,
8+ osutils,
9 tests,
10 workingtree,
11 )
12@@ -79,24 +80,13 @@
13
14 _test_needs_features = [tests.SymlinkFeature]
15
16- def test_symlink_to_dir(self):
17+ def test_symlink_changes_to_dir(self):
18 # <https://bugs.launchpad.net/bzr/+bug/192859>:
19 # we had some past problems with the workingtree remembering for too
20 # long what kind of object was at a particular name; we really
21 # shouldn't do that. Operating on the dirstate through passing
22 # inventory deltas rather than mutating the inventory largely avoids
23 # that.
24- if self.workingtree_format.upgrade_recommended:
25- # File "bzrlib/workingtree.py", line 2341, in conflicts
26- # for conflicted in self._iter_conflicts():
27- # File "bzrlib/workingtree.py", line 1590, in _iter_conflicts
28- # for info in self.list_files():
29- # File "bzrlib/workingtree.py", line 1203, in list_files
30- # f_ie = inv.get_child(from_dir_id, f)
31- # File "bzrlib/inventory.py", line 1269, in get_child
32- # return self[parent_id].children.get(filename)
33- # AttributeError: children
34- raise tests.TestSkipped("known broken on pre-dirstate formats; wontfix")
35 tree = self.make_branch_and_tree('tree')
36 self.build_tree_contents([
37 ('tree/a@', 'target')])
38@@ -109,6 +99,29 @@
39 ])
40 tree.smart_add(['tree/a/f'])
41 tree.commit('change to dir')
42+ tree.lock_read()
43+ self.addCleanup(tree.unlock)
44+ self.assertEquals([], list(tree.iter_changes(tree.basis_tree())))
45+
46+ def test_dir_changes_to_symlink(self):
47+ # <https://bugs.launchpad.net/bzr/+bug/192859>:
48+ # we had some past problems with the workingtree remembering for too
49+ # long what kind of object was at a particular name; we really
50+ # shouldn't do that. Operating on the dirstate through passing
51+ # inventory deltas rather than mutating the inventory largely avoids
52+ # that.
53+ tree = self.make_branch_and_tree('tree')
54+ self.build_tree_contents([
55+ ('tree/a/',),
56+ ('tree/a/file', 'content'),
57+ ])
58+ tree.smart_add(['tree/a'])
59+ tree.commit('add dir')
60+ osutils.rmtree('tree/a')
61+ self.build_tree_contents([
62+ ('tree/a@', 'target'),
63+ ])
64+ tree.commit('change to symlink')
65
66
67 class TestOpenTree(TestCaseWithWorkingTree):

Subscribers

People subscribed via source and target branches