Rev 2586: Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 4 21:41:02 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2586
revision-id: pqm at pqm.ubuntu.com-20070704204059-a1x9jomep52m9arn
parent: pqm at pqm.ubuntu.com-20070704140209-ldl1njlpcclszadu
parent: abentley at panoramicfeedback.com-20070704182424-q55ffb9o09qxw787
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-07-04 21:40:59 +0100
message:
  Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory
modified:
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/workingtree_implementations/test_smart_add.py test_smart_add.py-20070215175752-9s5mxoz8aqpd80fm-1
    ------------------------------------------------------------
    revno: 2585.1.1
    merged: abentley at panoramicfeedback.com-20070704182424-q55ffb9o09qxw787
    parent: pqm at pqm.ubuntu.com-20070704140209-ldl1njlpcclszadu
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: less-crack
    timestamp: Wed 2007-07-04 14:24:24 -0400
    message:
      Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2007-07-04 05:50:05 +0000
+++ b/bzrlib/mutabletree.py	2007-07-04 18:24:24 +0000
@@ -285,9 +285,7 @@
             a specific one should be used.
         :param save: Save the inventory after completing the adds. If False
             this provides dry-run functionality by doing the add and not saving
-            the inventory.  Note that the modified inventory is left in place,
-            allowing further dry-run tasks to take place. To restore the
-            original inventory call self.read_working_inventory().
+            the inventory.
         :return: A tuple - files_added, ignored_files. files_added is the count
             of added files, and ignored_files is a dict mapping files that were
             ignored to the rule that caused them to be ignored.
@@ -444,8 +442,11 @@
                             #mutter("queue to add sub-file %r", subp)
                             dirs_to_add.append((_FastPath(subp, subf), this_ie))
 
-        if len(added) > 0 and save:
-            self._write_inventory(inv)
+        if len(added) > 0:
+            if save:
+                self._write_inventory(inv)
+            else:
+                self.read_working_inventory()
         return added, ignored
 
 

=== modified file 'bzrlib/tests/workingtree_implementations/test_smart_add.py'
--- a/bzrlib/tests/workingtree_implementations/test_smart_add.py	2007-07-04 06:25:03 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_smart_add.py	2007-07-04 18:24:24 +0000
@@ -54,10 +54,14 @@
     def test_save_false(self):
         """Dry-run add doesn't permanently affect the tree."""
         wt = self.make_branch_and_tree('.')
-        self.build_tree(['file'])
-        wt.smart_add(['file'], save=False)
-        # the file should not be added - no id.
-        self.assertEqual(wt.path2id('file'), None)
+        wt.lock_write()
+        try:
+            self.build_tree(['file'])
+            wt.smart_add(['file'], save=False)
+            # the file should not be added - no id.
+            self.assertEqual(wt.path2id('file'), None)
+        finally:
+            wt.unlock()
         # and the disk state should be the same - reopen to check.
         wt = wt.bzrdir.open_workingtree()
         self.assertEqual(wt.path2id('file'), None)




More information about the bazaar-commits mailing list