17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
from cherrypy import InternalError
20
from paste.httpexceptions import HTTPServerError
25
22
from loggerhead import util
26
from loggerhead.templatefunctions import templatefunctions
23
from loggerhead.controllers import TemplatedBranchView
29
26
DEFAULT_LINE_COUNT_LIMIT = 3000
32
class RevisionUI (object):
34
def __init__(self, branch):
40
@util.strip_whitespace
41
@turbogears.expose(html='zpt:loggerhead.templates.revision')
42
def default(self, *args, **kw):
44
h = self._branch.get_history()
29
class RevisionUI(TemplatedBranchView):
31
template_path = 'loggerhead.templates.revision'
33
def get_values(self, h, args, kw, response):
36
revid = h.fix_revid(args[0])
40
filter_file_id = kw.get('filter_file_id', None)
41
start_revid = h.fix_revid(kw.get('start_revid', None))
42
query = kw.get('q', None)
43
remember = h.fix_revid(kw.get('remember', None))
44
compare_revid = h.fix_revid(kw.get('compare_revid', None))
50
revid = h.fix_revid(args[0])
54
filter_file_id = kw.get('filter_file_id', None)
55
start_revid = h.fix_revid(kw.get('start_revid', None))
56
query = kw.get('q', None)
57
remember = kw.get('remember', None)
58
compare_revid = kw.get('compare_revid', None)
61
revid, start_revid, revid_list = h.get_view(revid, start_revid, filter_file_id, query)
63
self.log.exception('Exception fetching changes')
64
raise InternalError('Could not fetch changes')
66
navigation = util.Container(
67
revid_list=revid_list, revid=revid, start_revid=start_revid,
68
filter_file_id=filter_file_id, pagesize=1,
69
scan_url='/revision', branch=self._branch, feed=True)
71
navigation.query = query
72
util.fill_in_navigation(navigation)
74
change = h.get_change_with_diff(revid, compare_revid)
75
# add parent & merge-point branch-nick info, in case it's useful
76
h.get_branch_nicks([ change ])
78
line_count_limit = int(self._branch.get_config_item(
79
'line_count_limit', DEFAULT_LINE_COUNT_LIMIT))
81
for file in change.changes.modified:
82
for chunk in file.chunks:
83
line_count += len(chunk.diff)
85
# let's make side-by-side diff be the default
86
side_by_side = not kw.get('unified', False)
88
h.add_side_by_side([ change ])
91
'branch': self._branch,
94
'start_revid': start_revid,
95
'filter_file_id': filter_file_id,
98
'navigation': navigation,
100
'remember': remember,
101
'compare_revid': compare_revid,
102
'side_by_side': side_by_side,
103
'url': self._branch.context_url,
104
'line_count': line_count,
105
'line_count_limit': line_count_limit,
106
'show_plain_diffs': line_count > line_count_limit,
108
vals.update(templatefunctions)
109
self.log.info('/revision: %r seconds' % (time.time() - z,))
47
revid, start_revid, revid_list = h.get_view(revid, start_revid, filter_file_id, query)
49
self.log.exception('Exception fetching changes')
50
raise HTTPServerError('Could not fetch changes')
52
navigation = util.Container(
53
revid_list=revid_list, revid=revid, start_revid=start_revid,
54
filter_file_id=filter_file_id, pagesize=1,
55
scan_url='/revision', branch=self._branch, feed=True)
57
navigation.query = query
58
util.fill_in_navigation(navigation)
60
change = h.get_change_with_diff(revid, compare_revid)
61
# add parent & merge-point branch-nick info, in case it's useful
62
h.get_branch_nicks([ change ])
64
line_count_limit = DEFAULT_LINE_COUNT_LIMIT
66
for file in change.changes.modified:
67
for chunk in file.chunks:
68
line_count += len(chunk.diff)
70
# let's make side-by-side diff be the default
71
side_by_side = not kw.get('unified', False)
73
h.add_side_by_side([ change ])
76
'branch': self._branch,
79
'start_revid': start_revid,
80
'filter_file_id': filter_file_id,
83
'navigation': navigation,
86
'compare_revid': compare_revid,
87
'side_by_side': side_by_side,
88
'url': self._branch.context_url,
89
'line_count': line_count,
90
'line_count_limit': line_count_limit,
91
'show_plain_diffs': line_count > line_count_limit,