17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from paste.httpexceptions import HTTPServerError
23
from cherrypy import InternalError
22
25
from loggerhead import util
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, revid, path, kwargs, headers):
35
filter_file_id = kwargs.get('filter_file_id', None)
36
start_revid = h.fix_revid(kwargs.get('start_revid', None))
37
query = kwargs.get('q', None)
38
remember = h.fix_revid(kwargs.get('remember', None))
39
compare_revid = h.fix_revid(kwargs.get('compare_revid', None))
28
class RevisionUI (object):
30
def __init__(self, branch):
36
@util.strip_whitespace
37
@turbogears.expose(html='loggerhead.templates.revision')
38
def default(self, *args, **kw):
40
h = self._branch.get_history()
42
revid, start_revid, revid_list = h.get_view(revid,
47
self.log.exception('Exception fetching changes')
48
raise HTTPServerError('Could not fetch changes')
50
navigation = util.Container(
51
revid_list=revid_list, revid=revid, start_revid=start_revid,
52
filter_file_id=filter_file_id, pagesize=1,
53
scan_url='/revision', branch=self._branch, feed=True, history=h)
55
navigation.query = query
56
util.fill_in_navigation(navigation)
58
change = h.get_change_with_diff(revid, compare_revid)
59
# add parent & merge-point branch-nick info, in case it's useful
60
h.get_branch_nicks([change])
62
line_count_limit = DEFAULT_LINE_COUNT_LIMIT
64
for file in change.changes.modified:
65
for chunk in file.chunks:
66
line_count += len(chunk.diff)
68
# let's make side-by-side diff be the default
69
# FIXME: not currently in use. Should be
70
side_by_side = not kwargs.get('unified', False)
72
h.add_side_by_side([change])
74
# Directory Breadcrumbs
75
directory_breadcrumbs = (
76
util.directory_breadcrumbs(
77
self._branch.friendly_name,
82
'branch': self._branch,
85
'start_revid': start_revid,
86
'filter_file_id': filter_file_id,
89
'navigation': navigation,
92
'compare_revid': compare_revid,
93
'side_by_side': side_by_side,
94
'url': self._branch.context_url,
95
'line_count': line_count,
96
'line_count_limit': line_count_limit,
97
'show_plain_diffs': line_count > line_count_limit,
98
'directory_breadcrumbs': directory_breadcrumbs,
46
revid = h.fix_revid(args[0])
50
file_id = kw.get('file_id', None)
51
start_revid = h.fix_revid(kw.get('start_revid', None))
52
query = kw.get('q', None)
53
remember = kw.get('remember', None)
54
compare_revid = kw.get('compare_revid', None)
57
revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
59
self.log.exception('Exception fetching changes')
60
raise InternalError('Could not fetch changes')
62
navigation = util.Container(revid_list=revid_list, revid=revid, start_revid=start_revid, file_id=file_id,
63
pagesize=1, scan_url='/revision', branch=self._branch, feed=True)
65
navigation.query = query
66
util.fill_in_navigation(navigation)
68
change = h.get_change_with_diff(revid, compare_revid)
69
# add parent & merge-point branch-nick info, in case it's useful
70
h.get_branch_nicks([ change ])
72
# let's make side-by-side diff be the default
73
side_by_side = not kw.get('unified', False)
75
h.add_side_by_side([ change ])
78
'branch': self._branch,
81
'start_revid': start_revid,
85
'navigation': navigation,
88
'compare_revid': compare_revid,
89
'side_by_side': side_by_side,
92
self.log.info('/revision: %r seconds' % (time.time() - z,))