Rev 5782: (jelmer) Split inventory-specific bits out of MutableTree into in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Apr 11 20:02:15 UTC 2011


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

------------------------------------------------------------
revno: 5782 [merge]
revision-id: pqm at pqm.ubuntu.com-20110411200154-cw0j0mqyiov9q5h6
parent: pqm at pqm.ubuntu.com-20110411183146-s7r7m89gnp0dl3sr
parent: jelmer at samba.org-20110411100516-fjotqodhohs77njo
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-04-11 20:01:54 +0000
message:
  (jelmer) Split inventory-specific bits out of MutableTree into
   MutableInventoryTree. (Jelmer Vernooij)
modified:
  bzrlib/memorytree.py           memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/per_repository/test_iter_reverse_revision_history.py test_iter_reverse_re-20070217015036-spu7j5ggch7pbpyd-1
  bzrlib/tests/per_tree/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/memorytree.py'
--- a/bzrlib/memorytree.py	2011-04-11 09:56:15 +0000
+++ b/bzrlib/memorytree.py	2011-04-11 10:05:16 +0000
@@ -26,8 +26,6 @@
     errors,
     mutabletree,
     revision as _mod_revision,
-    revisiontree,
-    tree,
     )
 from bzrlib.decorators import needs_read_lock
 from bzrlib.osutils import sha_file
@@ -35,7 +33,7 @@
 from bzrlib.transport.memory import MemoryTransport
 
 
-class MemoryTree(mutabletree.MutableTree, tree.InventoryTree):
+class MemoryTree(mutabletree.MutableInventoryTree):
     """A MemoryTree is a specialisation of MutableTree.
 
     It maintains nearly no state outside of read_lock and write_lock

=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2011-04-09 19:25:42 +0000
+++ b/bzrlib/mutabletree.py	2011-04-09 21:00:33 +0000
@@ -54,7 +54,7 @@
     return tree_write_locked
 
 
-class MutableTree(tree.InventoryTree):
+class MutableTree(tree.Tree):
     """A MutableTree is a specialisation of Tree which is able to be mutated.
 
     Generally speaking these mutations are only possible within a lock_write
@@ -160,7 +160,7 @@
         if sub_tree_id == self.get_root_id():
             raise errors.BadReferenceTarget(self, sub_tree,
                                      'Trees have the same root id.')
-        if sub_tree_id in self.inventory:
+        if sub_tree_id in self:
             raise errors.BadReferenceTarget(self, sub_tree,
                                             'Root id already present in tree')
         self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
@@ -175,7 +175,6 @@
         """
         raise NotImplementedError(self._add)
 
-    @needs_tree_write_lock
     def apply_inventory_delta(self, changes):
         """Apply changes to the inventory as an atomic operation.
 
@@ -184,10 +183,7 @@
         :return None:
         :seealso Inventory.apply_delta: For details on the changes parameter.
         """
-        self.flush()
-        inv = self.inventory
-        inv.apply_delta(changes)
-        self._write_inventory(inv)
+        raise NotImplementedError(self.apply_inventory_delta)
 
     @needs_write_lock
     def commit(self, message=None, revprops=None, *args,
@@ -345,12 +341,6 @@
         :return: None
         """
 
-    def _fix_case_of_inventory_path(self, path):
-        """If our tree isn't case sensitive, return the canonical path"""
-        if not self.case_sensitive:
-            path = self.get_canonical_inventory_path(path)
-        return path
-
     @needs_write_lock
     def put_file_bytes_non_atomic(self, file_id, bytes):
         """Update the content of a file in the tree.
@@ -380,6 +370,75 @@
         """
         raise NotImplementedError(self.set_parent_trees)
 
+    def smart_add(self, file_list, recurse=True, action=None, save=True):
+        """Version file_list, optionally recursing into directories.
+
+        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.
+        :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.
+        :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.
+        """
+        raise NotImplementedError(self.smart_add)
+
+    def update_basis_by_delta(self, new_revid, delta):
+        """Update the parents of this tree after a commit.
+
+        This gives the tree one parent, with revision id new_revid. The
+        inventory delta is applied to the current basis tree to generate the
+        inventory for the parent new_revid, and all other parent trees are
+        discarded.
+
+        All the changes in the delta should be changes synchronising the basis
+        tree with some or all of the working tree, with a change to a directory
+        requiring that its contents have been recursively included. That is,
+        this is not a general purpose tree modification routine, but a helper
+        for commit which is not required to handle situations that do not arise
+        outside of commit.
+
+        See the inventory developers documentation for the theory behind
+        inventory deltas.
+
+        :param new_revid: The new revision id for the trees parent.
+        :param delta: An inventory delta (see apply_inventory_delta) describing
+            the changes from the current left most parent revision to new_revid.
+        """
+        raise NotImplementedError(self.update_basis_by_delta)
+
+
+class MutableInventoryTree(MutableTree,tree.InventoryTree):
+
+    @needs_tree_write_lock
+    def apply_inventory_delta(self, changes):
+        """Apply changes to the inventory as an atomic operation.
+
+        :param changes: An inventory delta to apply to the working tree's
+            inventory.
+        :return None:
+        :seealso Inventory.apply_delta: For details on the changes parameter.
+        """
+        self.flush()
+        inv = self.inventory
+        inv.apply_delta(changes)
+        self._write_inventory(inv)
+
+    def _fix_case_of_inventory_path(self, path):
+        """If our tree isn't case sensitive, return the canonical path"""
+        if not self.case_sensitive:
+            path = self.get_canonical_inventory_path(path)
+        return path
+
     @needs_tree_write_lock
     def smart_add(self, file_list, recurse=True, action=None, save=True):
         """Version file_list, optionally recursing into directories.
@@ -642,6 +701,8 @@
         self.set_parent_trees([(new_revid, rev_tree)])
 
 
+
+
 class MutableTreeHooks(hooks.Hooks):
     """A dictionary mapping a hook name to a list of callables for mutabletree
     hooks.

=== modified file 'bzrlib/tests/per_repository/test_iter_reverse_revision_history.py'
--- a/bzrlib/tests/per_repository/test_iter_reverse_revision_history.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/per_repository/test_iter_reverse_revision_history.py	2011-04-09 21:00:33 +0000
@@ -18,7 +18,6 @@
 
 from bzrlib import (
     errors,
-    osutils,
     tests,
     )
 from bzrlib.tests.per_repository import TestCaseWithRepository

=== modified file 'bzrlib/tests/per_tree/test_inv.py'
--- a/bzrlib/tests/per_tree/test_inv.py	2010-12-02 09:23:10 +0000
+++ b/bzrlib/tests/per_tree/test_inv.py	2011-04-09 21:00:33 +0000
@@ -17,18 +17,14 @@
 """Tests for interface conformance of inventories of trees."""
 
 
-from cStringIO import StringIO
-import os
-
 from bzrlib import (
     tests,
     )
 from bzrlib.tests import (
-    features,
     per_tree,
     )
 from bzrlib.mutabletree import MutableTree
-from bzrlib.tests import SymlinkFeature, TestSkipped
+from bzrlib.tests import TestSkipped
 from bzrlib.transform import _PreviewTree
 from bzrlib.uncommit import uncommit
 

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2011-04-09 15:08:16 +0000
+++ b/bzrlib/workingtree.py	2011-04-11 20:01:54 +0000
@@ -166,7 +166,7 @@
         return ''
 
 
-class WorkingTree(bzrlib.mutabletree.MutableTree,
+class WorkingTree(bzrlib.mutabletree.MutableInventoryTree,
     controldir.ControlComponent):
     """Working copy tree.
 




More information about the bazaar-commits mailing list