~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/memorytree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    revision as _mod_revision,
29
29
    )
30
30
from bzrlib.decorators import needs_read_lock
31
 
from bzrlib.inventory import Inventory
32
31
from bzrlib.osutils import sha_file
33
32
from bzrlib.mutabletree import needs_tree_write_lock
34
33
from bzrlib.transport.memory import MemoryTransport
35
34
 
36
35
 
37
 
class MemoryTree(mutabletree.MutableInventoryTree):
 
36
class MemoryTree(mutabletree.MutableTree):
38
37
    """A MemoryTree is a specialisation of MutableTree.
39
38
 
40
39
    It maintains nearly no state outside of read_lock and write_lock
50
49
        self._locks = 0
51
50
        self._lock_mode = None
52
51
 
53
 
    def is_control_filename(self, filename):
54
 
        # Memory tree doesn't have any control filenames
55
 
        return False
56
 
 
57
52
    @needs_tree_write_lock
58
53
    def _add(self, files, ids, kinds):
59
54
        """See MutableTree._add."""
220
215
            self._parent_ids = []
221
216
        else:
222
217
            self._parent_ids = [self._branch_revision_id]
223
 
        self._inventory = Inventory(None, self._basis_tree.get_revision_id())
 
218
        self._inventory = self._basis_tree._inventory._get_mutable_inventory()
224
219
        self._file_transport = MemoryTransport()
225
220
        # TODO copy the revision trees content, or do it lazy, or something.
226
 
        inventory_entries = self._basis_tree.iter_entries_by_dir()
 
221
        inventory_entries = self._inventory.iter_entries()
227
222
        for path, entry in inventory_entries:
228
 
            self._inventory.add(entry.copy())
229
223
            if path == '':
230
224
                continue
231
225
            if entry.kind == 'directory':