~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/memorytree.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 16:50:33 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604165033-bfdo0lyf4yt4vjcz
We don't need a base Coder class, because Decoder._update_tail is different than Encoder._update_tail.
(one adds, one subtracts from self.size).
So we now have 2 versions of the macro, and the test suite stops crashing... :)

Show diffs side-by-side

added added

removed removed

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