17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
from cherrypy import HTTPRedirect, session
20
from paste.httpexceptions import HTTPServerError
29
22
from loggerhead import util
32
class RevisionUI (object):
34
def __init__(self, branch):
39
@util.strip_whitespace
40
@turbogears.expose(html='loggerhead.templates.revision')
41
def default(self, *args, **kw):
43
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):
47
36
revid = h.fix_revid(args[0])
51
file_id = kw.get('file_id', None)
40
filter_file_id = kw.get('filter_file_id', None)
52
41
start_revid = h.fix_revid(kw.get('start_revid', None))
53
42
query = kw.get('q', None)
54
remember = kw.get('remember', None)
55
compare_revid = kw.get('compare_revid', None)
43
remember = h.fix_revid(kw.get('remember', None))
44
compare_revid = h.fix_revid(kw.get('compare_revid', None))
58
revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
60
self.log.error('Exception fetching changes: %s' % (x,))
61
util.log_exception(self.log)
62
raise HTTPRedirect(self._branch.url('/changes'))
64
navigation = util.Container(revid_list=revid_list, revid=revid, start_revid=start_revid, file_id=file_id,
65
pagesize=1, scan_url='/revision', branch=self._branch, feed=True)
47
revid, start_revid, revid_list = h.get_view(revid,
52
self.log.exception('Exception fetching changes')
53
raise HTTPServerError('Could not fetch changes')
55
navigation = util.Container(
56
revid_list=revid_list, revid=revid, start_revid=start_revid,
57
filter_file_id=filter_file_id, pagesize=1,
58
scan_url='/revision', branch=self._branch, feed=True, history=h)
66
59
if query is not None:
67
60
navigation.query = query
68
util.fill_in_navigation(h, navigation)
61
util.fill_in_navigation(navigation)
70
if compare_revid is not None:
71
change = h.get_diff(compare_revid, revid)
73
change = h.get_changes([ revid ], get_diffs=True)[0]
63
change = h.get_change_with_diff(revid, compare_revid)
74
64
# add parent & merge-point branch-nick info, in case it's useful
75
h.get_branch_nicks([ change ])
65
h.get_branch_nicks([change])
67
line_count_limit = DEFAULT_LINE_COUNT_LIMIT
69
for file in change.changes.modified:
70
for chunk in file.chunks:
71
line_count += len(chunk.diff)
77
73
# let's make side-by-side diff be the default
78
74
side_by_side = not kw.get('unified', False)
80
h.add_side_by_side([ change ])
76
h.add_side_by_side([change])
78
# Directory Breadcrumbs
79
directory_breadcrumbs = (
80
util.directory_breadcrumbs(
81
self._branch.friendly_name,
83
86
'branch': self._branch,
86
89
'start_revid': start_revid,
90
'filter_file_id': filter_file_id,
90
93
'navigation': navigation,