~mnordhoff/loggerhead/cheezum

« back to all changes in this revision

Viewing changes to loggerhead/history.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-09-10 00:13:18 UTC
  • mfrom: (164.18.29 trunk)
  • mto: (164.35.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 242.
  • Revision ID: guillo.gonzo@gmail.com-20080910001318-78w16x9zl9p7f1k3
 * merge with trunk 

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
            "Can only construct a History object with a read-locked branch.")
200
200
        self._file_change_cache = None
201
201
        self._branch = branch
 
202
        self._inventory_cache = {}
202
203
        self.log = logging.getLogger('loggerhead.%s' % (branch.nick,))
203
204
 
204
205
        self.last_revid = branch.last_revision()
212
213
         self._revno_revid, self._merge_sort, self._where_merged
213
214
         ) = whole_history_data
214
215
 
 
216
 
215
217
    def use_file_cache(self, cache):
216
218
        self._file_change_cache = cache
217
219
 
417
419
            return None, None, []
418
420
 
419
421
    def get_inventory(self, revid):
420
 
        return self._branch.repository.get_revision_inventory(revid)
 
422
        if revid not in self._inventory_cache:
 
423
            self._inventory_cache[revid] = (
 
424
                self._branch.repository.get_revision_inventory(revid))
 
425
        return self._inventory_cache[revid]
421
426
 
422
427
    def get_path(self, revid, file_id):
423
428
        if (file_id is None) or (file_id == ''):
424
429
            return ''
425
 
        path = self._branch.repository.get_revision_inventory(revid).id2path(file_id)
 
430
        path = self.get_inventory(revid).id2path(file_id)
426
431
        if (len(path) > 0) and not path.startswith('/'):
427
432
            path = '/' + path
428
433
        return path
430
435
    def get_file_id(self, revid, path):
431
436
        if (len(path) > 0) and not path.startswith('/'):
432
437
            path = '/' + path
433
 
        return self._branch.repository.get_revision_inventory(revid).path2id(path)
 
438
        return self.get_inventory(revid).path2id(path)
434
439
 
435
440
    def get_merge_point_list(self, revid):
436
441
        """
559
564
        trees = dict((t.get_revision_id(), t) for
560
565
                     t in self._branch.repository.revision_trees(required_trees))
561
566
        ret = []
562
 
        self._branch.repository.lock_read()
563
 
        try:
564
 
            for revision in revisions:
565
 
                if not revision.parents:
566
 
                    old_tree = self._branch.repository.revision_tree(
567
 
                        bzrlib.revision.NULL_REVISION)
568
 
                else:
569
 
                    old_tree = trees[revision.parents[0].revid]
570
 
                tree = trees[revision.revid]
571
 
                ret.append(tree.changes_from(old_tree))
572
 
            return ret
573
 
        finally:
574
 
            self._branch.repository.unlock()
 
567
        for revision in revisions:
 
568
            if not revision.parents:
 
569
                old_tree = self._branch.repository.revision_tree(
 
570
                    bzrlib.revision.NULL_REVISION)
 
571
            else:
 
572
                old_tree = trees[revision.parents[0].revid]
 
573
            tree = trees[revision.revid]
 
574
            ret.append(tree.changes_from(old_tree))
 
575
        return ret
575
576
 
576
577
    def _change_from_revision(self, revision):
577
578
        """