~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/history.py

  • Committer: Martin Albisetti
  • Date: 2009-09-01 21:44:23 UTC
  • Revision ID: martin.albisetti@canonical.com-20090901214423-mo6dctq8xvpm2jse
Super-trivial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import logging
34
34
import re
35
35
import textwrap
36
 
import threading
37
36
 
38
37
from loggerhead import search
39
38
from loggerhead import util
42
41
import bzrlib
43
42
import bzrlib.branch
44
43
import bzrlib.delta
45
 
import bzrlib.diff
46
44
import bzrlib.errors
47
 
import bzrlib.lru_cache
48
 
import bzrlib.progress
49
 
import bzrlib.revision
50
 
import bzrlib.textfile
51
 
import bzrlib.tsort
52
 
import bzrlib.ui
53
 
 
54
 
# bzrlib's UIFactory is not thread-safe
55
 
uihack = threading.local()
56
 
 
57
 
 
58
 
class ThreadSafeUIFactory (bzrlib.ui.SilentUIFactory):
59
 
 
60
 
    def nested_progress_bar(self):
61
 
        if getattr(uihack, '_progress_bar_stack', None) is None:
62
 
            pbs = bzrlib.progress.ProgressBarStack(
63
 
                      klass=bzrlib.progress.DummyProgress)
64
 
            uihack._progress_bar_stack = pbs
65
 
        return uihack._progress_bar_stack.get_nested()
66
 
 
67
 
bzrlib.ui.ui_factory = ThreadSafeUIFactory()
 
45
 
68
46
 
69
47
def is_branch(folder):
70
48
    try:
649
627
        Given a bzrlib Revision, return a processed "change" for use in
650
628
        templates.
651
629
        """
652
 
        parents = [util.Container(revid=r,
653
 
                   revno=self.get_revno(r)) for r in revision.parent_ids]
654
 
 
655
630
        message, short_message = clean_message(revision.message)
656
631
 
657
 
        try:
658
 
            authors = revision.get_apparent_authors()
659
 
        except AttributeError:
660
 
            authors = [revision.get_apparent_author()]
 
632
        tags = self._branch.tags.get_reverse_tag_dict()
 
633
 
 
634
        revtags = None
 
635
        if tags.has_key(revision.revision_id):
 
636
          revtags = ', '.join(tags[revision.revision_id])
661
637
 
662
638
        entry = {
663
639
            'revid': revision.revision_id,
664
640
            'date': datetime.datetime.fromtimestamp(revision.timestamp),
665
641
            'utc_date': datetime.datetime.utcfromtimestamp(revision.timestamp),
666
 
            'authors': authors,
 
642
            'authors': revision.get_apparent_authors(),
667
643
            'branch_nick': revision.properties.get('branch-nick', None),
668
644
            'short_comment': short_message,
669
645
            'comment': revision.message,
670
646
            'comment_clean': [util.html_clean(s) for s in message],
671
647
            'parents': revision.parent_ids,
672
648
            'bugs': [bug.split()[0] for bug in revision.properties.get('bugs', '').splitlines()],
 
649
            'tags': revtags,
673
650
        }
674
651
        return util.Container(entry)
675
652
 
676
653
    def get_file_changes_uncached(self, entry):
677
 
        repo = self._branch.repository
678
654
        if entry.parents:
679
655
            old_revid = entry.parents[0].revid
680
656
        else: