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
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'))
26
from loggerhead.templatefunctions import templatefunctions
29
class ChangeLogUI (object):
31
def __init__(self, branch):
36
@util.strip_whitespace
37
@turbogears.expose(html='zpt:loggerhead.templates.changelog')
38
def default(self, *args, **kw):
40
h = self._branch.get_history()
41
config = self._branch.config
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
46
revid = h.fix_revid(args[0])
54
if revid in revid_list: # XXX is this always true?
55
i = revid_list.index(revid)
50
filter_file_id = kw.get('filter_file_id', None)
51
query = kw.get('q', None)
52
start_revid = h.fix_revid(kw.get('start_revid', None))
53
orig_start_revid = start_revid
54
pagesize = int(config.get('pagesize', '20'))
58
revid, start_revid, revid_list = h.get_view(
59
revid, start_revid, filter_file_id, query)
60
kw['start_revid'] = start_revid
63
if (query is not None) and (len(revid_list) == 0):
66
if len(revid_list) == 0:
67
scan_list = revid_list
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
89
# Directory Breadcrumbs
90
directory_breadcrumbs = (
91
util.directory_breadcrumbs(
92
self._branch.friendly_name,
97
'branch': self._branch,
102
'navigation': navigation,
103
'filter_file_id': filter_file_id,
104
'start_revid': start_revid,
105
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
107
'search_failed': search_failed,
108
'all_same_author': all_same_author,
109
'url': self._branch.context_url,
110
'directory_breadcrumbs': directory_breadcrumbs,
69
if revid in revid_list: # XXX is this always true?
70
i = revid_list.index(revid)
73
scan_list = revid_list[i:]
74
change_list = scan_list[:pagesize]
75
changes = list(h.get_changes(change_list))
76
h.add_changes(changes)
78
self.log.exception('Exception fetching changes')
79
raise InternalError('Could not fetch changes')
81
navigation = util.Container(
82
pagesize=pagesize, revid=revid, start_revid=start_revid,
83
revid_list=revid_list, filter_file_id=filter_file_id,
84
scan_url='/changes', branch=self._branch, feed=True)
86
navigation.query = query
87
util.fill_in_navigation(navigation)
89
# add parent & merge-point branch-nick info, in case it's useful
90
h.get_branch_nicks(changes)
92
# does every change on this page have the same committer? if so,
93
# tell the template to show committer info in the "details block"
94
# instead of on each line.
95
all_same_author = True
98
author = changes[0].author
100
if e.author != author:
101
all_same_author = False
104
def url(pathargs, **kw):
105
return self._branch.url(pathargs, **util.get_context(**kw))
108
'branch': self._branch,
113
'navigation': navigation,
114
'filter_file_id': filter_file_id,
115
'start_revid': start_revid,
116
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
118
'search_failed': search_failed,
119
'all_same_author': all_same_author,
120
'url': self._branch.context_url,
122
vals.update(templatefunctions)
123
self.log.info('/changes %r: %r secs' % (revid, time.time() - z))