17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
from cherrypy import HTTPRedirect, session
24
from cherrypy import InternalError, session
29
26
from loggerhead import util
31
log = logging.getLogger("loggerhead.controllers")
34
# just thinking out loud here...
36
# so, when browsing around, there are 3 pieces of context:
38
# the current beginning of navigation (navigation continues back to
39
# the original revision) -- this may not be along the primary revision
40
# path since the user may have navigated into a branch
42
# if navigating the revisions that touched a file
44
# current location along the navigation path (while browsing)
46
# current revid is given on the url path. 'file_id' and 'starting revid' are
47
# handed along as params.
50
29
class ChangeLogUI (object):
31
def __init__(self, branch):
36
@util.strip_whitespace
52
37
@turbogears.expose(html='loggerhead.templates.changelog')
53
38
def default(self, *args, **kw):
55
h = util.get_history()
40
h = self._branch.get_history()
41
config = self._branch.config
58
44
revid = h.fix_revid(args[0])
62
48
file_id = kw.get('file_id', None)
49
query = kw.get('q', None)
63
50
start_revid = h.fix_revid(kw.get('start_revid', None))
64
pagesize = int(util.get_config().get('pagesize', '20'))
51
orig_start_revid = start_revid
52
pagesize = int(config.get('pagesize', '20'))
67
revlist, start_revid = h.get_navigation(start_revid, file_id)
70
if revid not in revlist:
71
# if the given revid is not in the revlist, use a revlist that
72
# starts at the given revid.
73
revlist, start_revid = h.get_navigation(revid, file_id)
74
entry_list = list(h.get_revids_from(revlist, revid))[:pagesize]
56
revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
57
kw['start_revid'] = start_revid
60
if (query is not None) and (len(revid_list) == 0):
63
if len(revid_list) == 0:
64
scan_list = revid_list
66
scan_list = revid_list[h.get_revid_sequence(revid_list, revid):]
67
entry_list = scan_list[:pagesize]
75
68
entries = h.get_changes(entry_list)
77
log.error('Exception fetching changes: %r, %s' % (x, x))
78
raise HTTPRedirect(turbogears.url('/changes'))
70
self.log.exception('Exception fetching changes')
71
raise InternalError('Could not fetch changes')
80
navigation = util.Container(pagesize=pagesize, revid=revid, start_revid=start_revid, revlist=revlist,
81
file_id=file_id, scan_url='/changes', feed=True)
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)
76
navigation.query = query
82
77
util.fill_in_navigation(h, navigation)
84
79
entries = list(entries)
86
81
h.get_branch_nicks(entries)
89
'branch_name': util.get_config().get('branch_name'),
84
'branch': self._branch,
90
85
'changes': list(entries),
94
89
'navigation': navigation,
95
90
'file_id': file_id,
96
'last_revid': h.last_revid,
97
91
'start_revid': start_revid,
92
'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
94
'search_failed': search_failed,
100
log.info('/changes %r: %r secs' % (revid, time.time() - z))
97
self.log.info('/changes %r: %r secs' % (revid, time.time() - z))