Rev 4853: (mbp) merge 2.0 to 2.1 (Martin Pool) in file:///home/pqm/archives/thelove/bzr/2.1/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Jul 20 21:41:23 BST 2010


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

------------------------------------------------------------
revno: 4853 [merge]
revision-id: pqm at pqm.ubuntu.com-20100720204123-s3d2617lmhkrkub9
parent: pqm at pqm.ubuntu.com-20100714115733-e9rueysqk5064akm
parent: mbp at canonical.com-20100719103726-8bjz2008pur4lrln
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.1
timestamp: Tue 2010-07-20 21:41:23 +0100
message:
  (mbp) merge 2.0 to 2.1 (Martin Pool)
added:
  bzrlib/tests/per_workingtree/test_symlinks.py test_symlinks.py-20100715135626-4lw38d8njbzyec6l-1
  bzrlib/tests/test_treeshape.py test_treeshape.py-20100715135036-z8vz2u7f3w7wg2it-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/per_workingtree/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
  bzrlib/tests/test_upgrade.py   test_upgrade.py-20051004040251-555fe1d2bae1bc71
  bzrlib/tests/treeshape.py      treeshape.py-20051004094628-312a98f0194306a8
=== modified file 'NEWS'
--- a/NEWS	2010-07-14 10:11:45 +0000
+++ b/NEWS	2010-07-19 10:37:26 +0000
@@ -506,6 +506,10 @@
   history no longer crash when deleted files are involved.
   (Vincent Ladeuil, John Arbash Meinel, #375898)
 
+* ``bzr commit SYMLINK`` now works, rather than trying to commit the
+  target of the symlink.
+  (Martin Pool, John Arbash Meinel, #128562)
+
 * ``bzr revert`` now only takes write lock on working tree, instead of on 
   both working tree and branch.
   (Danny van Heumen, #498409)
@@ -545,6 +549,13 @@
   (John Arbash Meinel, #583486)
 
 
+Testing
+*******
+
+* ``build_tree_contents`` can create symlinks.
+  (Martin Pool, John Arbash Meinel)
+
+
 bzr 2.0.5
 #########
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-04-15 08:50:40 +0000
+++ b/bzrlib/builtins.py	2010-07-19 10:37:26 +0000
@@ -175,7 +175,7 @@
                 view_str = views.view_display_str(view_files)
                 note("Ignoring files outside view. View is %s" % view_str)
         return tree, file_list
-    tree = WorkingTree.open_containing(osutils.realpath(file_list[0]))[0]
+    tree = WorkingTree.open_containing(file_list[0])[0]
     return tree, safe_relpath_files(tree, file_list, canonicalize,
         apply_view=apply_view)
 

=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2009-10-06 14:40:37 +0000
+++ b/bzrlib/mutabletree.py	2010-07-19 10:37:26 +0000
@@ -362,6 +362,10 @@
         This is designed more towards DWIM for humans than API clarity.
         For the specific behaviour see the help for cmd_add().
 
+        :param file_list: List of zero or more paths.  *NB: these are 
+            interpreted relative to the process cwd, not relative to the 
+            tree.*  (Add and most other tree methods use tree-relative
+            paths.)
         :param action: A reporter to be called with the inventory, parent_ie,
             path and kind of the path being added. It may return a file_id if
             a specific one should be used.

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-05-19 23:09:33 +0000
+++ b/bzrlib/tests/__init__.py	2010-07-19 10:37:26 +0000
@@ -3728,6 +3728,7 @@
         'bzrlib.tests.test_transport_log',
         'bzrlib.tests.test_tree',
         'bzrlib.tests.test_treebuilder',
+        'bzrlib.tests.test_treeshape',
         'bzrlib.tests.test_tsort',
         'bzrlib.tests.test_tuned_gzip',
         'bzrlib.tests.test_ui',

=== modified file 'bzrlib/tests/per_workingtree/__init__.py'
--- a/bzrlib/tests/per_workingtree/__init__.py	2009-08-04 04:36:34 +0000
+++ b/bzrlib/tests/per_workingtree/__init__.py	2010-07-15 14:05:18 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007 Canonical Ltd
+# Copyright (C) 2006, 2007, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -101,6 +101,7 @@
         'revision_tree',
         'set_root_id',
         'smart_add',
+        'symlinks',
         'uncommit',
         'unversion',
         'views',

=== added file 'bzrlib/tests/per_workingtree/test_symlinks.py'
--- a/bzrlib/tests/per_workingtree/test_symlinks.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_workingtree/test_symlinks.py	2010-07-16 10:48:51 +0000
@@ -0,0 +1,98 @@
+# Copyright (C) 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Test symlink support.
+
+See eg <https://bugs.launchpad.net/bzr/+bug/192859>
+"""
+
+from bzrlib import (
+    builtins,
+    tests,
+    workingtree,
+    )
+from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
+
+
+class TestSmartAddTree(TestCaseWithWorkingTree):
+
+    _test_needs_features = [tests.SymlinkFeature]
+
+    def test_smart_add_symlink(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('tree/link@', 'target'),
+            ])
+        tree.smart_add(['tree/link'])
+        self.assertIsNot(None, tree.path2id('link'))
+        self.assertIs(None, tree.path2id('target'))
+        self.assertEqual('symlink',
+            tree.kind(tree.path2id('link')))
+
+    def test_smart_add_symlink_pointing_outside(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('tree/link@', '../../../../target'),
+            ])
+        tree.smart_add(['tree/link'])
+        self.assertIsNot(None, tree.path2id('link'))
+        self.assertIs(None, tree.path2id('target'))
+        self.assertEqual('symlink',
+            tree.kind(tree.path2id('link')))
+
+    def test_open_containing_through_symlink(self):
+        self.make_test_tree()
+        self.check_open_containing('link/content', 'tree', 'content')
+        self.check_open_containing('link/sublink', 'tree', 'sublink')
+        # this next one is a bit debatable, but arguably it's better that
+        # open_containing is only concerned with opening the tree 
+        # and then you can deal with symlinks along the way if you want
+        self.check_open_containing('link/sublink/subcontent', 'tree',
+            'sublink/subcontent')
+
+    def check_open_containing(self, to_open, expected_tree_name,
+        expected_relpath):
+        wt, relpath = workingtree.WorkingTree.open_containing(to_open)
+        self.assertEquals(relpath, expected_relpath)
+        self.assertEndsWith(wt.basedir, expected_tree_name)
+
+    def test_tree_files(self):
+        # not strictly a WorkingTree method, but it should be
+        # probably the root cause for
+        # <https://bugs.launchpad.net/bzr/+bug/128562>
+        self.make_test_tree()
+        self.check_tree_files(['tree/outerlink'],
+            'tree', ['outerlink'])
+        self.check_tree_files(['link/outerlink'],
+            'tree', ['outerlink'])
+        self.check_tree_files(['link/sublink/subcontent'],
+            'tree', ['subdir/subcontent'])
+
+    def check_tree_files(self, to_open, expected_tree, expect_paths):
+        tree, relpaths = builtins.tree_files(to_open)
+        self.assertEndsWith(tree.basedir, expected_tree)
+        self.assertEquals(expect_paths, relpaths)
+
+    def make_test_tree(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([
+            ('link@', 'tree'),
+            ('tree/outerlink@', '/not/there'),
+            ('tree/content', 'hello'),
+            ('tree/sublink@', 'subdir'),
+            ('tree/subdir/',),
+            ('tree/subdir/subcontent', 'subcontent stuff')
+            ])

=== added file 'bzrlib/tests/test_treeshape.py'
--- a/bzrlib/tests/test_treeshape.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_treeshape.py	2010-07-15 13:55:46 +0000
@@ -0,0 +1,41 @@
+# Copyright (C) 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+import os
+
+
+from bzrlib import tests
+
+
+class TestTreeShape(tests.TestCaseWithTransport):
+
+    def test_build_tree(self):
+        """Test tree-building test helper"""
+        self.build_tree_contents([
+            ('foo', 'new contents'),
+            ('.bzr/',),
+            ('.bzr/README', 'hello'),
+            ])
+        self.failUnlessExists('foo')
+        self.failUnlessExists('.bzr/README')
+        self.assertFileEqual('hello', '.bzr/README')
+
+    def test_build_tree_symlink(self):
+        self.requireFeature(tests.SymlinkFeature)
+        self.build_tree_contents([('link@', 'target')])
+        self.assertEqual('target',
+            os.readlink('link'))

=== modified file 'bzrlib/tests/test_upgrade.py'
--- a/bzrlib/tests/test_upgrade.py	2009-05-07 05:08:46 +0000
+++ b/bzrlib/tests/test_upgrade.py	2010-07-15 13:52:19 +0000
@@ -43,12 +43,6 @@
 
 class TestUpgrade(TestCaseWithTransport):
 
-    def test_build_tree(self):
-        """Test tree-building test helper"""
-        self.build_tree_contents(_upgrade1_template)
-        self.failUnlessExists('foo')
-        self.failUnlessExists('.bzr/README')
-
     def test_upgrade_simple(self):
         """Upgrade simple v0.0.4 format to latest format"""
         eq = self.assertEquals

=== modified file 'bzrlib/tests/treeshape.py'
--- a/bzrlib/tests/treeshape.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/treeshape.py	2010-07-15 13:55:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@
         if name[-1] == '/':
             os.mkdir(name)
         elif name[-1] == '@':
-            raise NotImplementedError('symlinks not handled yet')
+            os.symlink(tt[1], tt[0][:-1])
         else:
             f = file(name, 'wb')
             try:




More information about the bazaar-commits mailing list