~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/memorytree.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-11 21:41:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080711214124-qi09irlj7pd5cuzg
Shortcut the case when one revision is in the ancestry of the other.

At the cost of a heads() check, when one parent supersedes, we don't have to extract
the text for the other. Changes merge time from 3m37s => 3m21s. Using a
CachingParentsProvider would drop the time down to 3m11s.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
from copy import deepcopy
24
 
import os
25
24
 
26
25
from bzrlib import (
27
26
    errors,
28
27
    mutabletree,
29
 
    osutils,
30
28
    revision as _mod_revision,
31
29
    )
32
30
from bzrlib.decorators import needs_read_lock, needs_write_lock
70
68
    def create_on_branch(branch):
71
69
        """Create a MemoryTree for branch, using the last-revision of branch."""
72
70
        revision_id = _mod_revision.ensure_null(branch.last_revision())
 
71
        if _mod_revision.is_null(revision_id):
 
72
            revision_id = None
73
73
        return MemoryTree(branch, revision_id)
74
74
 
75
75
    def _gather_kinds(self, files, kinds):
101
101
            return None, False, None
102
102
        return entry.kind, entry.executable, None
103
103
 
104
 
    @needs_tree_write_lock
105
 
    def rename_one(self, from_rel, to_rel):
106
 
        file_id = self.path2id(from_rel)
107
 
        to_dir, to_tail = os.path.split(to_rel)
108
 
        to_parent_id = self.path2id(to_dir)
109
 
        self._file_transport.move(from_rel, to_rel)
110
 
        self._inventory.rename(file_id, to_parent_id, to_tail)
111
 
 
112
104
    def path_content_summary(self, path):
113
105
        """See Tree.path_content_summary."""
114
106
        id = self.path2id(path)
214
206
        """Populate the in-tree state from the branch."""
215
207
        self._basis_tree = self.branch.repository.revision_tree(
216
208
            self._branch_revision_id)
217
 
        if self._branch_revision_id == _mod_revision.NULL_REVISION:
 
209
        if self._branch_revision_id is None:
218
210
            self._parent_ids = []
219
211
        else:
220
212
            self._parent_ids = [self._branch_revision_id]
280
272
            _mod_revision.check_not_reserved_id(revision_id)
281
273
        if len(revision_ids) == 0:
282
274
            self._parent_ids = []
283
 
            self._basis_tree = self.branch.repository.revision_tree(
284
 
                                    _mod_revision.NULL_REVISION)
 
275
            self._basis_tree = self.branch.repository.revision_tree(None)
285
276
        else:
286
277
            self._parent_ids = revision_ids
287
278
            self._basis_tree = self.branch.repository.revision_tree(
292
283
        """See MutableTree.set_parent_trees()."""
293
284
        if len(parents_list) == 0:
294
285
            self._parent_ids = []
295
 
            self._basis_tree = self.branch.repository.revision_tree(
296
 
                                   _mod_revision.NULL_REVISION)
 
286
            self._basis_tree = self.branch.repository.revision_tree(None)
297
287
        else:
298
288
            if parents_list[0][1] is None and not allow_leftmost_as_ghost:
299
289
                # a ghost in the left most parent
300
290
                raise errors.GhostRevisionUnusableHere(parents_list[0][0])
301
291
            self._parent_ids = [parent_id for parent_id, tree in parents_list]
302
292
            if parents_list[0][1] is None or parents_list[0][1] == 'null:':
303
 
                self._basis_tree = self.branch.repository.revision_tree(
304
 
                                       _mod_revision.NULL_REVISION)
 
293
                self._basis_tree = self.branch.repository.revision_tree(None)
305
294
            else:
306
295
                self._basis_tree = parents_list[0][1]
307
296
            self._branch_revision_id = parents_list[0][0]