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
=== modified file 'bzrlib/mutabletree.py'
--- bzrlib/mutabletree.py 2010-08-17 06:45:33 +0000
+++ bzrlib/mutabletree.py 2010-10-26 22:24:52 +0000
@@ -545,6 +545,13 @@
545 this_ie = None545 this_ie = None
546 else:546 else:
547 this_ie = inv[this_id]547 this_ie = inv[this_id]
548 # Same as in _add_one below, if the inventory doesn't
549 # think this is a directory, update the inventory
550 if this_ie.kind != 'directory':
551 this_ie = inventory.make_entry('directory',
552 this_ie.name, this_ie.parent_id, this_id)
553 del inv[this_id]
554 inv.add(this_ie)
548555
549 for subf in sorted(os.listdir(abspath)):556 for subf in sorted(os.listdir(abspath)):
550 # here we could use TreeDirectory rather than557 # here we could use TreeDirectory rather than
551558
=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
--- bzrlib/tests/per_workingtree/test_smart_add.py 2010-10-26 22:24:52 +0000
+++ bzrlib/tests/per_workingtree/test_smart_add.py 2010-10-26 22:24:52 +0000
@@ -203,28 +203,17 @@
203 self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],203 self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],
204 [path for path, ie in tree.iter_entries_by_dir()])204 [path for path, ie in tree.iter_entries_by_dir()])
205205
206 @staticmethod206 def test_add_dir_bug_251864(self):
207 def _reraise_current_error_as_assertion():207 """Added file turning into a dir should be detected on add dir
208 _, e, tb = sys.exc_info()
209 try:
210 raise AssertionError, AssertionError(str(e)), tb
211 finally:
212 del tb
213208
214 def test_add_dir_bug_205636(self):209 Similar to bug 205636 but with automatic adding of directory contents.
215 """Added file turning into a dir should be detected on add dir"""210 """
216 tree = self.make_branch_and_tree(".")211 tree = self.make_branch_and_tree(".")
217 self.build_tree(["dir"]) # whoops, make a file called dir212 self.build_tree(["dir"]) # whoops, make a file called dir
218 tree.smart_add(["dir"])213 tree.smart_add(["dir"])
219 os.remove("dir")214 os.remove("dir")
220 self.build_tree(["dir/", "dir/file"])215 self.build_tree(["dir/", "dir/file"])
221 # GZ 2010-10-17: Need an expectError method like expectFailure but for216 tree.smart_add(["dir"])
222 # execptions that are not assertions
223 try:
224 tree.smart_add(["dir"])
225 except AttributeError, e:
226 self.expectFailure("Adding dir raises AttributeError",
227 self._reraise_current_error_as_assertion)
228 tree.commit("Add dir contents")217 tree.commit("Add dir contents")
229218
230 def test_add_subdir_file_bug_205636(self):219 def test_add_subdir_file_bug_205636(self):
231220
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- doc/en/release-notes/bzr-2.3.txt 2010-10-26 13:53:31 +0000
+++ doc/en/release-notes/bzr-2.3.txt 2010-10-26 22:24:52 +0000
@@ -46,12 +46,19 @@
4646
47* Always set PATH in start_bzr.bat on Windows. (Matthäus G. Chajdas, #470264)47* Always set PATH in start_bzr.bat on Windows. (Matthäus G. Chajdas, #470264)
4848
49<<<<<<< TREE
49* ``bzr status -r X..Y`` was failing because RevisionTree didn't implement50* ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
50 ``get_shelf_manager``. (John Arbash Meinel, #662053)51 ``get_shelf_manager``. (John Arbash Meinel, #662053)
5152
52* Correctly set the Content-Type header when http POSTing to comply53* Correctly set the Content-Type header when http POSTing to comply
53 with stricter web frameworks. (Vincent Ladeuil, #655100)54 with stricter web frameworks. (Vincent Ladeuil, #655100)
5455
56=======
57* Correctly add directory contents when the name was previously added as a
58 normal file, rather than throwing ``AttributeError: children`` during
59 smart_add. (Martin [gz], #251864)
60
61>>>>>>> MERGE-SOURCE
55* Don't force openssh to use protocol=2, since that is now the default.62* Don't force openssh to use protocol=2, since that is now the default.
56 (Neil Martinsen-Burrell, #561061)63 (Neil Martinsen-Burrell, #561061)
5764