~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/memorytree.py

  • Committer: Aaron Bentley
  • Date: 2009-03-24 15:47:32 UTC
  • mto: This revision was merged to the branch mainline in revision 4241.
  • Revision ID: aaron@aaronbentley.com-20090324154732-bwkvi4dx3o90a7dq
Add output, emit minimal inventory delta.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
"""
21
21
 
22
22
 
 
23
from copy import deepcopy
23
24
import os
24
25
 
25
26
from bzrlib import (
26
27
    errors,
27
28
    mutabletree,
 
29
    osutils,
28
30
    revision as _mod_revision,
29
31
    )
30
 
from bzrlib.decorators import needs_read_lock
 
32
from bzrlib.decorators import needs_read_lock, needs_write_lock
31
33
from bzrlib.osutils import sha_file
32
34
from bzrlib.mutabletree import needs_tree_write_lock
33
35
from bzrlib.transport.memory import MemoryTransport
210
212
 
211
213
    def _populate_from_branch(self):
212
214
        """Populate the in-tree state from the branch."""
213
 
        self._set_basis()
 
215
        self._basis_tree = self.branch.repository.revision_tree(
 
216
            self._branch_revision_id)
214
217
        if self._branch_revision_id == _mod_revision.NULL_REVISION:
215
218
            self._parent_ids = []
216
219
        else:
217
220
            self._parent_ids = [self._branch_revision_id]
218
 
        self._inventory = self._basis_tree._inventory._get_mutable_inventory()
 
221
        self._inventory = deepcopy(self._basis_tree._inventory)
219
222
        self._file_transport = MemoryTransport()
220
223
        # TODO copy the revision trees content, or do it lazy, or something.
221
224
        inventory_entries = self._inventory.iter_entries()
277
280
            _mod_revision.check_not_reserved_id(revision_id)
278
281
        if len(revision_ids) == 0:
279
282
            self._parent_ids = []
280
 
            self._branch_revision_id = _mod_revision.NULL_REVISION
 
283
            self._basis_tree = self.branch.repository.revision_tree(
 
284
                                    _mod_revision.NULL_REVISION)
281
285
        else:
282
286
            self._parent_ids = revision_ids
 
287
            self._basis_tree = self.branch.repository.revision_tree(
 
288
                                    revision_ids[0])
283
289
            self._branch_revision_id = revision_ids[0]
284
 
        self._allow_leftmost_as_ghost = allow_leftmost_as_ghost
285
 
        self._set_basis()
286
 
    
287
 
    def _set_basis(self):
288
 
        try:
289
 
            self._basis_tree = self.branch.repository.revision_tree(
290
 
                self._branch_revision_id)
291
 
        except errors.NoSuchRevision:
292
 
            if self._allow_leftmost_as_ghost:
293
 
                self._basis_tree = self.branch.repository.revision_tree(
294
 
                    _mod_revision.NULL_REVISION)
295
 
            else:
296
 
                raise
297
290
 
298
291
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
299
292
        """See MutableTree.set_parent_trees()."""