/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/memorytree.py

  • Committer: Martin
  • Date: 2017-08-26 16:16:11 UTC
  • mto: This revision was merged to the branch mainline in revision 6763.
  • Revision ID: gzlist@googlemail.com-20170826161611-gzjgbcvq03u9vr38
One last dict.iteritems() in hooks tests

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
22
23
 
23
24
import os
24
25
 
25
 
from bzrlib import (
 
26
from . import (
26
27
    errors,
27
28
    mutabletree,
28
29
    revision as _mod_revision,
29
30
    )
30
 
from bzrlib.decorators import needs_read_lock
31
 
from bzrlib.osutils import sha_file
32
 
from bzrlib.mutabletree import needs_tree_write_lock
33
 
from bzrlib.transport.memory import MemoryTransport
34
 
 
35
 
 
36
 
class MemoryTree(mutabletree.MutableTree):
 
31
from .decorators import needs_read_lock
 
32
from .bzr.inventory import Inventory
 
33
from .bzr.inventorytree import MutableInventoryTree
 
34
from .osutils import sha_file
 
35
from .mutabletree import needs_tree_write_lock
 
36
from .transport.memory import MemoryTransport
 
37
 
 
38
 
 
39
class MemoryTree(MutableInventoryTree):
37
40
    """A MemoryTree is a specialisation of MutableTree.
38
41
 
39
42
    It maintains nearly no state outside of read_lock and write_lock
44
47
    def __init__(self, branch, revision_id):
45
48
        """Construct a MemoryTree for branch using revision_id."""
46
49
        self.branch = branch
47
 
        self.bzrdir = branch.bzrdir
 
50
        self.controldir = branch.controldir
48
51
        self._branch_revision_id = revision_id
49
52
        self._locks = 0
50
53
        self._lock_mode = None
51
54
 
 
55
    def get_config_stack(self):
 
56
        return self.branch.get_config_stack()
 
57
 
 
58
    def is_control_filename(self, filename):
 
59
        # Memory tree doesn't have any control filenames
 
60
        return False
 
61
 
52
62
    @needs_tree_write_lock
53
63
    def _add(self, files, ids, kinds):
54
64
        """See MutableTree._add."""
215
225
            self._parent_ids = []
216
226
        else:
217
227
            self._parent_ids = [self._branch_revision_id]
218
 
        self._inventory = self._basis_tree._inventory._get_mutable_inventory()
 
228
        self._inventory = Inventory(None, self._basis_tree.get_revision_id())
219
229
        self._file_transport = MemoryTransport()
220
230
        # TODO copy the revision trees content, or do it lazy, or something.
221
 
        inventory_entries = self._inventory.iter_entries()
 
231
        inventory_entries = self._basis_tree.iter_entries_by_dir()
222
232
        for path, entry in inventory_entries:
 
233
            self._inventory.add(entry.copy())
223
234
            if path == '':
224
235
                continue
225
236
            if entry.kind == 'directory':
283
294
            self._branch_revision_id = revision_ids[0]
284
295
        self._allow_leftmost_as_ghost = allow_leftmost_as_ghost
285
296
        self._set_basis()
286
 
    
 
297
 
287
298
    def _set_basis(self):
288
299
        try:
289
300
            self._basis_tree = self.branch.repository.revision_tree(