Merge lp:~gz/bzr/smart_add_former_file_dir_251864 into lp:bzr

Proposed by Martin Packman
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5520
Proposed branch: lp:~gz/bzr/smart_add_former_file_dir_251864
Merge into: lp:bzr
Prerequisite: lp:~gz/bzr/tests_for_bug_205636
Diff against target: 78 lines (+19/-16) (has conflicts)
3 files modified
bzrlib/mutabletree.py (+7/-0)
bzrlib/tests/per_workingtree/test_smart_add.py (+5/-16)
doc/en/release-notes/bzr-2.3.txt (+7/-0)
Text conflict in doc/en/release-notes/bzr-2.3.txt
To merge this branch: bzr merge lp:~gz/bzr/smart_add_former_file_dir_251864
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+38676@code.launchpad.net

Description of the change

Builds on the bug 205636 tests, and fixes the smart_add path that wasn't already handled by the bug 192859 change. Duplicates the logic Martin Pool added to mutabletree._add_one inside smart_add to detect a directory that used to be something else and correct the inventory.

Rewriting Inventory so we don't have to care about this I leave to someone else. :)

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Nice, thanks. Sorry for the delay.

Could you still mention the old bug 205636 in the test, and also add news?

review: Approve
Revision history for this message
Martin Packman (gz) wrote :

Done.

Note to landers, the prerequisite branch that added this test and a couple of others still need to be checked and approved. See the last comment especially.

<https://code.launchpad.net/~gz/bzr/tests_for_bug_205636/+merge/38673>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/mutabletree.py'
2--- bzrlib/mutabletree.py 2010-08-17 06:45:33 +0000
3+++ bzrlib/mutabletree.py 2010-10-26 22:24:52 +0000
4@@ -545,6 +545,13 @@
5 this_ie = None
6 else:
7 this_ie = inv[this_id]
8+ # Same as in _add_one below, if the inventory doesn't
9+ # think this is a directory, update the inventory
10+ if this_ie.kind != 'directory':
11+ this_ie = inventory.make_entry('directory',
12+ this_ie.name, this_ie.parent_id, this_id)
13+ del inv[this_id]
14+ inv.add(this_ie)
15
16 for subf in sorted(os.listdir(abspath)):
17 # here we could use TreeDirectory rather than
18
19=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
20--- bzrlib/tests/per_workingtree/test_smart_add.py 2010-10-26 22:24:52 +0000
21+++ bzrlib/tests/per_workingtree/test_smart_add.py 2010-10-26 22:24:52 +0000
22@@ -203,28 +203,17 @@
23 self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],
24 [path for path, ie in tree.iter_entries_by_dir()])
25
26- @staticmethod
27- def _reraise_current_error_as_assertion():
28- _, e, tb = sys.exc_info()
29- try:
30- raise AssertionError, AssertionError(str(e)), tb
31- finally:
32- del tb
33+ def test_add_dir_bug_251864(self):
34+ """Added file turning into a dir should be detected on add dir
35
36- def test_add_dir_bug_205636(self):
37- """Added file turning into a dir should be detected on add dir"""
38+ Similar to bug 205636 but with automatic adding of directory contents.
39+ """
40 tree = self.make_branch_and_tree(".")
41 self.build_tree(["dir"]) # whoops, make a file called dir
42 tree.smart_add(["dir"])
43 os.remove("dir")
44 self.build_tree(["dir/", "dir/file"])
45- # GZ 2010-10-17: Need an expectError method like expectFailure but for
46- # execptions that are not assertions
47- try:
48- tree.smart_add(["dir"])
49- except AttributeError, e:
50- self.expectFailure("Adding dir raises AttributeError",
51- self._reraise_current_error_as_assertion)
52+ tree.smart_add(["dir"])
53 tree.commit("Add dir contents")
54
55 def test_add_subdir_file_bug_205636(self):
56
57=== modified file 'doc/en/release-notes/bzr-2.3.txt'
58--- doc/en/release-notes/bzr-2.3.txt 2010-10-26 13:53:31 +0000
59+++ doc/en/release-notes/bzr-2.3.txt 2010-10-26 22:24:52 +0000
60@@ -46,12 +46,19 @@
61
62 * Always set PATH in start_bzr.bat on Windows. (Matthäus G. Chajdas, #470264)
63
64+<<<<<<< TREE
65 * ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
66 ``get_shelf_manager``. (John Arbash Meinel, #662053)
67
68 * Correctly set the Content-Type header when http POSTing to comply
69 with stricter web frameworks. (Vincent Ladeuil, #655100)
70
71+=======
72+* Correctly add directory contents when the name was previously added as a
73+ normal file, rather than throwing ``AttributeError: children`` during
74+ smart_add. (Martin [gz], #251864)
75+
76+>>>>>>> MERGE-SOURCE
77 * Don't force openssh to use protocol=2, since that is now the default.
78 (Neil Martinsen-Burrell, #561061)
79