Rev 4854: (spiv) Merge lp:bzr/2.0, including fix for #192859. in file:///home/pqm/archives/thelove/bzr/2.1/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Aug 16 03:58:50 BST 2010


At file:///home/pqm/archives/thelove/bzr/2.1/

------------------------------------------------------------
revno: 4854 [merge]
revision-id: pqm at pqm.ubuntu.com-20100816025848-n3n5g3spo3nxynvp
parent: pqm at pqm.ubuntu.com-20100720204123-s3d2617lmhkrkub9
parent: andrew.bennetts at canonical.com-20100816015012-yg6rdqs2ueme0mdy
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.1
timestamp: Mon 2010-08-16 03:58:48 +0100
message:
  (spiv) Merge lp:bzr/2.0, including fix for #192859.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/per_workingtree/test_symlinks.py test_symlinks.py-20100715135626-4lw38d8njbzyec6l-1
=== modified file 'NEWS'
--- a/NEWS	2010-07-19 10:37:26 +0000
+++ b/NEWS	2010-08-16 01:50:12 +0000
@@ -20,6 +20,11 @@
 Bug Fixes
 *********
 
+* ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
+  previously-unversioned directory within the tree: the directory is
+  marked versioned too.  
+  (Martin Pool, #192859)
+
 * Configuration files in ``${BZR_HOME}`` are now written in an atomic
   way which should help avoid problems with concurrent writers.
   (Vincent Ladeuil, #525571)
@@ -27,6 +32,10 @@
 * Don't traceback trying to unversion children files of an already
   unversioned directory.  (Vincent Ladeuil, #494221)
 
+* Fix ``AttributeError on parent.children`` when adding a file under a 
+  directory that was a symlink in the previous commit.
+  (Martin Pool, #192859)
+
 * Prevent ``CHKMap.apply_delta`` from generating non-canonical CHK maps,
   which can result in "missing referenced chk root keys" errors when
   fetching from repositories with affected revisions.
@@ -506,6 +515,11 @@
   history no longer crash when deleted files are involved.
   (Vincent Ladeuil, John Arbash Meinel, #375898)
 
+* ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
+  previously-unversioned directory within the tree: the directory is
+  marked versioned too.  
+  (Martin Pool, #192859)
+
 * ``bzr commit SYMLINK`` now works, rather than trying to commit the
   target of the symlink.
   (Martin Pool, John Arbash Meinel, #128562)
@@ -521,6 +535,10 @@
 * Don't traceback trying to unversion children files of an already
   unversioned directory.  (Vincent Ladeuil, #494221)
 
+* Fix ``AttributeError on parent.children`` when adding a file under a 
+  directory that was a symlink in the previous commit.
+  (Martin Pool, #192859)
+
 * Prevent ``CHKMap.apply_delta`` from generating non-canonical CHK maps,
   which can result in "missing referenced chk root keys" errors when
   fetching from repositories with affected revisions.

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2010-02-17 17:11:16 +0000
+++ b/bzrlib/inventory.py	2010-08-16 01:50:12 +0000
@@ -1282,9 +1282,6 @@
     def add(self, entry):
         """Add entry to inventory.
 
-        To add  a file to a branch ready to be committed, use Branch.add,
-        which calls this.
-
         :return: entry
         """
         if entry.file_id in self._byid:

=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2010-07-19 10:37:26 +0000
+++ b/bzrlib/mutabletree.py	2010-08-16 01:50:12 +0000
@@ -32,6 +32,7 @@
     hooks,
     osutils,
     revisiontree,
+    inventory,
     symbol_versioning,
     trace,
     tree,
@@ -392,6 +393,10 @@
         dirs_to_add = []
         user_dirs = set()
 
+        # expand any symlinks in the directory part, while leaving the
+        # filename alone
+        file_list = map(osutils.normalizepath, file_list)
+
         # validate user file paths and convert all paths to tree
         # relative : it's cheaper to make a tree relative path an abspath
         # than to convert an abspath to tree relative, and it's cheaper to
@@ -689,6 +694,17 @@
         file_id or None to generate a new file id
     :returns: None
     """
+    # if the parent exists, but isn't a directory, we have to do the
+    # kind change now -- really the inventory shouldn't pretend to know
+    # the kind of wt files, but it does.
+    if parent_ie.kind != 'directory':
+        # nb: this relies on someone else checking that the path we're using
+        # doesn't contain symlinks.
+        new_parent_ie = inventory.make_entry('directory', parent_ie.name,
+            parent_ie.parent_id, parent_ie.file_id)
+        del inv[parent_ie.file_id]
+        inv.add(new_parent_ie)
+        parent_ie = new_parent_ie
     file_id = file_id_callback(inv, parent_ie, path, kind)
     entry = inv.make_entry(kind, path.base_path, parent_ie.file_id,
         file_id=file_id)

=== modified file 'bzrlib/tests/per_workingtree/test_symlinks.py'
--- a/bzrlib/tests/per_workingtree/test_symlinks.py	2010-07-16 10:48:51 +0000
+++ b/bzrlib/tests/per_workingtree/test_symlinks.py	2010-07-20 17:34:06 +0000
@@ -15,12 +15,13 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 """Test symlink support.
-
-See eg <https://bugs.launchpad.net/bzr/+bug/192859>
 """
 
+import os
+
 from bzrlib import (
     builtins,
+    osutils,
     tests,
     workingtree,
     )
@@ -29,6 +30,8 @@
 
 class TestSmartAddTree(TestCaseWithWorkingTree):
 
+    # See eg <https://bugs.launchpad.net/bzr/+bug/192859>
+
     _test_needs_features = [tests.SymlinkFeature]
 
     def test_smart_add_symlink(self):
@@ -53,6 +56,78 @@
         self.assertEqual('symlink',
             tree.kind(tree.path2id('link')))
 
+    def test_add_file_under_symlink(self):
+        # similar to 
+        # https://bugs.launchpad.net/bzr/+bug/192859/comments/3
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('tree/link@', 'dir'),
+            ('tree/dir/',),
+            ('tree/dir/file', 'content'),
+            ])
+        self.assertEquals(
+            tree.smart_add(['tree/link/file']),
+            ([u'dir', u'dir/file'], {}))
+        # should add the actual parent directory, not the apparent parent
+        # (which is actually a symlink)
+        self.assertTrue(tree.path2id('dir/file'))
+        self.assertTrue(tree.path2id('dir'))
+        self.assertIs(None, tree.path2id('link'))
+        self.assertIs(None, tree.path2id('link/file'))
+
+
+class TestKindChanges(TestCaseWithWorkingTree):
+
+    _test_needs_features = [tests.SymlinkFeature]
+
+    def test_symlink_changes_to_dir(self):
+        # <https://bugs.launchpad.net/bzr/+bug/192859>:
+        # we had some past problems with the workingtree remembering for too
+        # long what kind of object was at a particular name; we really
+        # shouldn't do that.  Operating on the dirstate through passing
+        # inventory deltas rather than mutating the inventory largely avoids
+        # that.
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('tree/a@', 'target')])
+        tree.smart_add(['tree/a'])
+        tree.commit('add symlink')
+        os.unlink('tree/a')
+        self.build_tree_contents([
+            ('tree/a/',),
+            ('tree/a/f', 'content'),
+            ])
+        tree.smart_add(['tree/a/f'])
+        tree.commit('change to dir')
+        tree.lock_read()
+        self.addCleanup(tree.unlock)
+        self.assertEquals([], list(tree.iter_changes(tree.basis_tree())))
+
+    def test_dir_changes_to_symlink(self):
+        # <https://bugs.launchpad.net/bzr/+bug/192859>:
+        # we had some past problems with the workingtree remembering for too
+        # long what kind of object was at a particular name; we really
+        # shouldn't do that.  Operating on the dirstate through passing
+        # inventory deltas rather than mutating the inventory largely avoids
+        # that.
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('tree/a/',),
+            ('tree/a/file', 'content'),
+            ])
+        tree.smart_add(['tree/a'])
+        tree.commit('add dir')
+        osutils.rmtree('tree/a')
+        self.build_tree_contents([
+            ('tree/a@', 'target'),
+            ])
+        tree.commit('change to symlink')
+
+
+class TestOpenTree(TestCaseWithWorkingTree):
+
+    _test_needs_features = [tests.SymlinkFeature]
+
     def test_open_containing_through_symlink(self):
         self.make_test_tree()
         self.check_open_containing('link/content', 'tree', 'content')




More information about the bazaar-commits mailing list