~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/annotate_ui.py

  • Committer: Robey Pointer
  • Date: 2007-01-24 19:17:25 UTC
  • Revision ID: robey@lag.net-20070124191725-nbh93909s4qfez18
fix silly typo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        
42
42
class AnnotateUI (object):
43
43
 
 
44
    def __init__(self, branch):
 
45
        # BranchView object
 
46
        self._branch = branch
 
47
        self.log = branch.log
 
48
 
 
49
    @util.strip_whitespace
44
50
    @turbogears.expose(html='loggerhead.templates.annotate')
45
51
    def default(self, *args, **kw):
46
52
        z = time.time()
47
 
        h = util.get_history()
 
53
        h = self._branch.get_history()
 
54
        util.set_context(kw)
48
55
        
49
56
        if len(args) > 0:
50
57
            revid = h.fix_revid(args[0])
51
58
        else:
52
59
            revid = None
53
60
        
54
 
        path = kw.get('path', None)
55
 
        if (path == '/') or (path == '') or (path is None):
56
 
            raise HTTPRedirect(turbogears.url('/changes'))
 
61
        file_id = kw.get('file_id', None)
 
62
        if file_id is None:
 
63
            raise HTTPRedirect(self._branch.url('/changes'))
57
64
 
58
65
        try:
59
 
            revlist, revid = h.get_navigation(revid, path)
60
 
            file_id = h.get_inventory(revid).path2id(path)
 
66
            revid_list, revid = h.get_file_view(revid, file_id)
61
67
        except Exception, x:
62
 
            log.error('Exception fetching changes: %r, %s' % (x, x))
63
 
            raise HTTPRedirect(turbogears.url('/changes'))
 
68
            self.log.error('Exception fetching changes: %s' % (x,))
 
69
            util.log_exception(self.log)
 
70
            raise HTTPRedirect(self._branch.url('/changes'))
64
71
            
65
72
        # no navbar for revisions
66
73
        navigation = util.Container()
 
74
        
 
75
        path = h.get_path(revid, file_id)
 
76
        filename = os.path.basename(path)
67
77
 
68
78
        vals = {
69
 
            'branch_name': util.get_config().get('branch_name'),
 
79
            'branch': self._branch,
70
80
            'util': util,
71
81
            'revid': revid,
 
82
            'file_id': file_id,
72
83
            'path': path,
 
84
            'filename': filename,
73
85
            'history': h,
74
86
            'navigation': navigation,
75
 
            'change': h.get_change(revid),
 
87
            'change': h.get_changes([ revid ])[0],
76
88
            'contents': list(h.annotate_file(file_id, revid)),
77
89
        }
78
90
        h.flush_cache()
79
 
        log.info('/annotate: %r secs' % (time.time() - z,))
 
91
        self.log.info('/annotate: %r secs' % (time.time() - z,))
80
92
        return vals