17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
from cherrypy import InternalError, session
20
from paste.httpexceptions import HTTPServerError
29
22
from loggerhead import util
32
class RevisionUI (object):
34
def __init__(self, branch):
40
@util.strip_whitespace
41
@turbogears.expose(html='loggerhead.templates.revision')
42
def default(self, *args, **kw):
44
h = self._branch.get_history()
23
from loggerhead.controllers import TemplatedBranchView
26
DEFAULT_LINE_COUNT_LIMIT = 3000
29
class RevisionUI(TemplatedBranchView):
31
template_path = 'loggerhead.templates.revision'
33
def get_values(self, h, args, kw, headers):
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
file_id = kw.get('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, file_id, query)
63
self.log.exception('Exception fetching changes')
64
raise InternalError('Could not fetch changes')
66
navigation = util.Container(revid_list=revid_list, revid=revid, start_revid=start_revid, file_id=file_id,
67
pagesize=1, scan_url='/revision', branch=self._branch, feed=True)
69
navigation.query = query
70
util.fill_in_navigation(navigation)
72
change = h.get_change_with_diff(revid, compare_revid)
73
# add parent & merge-point branch-nick info, in case it's useful
74
h.get_branch_nicks([ change ])
76
# let's make side-by-side diff be the default
77
side_by_side = not kw.get('unified', False)
79
h.add_side_by_side([ change ])
82
'branch': self._branch,
85
'start_revid': start_revid,
89
'navigation': navigation,
92
'compare_revid': compare_revid,
93
'side_by_side': side_by_side,
96
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, history=h)
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,