17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
20
from paste.httpexceptions import HTTPServerError
23
from paste.request import path_info_pop
25
22
from loggerhead import util
26
from loggerhead.templatefunctions import templatefunctions
27
from loggerhead.zptsupport import load_template
31
class ChangeLogUI (object):
33
def __init__(self, branch):
38
def default(self, request, response):
40
h = self._branch.history
41
#config = self._branch.config
23
from loggerhead.controllers import TemplatedBranchView
26
class ChangeLogUI(TemplatedBranchView):
28
template_path = 'loggerhead.templates.changelog'
30
def get_values(self, h, args, kw, headers):
32
revid = h.fix_revid(args[0])
36
filter_file_id = kw.get('filter_file_id', None)
37
query = kw.get('q', None)
38
start_revid = h.fix_revid(kw.get('start_revid', None))
39
orig_start_revid = start_revid
40
pagesize = 20#int(config.get('pagesize', '20'))
46
arg = path_info_pop(request.environ)
48
revid = h.fix_revid(arg)
44
revid, start_revid, revid_list = h.get_view(
45
revid, start_revid, filter_file_id, query)
48
if (query is not None) and (len(revid_list) == 0):
51
if len(revid_list) == 0:
52
scan_list = revid_list
52
filter_file_id = kw.get('filter_file_id', None)
53
query = kw.get('q', None)
54
start_revid = h.fix_revid(kw.get('start_revid', None))
55
orig_start_revid = start_revid
56
pagesize = 20#int(config.get('pagesize', '20'))
60
revid, start_revid, revid_list = h.get_view(
61
revid, start_revid, filter_file_id, query)
64
if (query is not None) and (len(revid_list) == 0):
67
if len(revid_list) == 0:
68
scan_list = revid_list
54
if revid in revid_list: # XXX is this always true?
55
i = revid_list.index(revid)
70
if revid in revid_list: # XXX is this always true?
71
i = revid_list.index(revid)
74
scan_list = revid_list[i:]
75
change_list = scan_list[:pagesize]
76
changes = list(h.get_changes(change_list))
77
h.add_changes(changes)
79
self.log.exception('Exception fetching changes')
80
raise HTTPServerError('Could not fetch changes')
82
navigation = util.Container(
83
pagesize=pagesize, revid=revid, start_revid=start_revid,
84
revid_list=revid_list, filter_file_id=filter_file_id,
85
scan_url='/changes', branch=self._branch, feed=True)
87
navigation.query = query
88
util.fill_in_navigation(navigation)
90
# add parent & merge-point branch-nick info, in case it's useful
91
h.get_branch_nicks(changes)
93
# does every change on this page have the same committer? if so,
94
# tell the template to show committer info in the "details block"
95
# instead of on each line.
96
all_same_author = True
99
author = changes[0].author
100
for e in changes[1:]:
101
if e.author != author:
102
all_same_author = False
105
def url(pathargs, **kw):
106
return self._branch.url(pathargs, **kw)
109
'branch': self._branch,
114
'navigation': navigation,
115
'filter_file_id': filter_file_id,
116
'start_revid': start_revid,
117
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
119
'search_failed': search_failed,
120
'all_same_author': all_same_author,
121
'url': self._branch.context_url,
123
vals.update(templatefunctions)
124
self.log.info('/changes %r: %r secs' % (revid, time.time() - z))
125
response.headers['Content-Type'] = 'text/html'
126
template = load_template('loggerhead.templates.changelog')
127
template.expand_into(response, **vals)
58
scan_list = revid_list[i:]
59
change_list = scan_list[:pagesize]
60
changes = list(h.get_changes(change_list))
61
h.add_changes(changes)
63
self.log.exception('Exception fetching changes')
64
raise HTTPServerError('Could not fetch changes')
66
navigation = util.Container(
67
pagesize=pagesize, revid=revid, start_revid=start_revid,
68
revid_list=revid_list, filter_file_id=filter_file_id,
69
scan_url='/changes', branch=self._branch, feed=True, history=h)
71
navigation.query = query
72
util.fill_in_navigation(navigation)
74
# add parent & merge-point branch-nick info, in case it's useful
75
h.get_branch_nicks(changes)
77
# does every change on this page have the same committer? if so,
78
# tell the template to show committer info in the "details block"
79
# instead of on each line.
80
all_same_author = True
83
author = changes[0].author
85
if e.author != author:
86
all_same_author = False
90
'branch': self._branch,
95
'navigation': navigation,
96
'filter_file_id': filter_file_id,
97
'start_revid': start_revid,
98
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
100
'search_failed': search_failed,
101
'all_same_author': all_same_author,
102
'url': self._branch.context_url,