594
595
cPickle.dump(stats, open('lsprof.stats', 'w'), 2)
596
self.log.info('lsprof complete!')
599
def _get_deltas_for_revisions_with_trees(self, revisions):
600
"""Produce a generator of revision deltas.
602
Note that the input is a sequence of REVISIONS, not revision_ids.
603
Trees will be held in memory until the generator exits.
604
Each delta is relative to the revision's lefthand predecessor.
606
required_trees = set()
607
for revision in revisions:
608
required_trees.add(revision.revision_id)
609
required_trees.update(revision.parent_ids[:1])
610
trees = dict((t.get_revision_id(), t) for
611
t in self._branch.repository.revision_trees(required_trees))
613
self._branch.repository.lock_read()
615
for revision in revisions:
616
if not revision.parent_ids:
617
old_tree = self._branch.repository.revision_tree(None)
619
old_tree = trees[revision.parent_ids[0]]
620
tree = trees[revision.revision_id]
621
ret.append((tree, old_tree, tree.changes_from(old_tree)))
624
self._branch.repository.unlock()
597
626
@with_branch_lock
598
627
@with_bzrlib_read_lock
599
628
def get_changes_uncached(self, revid_list, get_diffs=False):
602
631
except (KeyError, bzrlib.errors.NoSuchRevision):
605
delta_list = self._branch.repository.get_deltas_for_revisions(rev_list)
634
delta_list = self._get_deltas_for_revisions_with_trees(rev_list)
606
635
combined_list = zip(rev_list, delta_list)
610
# lookup the trees for each revision, so we can calculate diffs
613
lookup_set.add(rev.revision_id)
614
if len(rev.parent_ids) > 0:
615
lookup_set.add(rev.parent_ids[0])
616
tree_map = dict((t.get_revision_id(), t) for t in self._branch.repository.revision_trees(lookup_set))
617
# also the root tree, in case we hit the origin:
618
tree_map[None] = self._branch.repository.revision_tree(None)
621
for rev, delta in combined_list:
638
for rev, (new_tree, old_tree, delta) in combined_list:
622
639
commit_time = datetime.datetime.fromtimestamp(rev.timestamp)
624
641
parents = [util.Container(revid=r, revno=self.get_revno(r)) for r in rev.parent_ids]
638
655
if len(short_message) > 60:
639
656
short_message = short_message[:60] + '...'
641
old_tree, new_tree = None, None
643
new_tree = tree_map[rev.revision_id]
644
old_tree = tree_map[left_parent]
647
659
'revid': rev.revision_id,
648
660
'revno': self.get_revno(rev.revision_id),