Rev 4247: (ianc) prepare for CHKInventory in memorytree/mutabletree (Vincent in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 3 14:48:37 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4247
revision-id: pqm at pqm.ubuntu.com-20090403134832-h6hyqeruefueidyu
parent: pqm at pqm.ubuntu.com-20090403112653-xcbrm6c5zdlymd53
parent: ian.clatworthy at canonical.com-20090403115948-oq2uwsjfo3kc0xwz
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-04-03 14:48:32 +0100
message:
(ianc) prepare for CHKInventory in memorytree/mutabletree (Vincent
Ladeuil)
modified:
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
------------------------------------------------------------
revno: 4246.1.1
revision-id: ian.clatworthy at canonical.com-20090403115948-oq2uwsjfo3kc0xwz
parent: pqm at pqm.ubuntu.com-20090403112653-xcbrm6c5zdlymd53
parent: ian.clatworthy at canonical.com-20090403051724-1rtkgua4zrhbrfrg
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Fri 2009-04-03 21:59:48 +1000
message:
(ianc) prepare for CHKInventory in memorytree/mutabletree (Vincent Ladeuil)
modified:
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
------------------------------------------------------------
revno: 4244.2.1
revision-id: ian.clatworthy at canonical.com-20090403051724-1rtkgua4zrhbrfrg
parent: pqm at pqm.ubuntu.com-20090403043720-k4mdy4a72sk0n1ok
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.bris-get-mutable-inv
timestamp: Fri 2009-04-03 15:17:24 +1000
message:
inv._get_mutable_inventory() - prepare for CHKInventory
modified:
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/inventory.py 2009-04-03 05:17:24 +0000
@@ -27,13 +27,13 @@
# created, but it's not for now.
ROOT_ID = "TREE_ROOT"
-import os
-import re
-import sys
+from copy import deepcopy
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
import collections
+import os
+import re
import tarfile
import bzrlib
@@ -877,6 +877,14 @@
other.add(entry.copy())
return other
+ def _get_mutable_inventory(self):
+ """Returns a mutable copy of the object.
+
+ Some inventories are immutable, yet working trees, for example, needs
+ to mutate exisiting inventories instead of creating a new one.
+ """
+ return deepcopy(self)
+
def __iter__(self):
return iter(self._byid)
=== modified file 'bzrlib/memorytree.py'
--- a/bzrlib/memorytree.py 2009-03-24 23:19:12 +0000
+++ b/bzrlib/memorytree.py 2009-04-03 05:17:24 +0000
@@ -20,7 +20,6 @@
"""
-from copy import deepcopy
import os
from bzrlib import (
@@ -217,7 +216,7 @@
self._parent_ids = []
else:
self._parent_ids = [self._branch_revision_id]
- self._inventory = deepcopy(self._basis_tree._inventory)
+ self._inventory = self._basis_tree._inventory._get_mutable_inventory()
self._file_transport = MemoryTransport()
# TODO copy the revision trees content, or do it lazy, or something.
inventory_entries = self._inventory.iter_entries()
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py 2009-03-24 12:15:01 +0000
+++ b/bzrlib/mutabletree.py 2009-04-03 05:17:24 +0000
@@ -552,7 +552,10 @@
# WorkingTree classes for optimised versions for specific format trees.
basis = self.basis_tree()
basis.lock_read()
- inventory = basis.inventory
+ # TODO: Consider re-evaluating the need for this with CHKInventory
+ # we don't strictly need to mutate an inventory for this
+ # it only makes sense when apply_delta is cheaper than get_inventory()
+ inventory = basis.inventory._get_mutable_inventory()
basis.unlock()
inventory.apply_delta(delta)
rev_tree = RevisionTree(self.branch.repository, inventory, new_revid)
More information about the bazaar-commits
mailing list