Rev 2392: Move the WorkingTree.move() tests into their own module in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Sun Feb 25 17:21:27 GMT 2007


At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

------------------------------------------------------------
revno: 2392
revision-id: john at arbash-meinel.com-20070225172022-1lz2vdjp84vp3lu3
parent: john at arbash-meinel.com-20070225171143-dcj0kgtu8kf2o0is
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Sun 2007-02-25 11:20:22 -0600
message:
  Move the WorkingTree.move() tests into their own module
  and remove the requirement for maintaining api compatibility for the
  new WorkingTreeFormat4, its ugly and deprecated anyway.
added:
  bzrlib/tests/workingtree_implementations/test_move.py test_move.py-20070225171927-mohn2vqj5fx7edc6-1
modified:
  bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
  bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== added file 'bzrlib/tests/workingtree_implementations/test_move.py'
--- a/bzrlib/tests/workingtree_implementations/test_move.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_move.py	2007-02-25 17:20:22 +0000
@@ -0,0 +1,81 @@
+# Copyright (C) 2006 Canonical Ltd
+# Authors:  Robert Collins <robert.collins at canonical.com>
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for interface conformance of 'workingtree.put_mkdir'"""
+
+from bzrlib.workingtree_4 import WorkingTreeFormat4
+from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
+
+
+class TestMove(TestCaseWithWorkingTree):
+
+    def test_move_correct_call_named(self):
+        """tree.move has the deprecated parameter 'to_name'.
+        It has been replaced by 'to_dir' for consistency.
+        Test the new API using named parameter
+        """
+        self.build_tree(['a1', 'sub1/'])
+        tree = self.make_branch_and_tree('.')
+        tree.add(['a1', 'sub1'])
+        tree.commit('initial commit')
+        tree.move(['a1'], to_dir='sub1', after=False)
+
+    def test_move_correct_call_unnamed(self):
+        """tree.move has the deprecated parameter 'to_name'.
+        It has been replaced by 'to_dir' for consistency.
+        Test the new API using unnamed parameter
+        """
+        self.build_tree(['a1', 'sub1/'])
+        tree = self.make_branch_and_tree('.')
+        tree.add(['a1', 'sub1'])
+        tree.commit('initial commit')
+        tree.move(['a1'], 'sub1', after=False)
+
+    def test_move_deprecated_wrong_call(self):
+        """tree.move has the deprecated parameter 'to_name'.
+        It has been replaced by 'to_dir' for consistency.
+        Test the new API using wrong parameter
+        """
+        self.build_tree(['a1', 'sub1/'])
+        tree = self.make_branch_and_tree('.')
+        tree.add(['a1', 'sub1'])
+        tree.commit('initial commit')
+        self.assertRaises(TypeError, tree.move, ['a1'],
+                          to_this_parameter_does_not_exist='sub1',
+                          after=False)
+
+    def test_move_deprecated_call(self):
+        """tree.move has the deprecated parameter 'to_name'.
+        It has been replaced by 'to_dir' for consistency.
+        Test the new API using deprecated parameter
+        """
+        self.build_tree(['a1', 'sub1/'])
+        tree = self.make_branch_and_tree('.')
+        tree.add(['a1', 'sub1'])
+        tree.commit('initial commit')
+
+        try:
+            self.callDeprecated(['The parameter to_name was deprecated'
+                                 ' in version 0.13. Use to_dir instead'],
+                                tree.move, ['a1'], to_name='sub1',
+                                after=False)
+        except TypeError:
+            # WorkingTreeFormat4 doesn't have to maintain api compatibility
+            # since it was deprecated before the class was introduced.
+            if not isinstance(self.workingtree_format, WorkingTreeFormat4):
+                raise
+

=== modified file 'bzrlib/tests/workingtree_implementations/__init__.py'
--- a/bzrlib/tests/workingtree_implementations/__init__.py	2007-02-22 01:17:30 +0000
+++ b/bzrlib/tests/workingtree_implementations/__init__.py	2007-02-25 17:20:22 +0000
@@ -64,6 +64,7 @@
         'bzrlib.tests.workingtree_implementations.test_locking',
         'bzrlib.tests.workingtree_implementations.test_merge_from_branch',
         'bzrlib.tests.workingtree_implementations.test_mkdir',
+        'bzrlib.tests.workingtree_implementations.test_move',
         'bzrlib.tests.workingtree_implementations.test_parents',
         'bzrlib.tests.workingtree_implementations.test_paths2ids',
         'bzrlib.tests.workingtree_implementations.test_pull',

=== modified file 'bzrlib/tests/workingtree_implementations/test_workingtree.py'
--- a/bzrlib/tests/workingtree_implementations/test_workingtree.py	2007-02-23 03:01:08 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_workingtree.py	2007-02-25 17:20:22 +0000
@@ -712,52 +712,6 @@
         finally:
             osutils.normalized_filename = orig
 
-    def test_move_correct_call_named(self):
-        """tree.move has the deprecated parameter 'to_name'.
-        It has been replaced by 'to_dir' for consistency.
-        Test the new API using named parameter"""
-        self.build_tree(['a1', 'sub1/'])
-        tree = self.make_branch_and_tree('.')
-        tree.add(['a1', 'sub1'])
-        tree.commit('initial commit')
-        tree.move(['a1'], to_dir='sub1', after=False)
-
-    def test_move_correct_call_unnamed(self):
-        """tree.move has the deprecated parameter 'to_name'.
-        It has been replaced by 'to_dir' for consistency.
-        Test the new API using unnamed parameter"""
-        self.build_tree(['a1', 'sub1/'])
-        tree = self.make_branch_and_tree('.')
-        tree.add(['a1', 'sub1'])
-        tree.commit('initial commit')
-        tree.move(['a1'], 'sub1', after=False)
-
-    def test_move_deprecated_wrong_call(self):
-        """tree.move has the deprecated parameter 'to_name'.
-        It has been replaced by 'to_dir' for consistency.
-        Test the new API using wrong parameter"""
-        self.build_tree(['a1', 'sub1/'])
-        tree = self.make_branch_and_tree('.')
-        tree.add(['a1', 'sub1'])
-        tree.commit('initial commit')
-        self.assertRaises(TypeError, tree.move, ['a1'],
-                          to_this_parameter_does_not_exist='sub1',
-                          after=False)
-
-    def test_move_deprecated_call(self):
-        """tree.move has the deprecated parameter 'to_name'.
-        It has been replaced by 'to_dir' for consistency.
-        Test the new API using deprecated parameter"""
-        self.build_tree(['a1', 'sub1/'])
-        tree = self.make_branch_and_tree('.')
-        tree.add(['a1', 'sub1'])
-        tree.commit('initial commit')
-
-        self.callDeprecated(['The parameter to_name was deprecated'
-                             ' in version 0.13. Use to_dir instead'],
-                            tree.move, ['a1'], to_name='sub1',
-                            after=False)
-
     def test__write_inventory(self):
         # The private interface _write_inventory is currently used by transform.
         tree = self.make_branch_and_tree('.')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-02-25 16:56:33 +0000
+++ b/bzrlib/workingtree_4.py	2007-02-25 17:20:22 +0000
@@ -399,23 +399,13 @@
             self._dirstate.lock_write()
 
     @needs_tree_write_lock
-    def move(self, from_paths, to_dir=None, after=False, **kwargs):
+    def move(self, from_paths, to_dir, after=False):
         """See WorkingTree.move()."""
         if not from_paths:
             return ()
 
         state = self.current_dirstate()
 
-        # check for deprecated use of signature
-        if to_dir is None:
-            to_dir = kwargs.get('to_name', None)
-            if to_dir is None:
-                raise TypeError('You must supply a target directory')
-            else:
-                symbol_versioning.warn('The parameter to_name was deprecated'
-                                       ' in version 0.13. Use to_dir instead',
-                                       DeprecationWarning)
-
         assert not isinstance(from_paths, basestring)
         to_dir_utf8 = to_dir.encode('utf8')
         to_entry_dirname, to_basename = os.path.split(to_dir_utf8)



More information about the bazaar-commits mailing list