Merge lp:~mbp/bzr/192859-2.0-symlinks-add into lp:bzr/2.0

Proposed by Martin Pool
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 4755
Proposed branch: lp:~mbp/bzr/192859-2.0-symlinks-add
Merge into: lp:bzr/2.0
Prerequisite: lp:~mbp/bzr/192859-2.0-symlinks
Diff against target: 59 lines (+28/-0)
3 files modified
NEWS (+5/-0)
bzrlib/mutabletree.py (+4/-0)
bzrlib/tests/per_workingtree/test_symlinks.py (+19/-0)
To merge this branch: bzr merge lp:~mbp/bzr/192859-2.0-symlinks-add
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+30183@code.launchpad.net

Commit message

``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.

Description of the change

This fixes the symlink handling problem of <https://bugs.edge.launchpad.net/bzr/+bug/192859/comments/3> - the test is pretty self-explanatory.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-07-17 17:19:40 +0000
3+++ NEWS 2010-07-17 17:19:40 +0000
4@@ -18,6 +18,11 @@
5 history no longer crash when deleted files are involved.
6 (Vincent Ladeuil, John Arbash Meinel, #375898)
7
8+* ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
9+ previously-unversioned directory within the tree: the directory is
10+ marked versioned too.
11+ (Martin Pool, #192859)
12+
13 * ``bzr commit SYMLINK`` now works, rather than trying to commit the
14 target of the symlink.
15 (Martin Pool, John Arbash Meinel, #128562)
16
17=== modified file 'bzrlib/mutabletree.py'
18--- bzrlib/mutabletree.py 2010-07-17 17:19:40 +0000
19+++ bzrlib/mutabletree.py 2010-07-17 17:19:40 +0000
20@@ -389,6 +389,10 @@
21 dirs_to_add = []
22 user_dirs = set()
23
24+ # expand any symlinks in the directory part, while leaving the
25+ # filename alone
26+ file_list = map(osutils.normalizepath, file_list)
27+
28 # validate user file paths and convert all paths to tree
29 # relative : it's cheaper to make a tree relative path an abspath
30 # than to convert an abspath to tree relative, and it's cheaper to
31
32=== modified file 'bzrlib/tests/per_workingtree/test_symlinks.py'
33--- bzrlib/tests/per_workingtree/test_symlinks.py 2010-07-17 17:19:40 +0000
34+++ bzrlib/tests/per_workingtree/test_symlinks.py 2010-07-17 17:19:40 +0000
35@@ -55,6 +55,25 @@
36 self.assertEqual('symlink',
37 tree.kind(tree.path2id('link')))
38
39+ def test_add_file_under_symlink(self):
40+ # similar to
41+ # https://bugs.launchpad.net/bzr/+bug/192859/comments/3
42+ tree = self.make_branch_and_tree('tree')
43+ self.build_tree_contents([
44+ ('tree/link@', 'dir'),
45+ ('tree/dir/',),
46+ ('tree/dir/file', 'content'),
47+ ])
48+ self.assertEquals(
49+ tree.smart_add(['tree/link/file']),
50+ ([u'dir', u'dir/file'], {}))
51+ # should add the actual parent directory, not the apparent parent
52+ # (which is actually a symlink)
53+ self.assertTrue(tree.path2id('dir/file'))
54+ self.assertTrue(tree.path2id('dir'))
55+ self.assertIs(None, tree.path2id('link'))
56+ self.assertIs(None, tree.path2id('link/file'))
57+
58
59 class TestKindChanges(TestCaseWithWorkingTree):
60

Subscribers

People subscribed via source and target branches