Rev 5520: (gz) Add tests for bug 205636 and fix closely related bug 251864 (Martin in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Nov 2 23:17:06 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5520 [merge]
revision-id: pqm at pqm.ubuntu.com-20101102231704-tp1zv8m5659w19gn
parent: pqm at pqm.ubuntu.com-20101029172603-nzb390is9yby1mjb
parent: gzlist at googlemail.com-20101102222340-ih1flo8f6xwdopaq
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-11-02 23:17:04 +0000
message:
  (gz) Add tests for bug 205636 and fix closely related bug 251864 (Martin
   [gz])
modified:
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/per_workingtree/test_smart_add.py test_smart_add.py-20070215175752-9s5mxoz8aqpd80fm-1
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2010-08-17 06:45:33 +0000
+++ b/bzrlib/mutabletree.py	2010-10-17 23:20:40 +0000
@@ -545,6 +545,13 @@
                         this_ie = None
                     else:
                         this_ie = inv[this_id]
+                        # Same as in _add_one below, if the inventory doesn't
+                        # think this is a directory, update the inventory
+                        if this_ie.kind != 'directory':
+                            this_ie = inventory.make_entry('directory',
+                                this_ie.name, this_ie.parent_id, this_id)
+                            del inv[this_id]
+                            inv.add(this_ie)
 
                 for subf in sorted(os.listdir(abspath)):
                     # here we could use TreeDirectory rather than

=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
--- a/bzrlib/tests/per_workingtree/test_smart_add.py	2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/per_workingtree/test_smart_add.py	2010-11-02 22:23:40 +0000
@@ -17,6 +17,7 @@
 """Test that we can use smart_add on all Tree implementations."""
 
 from cStringIO import StringIO
+import os
 import sys
 
 from bzrlib import (
@@ -202,6 +203,37 @@
         self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'],
             [path for path, ie in tree.iter_entries_by_dir()])
 
+    def test_add_dir_bug_251864(self):
+        """Added file turning into a dir should be detected on add dir
+
+        Similar to bug 205636 but with automatic adding of directory contents.
+        """
+        tree = self.make_branch_and_tree(".")
+        self.build_tree(["dir"]) # whoops, make a file called dir
+        tree.smart_add(["dir"])
+        os.remove("dir")
+        self.build_tree(["dir/", "dir/file"])
+        tree.smart_add(["dir"])
+        tree.commit("Add dir contents")
+        self.addCleanup(tree.lock_read().unlock)
+        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
+            [(t[0], t[2]) for t in tree.list_files()])
+        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
+
+    def test_add_subdir_file_bug_205636(self):
+        """Added file turning into a dir should be detected on add dir/file"""
+        tree = self.make_branch_and_tree(".")
+        self.build_tree(["dir"]) # whoops, make a file called dir
+        tree.smart_add(["dir"])
+        os.remove("dir")
+        self.build_tree(["dir/", "dir/file"])
+        tree.smart_add(["dir/file"])
+        tree.commit("Add file in dir")
+        self.addCleanup(tree.lock_read().unlock)
+        self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")],
+            [(t[0], t[2]) for t in tree.list_files()])
+        self.assertFalse(list(tree.iter_changes(tree.basis_tree())))
+
     def test_custom_ids(self):
         sio = StringIO()
         action = test_smart_add.AddCustomIDAction(to_file=sio,

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-10-29 17:26:03 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-11-02 22:23:40 +0000
@@ -49,6 +49,10 @@
 * ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
   ``get_shelf_manager``. (John Arbash Meinel, #662053)
 
+* Correctly add directory contents when the name was previously added as a
+  normal file, rather than throwing ``AttributeError: children`` during
+  smart_add. (Martin [gz], #251864)
+
 * Correctly set the Content-Type  header when http POSTing to comply
   with stricter web frameworks. (Vincent Ladeuil, #655100)
 




More information about the bazaar-commits mailing list