17
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
from cherrypy import InternalError
26
import json as simplejson
28
from paste.httpexceptions import HTTPServerError
25
30
from loggerhead import util
28
class ChangeLogUI (object):
30
def __init__(self, branch):
35
@util.strip_whitespace
36
@turbogears.expose(html='loggerhead.templates.changelog')
37
def default(self, *args, **kw):
39
h = self._branch.get_history()
40
config = self._branch.config
31
from loggerhead.controllers import TemplatedBranchView
34
class ChangeLogUI(TemplatedBranchView):
36
template_path = 'loggerhead.templates.changelog'
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))
44
orig_start_revid = start_revid
45
pagesize = 20#int(config.get('pagesize', '20'))
48
if filter_file_id is None and path is not None:
49
filter_file_id = history.get_file_id(revid, path)
45
revid = h.fix_revid(args[0])
52
revid, start_revid, revid_list = history.get_view(
53
revid, start_revid, filter_file_id, query)
54
util.set_context(kwargs)
56
if (query is not None) and (len(revid_list) == 0):
59
if len(revid_list) == 0:
60
scan_list = revid_list
49
filter_file_id = kw.get('filter_file_id', None)
50
query = kw.get('q', None)
51
start_revid = h.fix_revid(kw.get('start_revid', None))
52
orig_start_revid = start_revid
53
pagesize = int(config.get('pagesize', '20'))
57
revid, start_revid, revid_list = h.get_view(
58
revid, start_revid, filter_file_id, query)
59
kw['start_revid'] = start_revid
62
if (query is not None) and (len(revid_list) == 0):
65
if len(revid_list) == 0:
66
scan_list = revid_list
62
if revid in revid_list: # XXX is this always true?
63
i = revid_list.index(revid)
68
if revid in revid_list: # XXX is this always true?
69
i = revid_list.index(revid)
72
scan_list = revid_list[i:]
73
change_list = scan_list[:pagesize]
74
changes = list(h.get_changes(change_list))
75
h.add_changes(changes)
77
self.log.exception('Exception fetching changes')
78
raise InternalError('Could not fetch changes')
80
navigation = util.Container(
81
pagesize=pagesize, revid=revid, start_revid=start_revid,
82
revid_list=revid_list, filter_file_id=filter_file_id,
83
scan_url='/changes', branch=self._branch, feed=True)
85
navigation.query = query
86
util.fill_in_navigation(navigation)
88
# add parent & merge-point branch-nick info, in case it's useful
89
h.get_branch_nicks(changes)
91
# does every change on this page have the same committer? if so,
92
# tell the template to show committer info in the "details block"
93
# instead of on each line.
94
all_same_author = True
97
author = changes[0].author
99
if e.author != author:
100
all_same_author = False
104
'branch': self._branch,
109
'navigation': navigation,
110
'filter_file_id': filter_file_id,
111
'start_revid': start_revid,
112
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
114
'search_failed': search_failed,
115
'all_same_author': all_same_author,
118
self.log.info('/changes %r: %r secs' % (revid, time.time() - z))
66
scan_list = revid_list[i:]
67
change_list = scan_list[:pagesize]
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=''))
74
self.log.exception('Exception fetching changes')
75
raise HTTPServerError('Could not fetch changes')
77
navigation = util.Container(
78
pagesize=pagesize, revid=revid, start_revid=start_revid,
79
revid_list=revid_list, filter_file_id=filter_file_id,
80
scan_url='/changes', branch=self._branch, feed=True, history=history)
82
navigation.query = query
83
util.fill_in_navigation(navigation)
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:
99
'branch': self._branch,
101
'show_tag_col': show_tag_col,
102
'data': simplejson.dumps(data),
106
'navigation': navigation,
107
'filter_file_id': filter_file_id,
108
'start_revid': start_revid,
109
'viewing_from': (orig_start_revid is not None) and
110
(orig_start_revid != history.last_revid),
112
'search_failed': search_failed,
113
'url': self._branch.context_url,
114
'directory_breadcrumbs': directory_breadcrumbs,