17
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
from cherrypy import InternalError, session
25
from paste.httpexceptions import HTTPServerError
26
27
from loggerhead import util
29
class ChangeLogUI (object):
31
def __init__(self, branch):
36
@util.strip_whitespace
37
@turbogears.expose(html='loggerhead.templates.changelog')
38
def default(self, *args, **kw):
40
h = self._branch.get_history()
41
config = self._branch.config
44
revid = h.fix_revid(args[0])
48
file_id = kw.get('file_id', None)
49
query = kw.get('q', None)
50
start_revid = h.fix_revid(kw.get('start_revid', None))
28
from loggerhead.controllers import TemplatedBranchView
31
class ChangeLogUI(TemplatedBranchView):
33
template_path = 'loggerhead.templates.changelog'
35
def get_values(self, path, kwargs, headers):
36
history = self._history
37
revid = self.get_revid()
38
filter_file_id = kwargs.get('filter_file_id', None)
39
query = kwargs.get('q', None)
40
start_revid = history.fix_revid(kwargs.get('start_revid', None))
51
41
orig_start_revid = start_revid
52
pagesize = int(config.get('pagesize', '20'))
42
pagesize = 20#int(config.get('pagesize', '20'))
53
43
search_failed = False
45
if filter_file_id is None and path is not None:
46
filter_file_id = history.get_file_id(revid, path)
56
revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
57
kw['start_revid'] = start_revid
49
revid, start_revid, revid_list = history.get_view(
50
revid, start_revid, filter_file_id, query,
51
extra_rev_count=pagesize+1)
52
util.set_context(kwargs)
60
54
if (query is not None) and (len(revid_list) == 0):
61
55
search_failed = True
63
57
if len(revid_list) == 0:
64
58
scan_list = revid_list
66
scan_list = revid_list[h.get_revid_sequence(revid_list, revid):]
67
entry_list = scan_list[:pagesize]
68
entries = h.get_changes(entry_list)
60
if revid in revid_list: # XXX is this always true?
61
i = revid_list.index(revid)
64
scan_list = revid_list[i:]
65
change_list = scan_list[:pagesize]
66
changes = list(history.get_changes(change_list))
68
for i, c in enumerate(changes):
70
data[str(i)] = urllib.quote(urllib.quote(c.revid, safe=''))
70
72
self.log.exception('Exception fetching changes')
71
raise InternalError('Could not fetch changes')
73
raise HTTPServerError('Could not fetch changes')
73
navigation = util.Container(pagesize=pagesize, revid=revid, start_revid=start_revid, revid_list=revid_list,
74
file_id=file_id, scan_url='/changes', branch=self._branch, feed=True)
75
navigation = util.Container(
76
pagesize=pagesize, revid=revid, start_revid=start_revid,
77
revid_list=revid_list, filter_file_id=filter_file_id,
78
scan_url='/changes', branch=self._branch, feed=True, history=history)
75
79
if query is not None:
76
80
navigation.query = query
77
util.fill_in_navigation(h, navigation)
79
entries = list(entries)
80
# add parent & merge-point branch-nick info, in case it's useful
81
h.get_branch_nicks(entries)
81
util.fill_in_navigation(navigation)
83
# Directory Breadcrumbs
84
directory_breadcrumbs = (
85
util.directory_breadcrumbs(
86
self._branch.friendly_name,
91
for change in changes:
92
if change.tags is not None:
84
97
'branch': self._branch,
85
'changes': list(entries),
99
'show_tag_col': show_tag_col,
100
'data': simplejson.dumps(data),
89
104
'navigation': navigation,
105
'filter_file_id': filter_file_id,
91
106
'start_revid': start_revid,
92
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
107
'viewing_from': (orig_start_revid is not None) and
108
(orig_start_revid != history.last_revid),
94
110
'search_failed': search_failed,
111
'url': self._branch.context_url,
112
'directory_breadcrumbs': directory_breadcrumbs,
97
self.log.info('/changes %r: %r secs' % (revid, time.time() - z))