17
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
import json as simplejson
20
28
from paste.httpexceptions import HTTPServerError
22
30
from loggerhead import util
28
36
template_path = 'loggerhead.templates.changelog'
30
def get_values(self, h, args, kw, response):
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))
38
def get_values(self, path, kwargs, headers):
39
history = self._history
40
revid = self.get_revid()
41
filter_file_id = kwargs.get('filter_file_id', None)
42
query = kwargs.get('q', None)
43
start_revid = history.fix_revid(kwargs.get('start_revid', None))
39
44
orig_start_revid = start_revid
40
45
pagesize = 20#int(config.get('pagesize', '20'))
41
46
search_failed = False
48
if filter_file_id is None and path is not None:
49
filter_file_id = history.get_file_id(revid, path)
44
revid, start_revid, revid_list = h.get_view(
52
revid, start_revid, revid_list = history.get_view(
45
53
revid, start_revid, filter_file_id, query)
54
util.set_context(kwargs)
48
56
if (query is not None) and (len(revid_list) == 0):
49
57
search_failed = True
58
66
scan_list = revid_list[i:]
59
67
change_list = scan_list[:pagesize]
60
changes = list(h.get_changes(change_list))
61
h.add_changes(changes)
68
changes = list(history.get_changes(change_list))
70
for i, c in enumerate(changes):
72
data[str(i)] = urllib.quote(urllib.quote(c.revid, safe=''))
63
74
self.log.exception('Exception fetching changes')
64
75
raise HTTPServerError('Could not fetch changes')
66
77
navigation = util.Container(
67
78
pagesize=pagesize, revid=revid, start_revid=start_revid,
68
79
revid_list=revid_list, filter_file_id=filter_file_id,
69
scan_url='/changes', branch=self._branch, feed=True)
80
scan_url='/changes', branch=self._branch, feed=True, history=history)
70
81
if query is not None:
71
82
navigation.query = query
72
83
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
85
# Directory Breadcrumbs
86
directory_breadcrumbs = (
87
util.directory_breadcrumbs(
88
self._branch.friendly_name,
93
for change in changes:
94
if change.tags is not None:
90
99
'branch': self._branch,
91
100
'changes': changes,
101
'show_tag_col': show_tag_col,
102
'data': simplejson.dumps(data),
95
106
'navigation': navigation,
96
107
'filter_file_id': filter_file_id,
97
108
'start_revid': start_revid,
98
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
109
'viewing_from': (orig_start_revid is not None) and
110
(orig_start_revid != history.last_revid),
100
112
'search_failed': search_failed,
101
'all_same_author': all_same_author,
102
113
'url': self._branch.context_url,
114
'directory_breadcrumbs': directory_breadcrumbs,