Rev 4755: (jameinel) ``bzr add SYMLINK/FILE`` now works properly when the symlink in file:///home/pqm/archives/thelove/bzr/2.0/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jul 19 12:51:27 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.0/
------------------------------------------------------------
revno: 4755 [merge]
revision-id: pqm at pqm.ubuntu.com-20100719115126-nbjdil02f2jrw4gp
parent: pqm at pqm.ubuntu.com-20100716153940-5vs5ue0wfbj25axa
parent: mbp at canonical.com-20100717171619-5pmtgtb6mn4ivtdy
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.0
timestamp: Mon 2010-07-19 12:51:26 +0100
message:
(jameinel) ``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)
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-16 13:06:04 +0000
+++ b/NEWS 2010-07-17 17:16:19 +0000
@@ -18,6 +18,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)
@@ -33,6 +38,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 2009-09-30 05:58:45 +0000
+++ b/bzrlib/inventory.py 2010-07-17 16:13:39 +0000
@@ -1281,9 +1281,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-15 14:04:57 +0000
+++ b/bzrlib/mutabletree.py 2010-07-17 17:16:19 +0000
@@ -29,6 +29,7 @@
add,
bzrdir,
hooks,
+ inventory,
symbol_versioning,
)
from bzrlib.osutils import dirname
@@ -388,6 +389,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
@@ -682,6 +687,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-17 17:16:19 +0000
@@ -15,10 +15,10 @@
# 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,
tests,
@@ -29,6 +29,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 +55,66 @@
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_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.
+ if self.workingtree_format.upgrade_recommended:
+ # File "bzrlib/workingtree.py", line 2341, in conflicts
+ # for conflicted in self._iter_conflicts():
+ # File "bzrlib/workingtree.py", line 1590, in _iter_conflicts
+ # for info in self.list_files():
+ # File "bzrlib/workingtree.py", line 1203, in list_files
+ # f_ie = inv.get_child(from_dir_id, f)
+ # File "bzrlib/inventory.py", line 1269, in get_child
+ # return self[parent_id].children.get(filename)
+ # AttributeError: children
+ raise tests.TestSkipped("known broken on pre-dirstate formats; wontfix")
+ 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')
+
+
+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