Rev 2317: add a workingtree_implementations test that makes sure smart_add_tree orks properly in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Thu Feb 15 18:00:04 GMT 2007


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

------------------------------------------------------------
revno: 2317
revision-id: john at arbash-meinel.com-20070215175900-28ukh0bwk1lnv1qq
parent: john at arbash-meinel.com-20070215175610-171tue5qcl4zm6vf
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Thu 2007-02-15 11:59:00 -0600
message:
  add a workingtree_implementations test that makes sure smart_add_tree orks properly
  and fix smart_add_tree to ensure that it takes out a lock_tree_write()
added:
  bzrlib/tests/workingtree_implementations/test_smart_add.py test_smart_add.py-20070215175752-9s5mxoz8aqpd80fm-1
modified:
  bzrlib/add.py                  add.py-20050323030017-3a77d63feda58e33
  bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
-------------- next part --------------
=== added file 'bzrlib/tests/workingtree_implementations/test_smart_add.py'
--- a/bzrlib/tests/workingtree_implementations/test_smart_add.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_smart_add.py	2007-02-15 17:59:00 +0000
@@ -0,0 +1,42 @@
+# Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Test that we can use smart_add on all Tree implementations."""
+
+from bzrlib import (
+    add,
+    errors,
+    workingtree,
+    )
+from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
+
+
+class TestSmartAddTree(TestCaseWithWorkingTree):
+
+    def test_single_file(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/a'])
+        add.smart_add_tree(tree, ['tree'])
+
+        tree.lock_read()
+        try:
+            files = [(path, status, kind)
+                     for path, status, kind, file_id, parent_id
+                      in tree.list_files(include_root=True)]
+        finally:
+            tree.unlock()
+        self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')],
+                         files)

=== modified file 'bzrlib/add.py'
--- a/bzrlib/add.py	2006-11-10 21:06:11 +0000
+++ b/bzrlib/add.py	2007-02-15 17:59:00 +0000
@@ -169,6 +169,14 @@
 
 
 def smart_add_tree(tree, file_list, recurse=True, action=None, save=True):
+    tree.lock_tree_write()
+    try:
+        return _smart_add_tree(tree=tree, file_list=file_list, recurse=recurse,
+                               action=action, save=save)
+    finally:
+        tree.unlock()
+
+def _smart_add_tree(tree, file_list, recurse=True, action=None, save=True):
     """Add files to version, optionally recursing into directories.
 
     This is designed more towards DWIM for humans than API simplicity.

=== modified file 'bzrlib/tests/workingtree_implementations/__init__.py'
--- a/bzrlib/tests/workingtree_implementations/__init__.py	2007-02-02 04:49:38 +0000
+++ b/bzrlib/tests/workingtree_implementations/__init__.py	2007-02-15 17:59:00 +0000
@@ -66,11 +66,11 @@
         'bzrlib.tests.workingtree_implementations.test_parents',
         'bzrlib.tests.workingtree_implementations.test_pull',
         'bzrlib.tests.workingtree_implementations.test_put_file',
-        'bzrlib.tests.workingtree_implementations.test_mkdir',
         'bzrlib.tests.workingtree_implementations.test_readonly',
         'bzrlib.tests.workingtree_implementations.test_read_working_inventory',
         'bzrlib.tests.workingtree_implementations.test_revision_tree',
         'bzrlib.tests.workingtree_implementations.test_set_root_id',
+        'bzrlib.tests.workingtree_implementations.test_smart_add',
         'bzrlib.tests.workingtree_implementations.test_unversion',
         'bzrlib.tests.workingtree_implementations.test_walkdirs',
         'bzrlib.tests.workingtree_implementations.test_workingtree',



More information about the bazaar-commits mailing list