# # # add_file "branch.psp" # content [d31efaaf929acc45cccc088e8642179febabd73a] # ============================================================ --- branch.psp d31efaaf929acc45cccc088e8642179febabd73a +++ branch.psp d31efaaf929acc45cccc088e8642179febabd73a @@ -0,0 +1,95 @@ +<% + +import datetime +import config +import time +from common import link + +# +# branch.psp +# display a log of changes on a given branch, with an +# optional offset +# + +psp.set_error_page("error.psp") + +def prettify(s): + return ' '.join(map(lambda x: hq(x[0].upper() + x[1:]), s.replace("_", " ").split(" "))) + +if not form.has_key('branch'): + raise Exception("No branch specified.") + +page = 1 +if form.has_key('page'): + try: page = int(form['page']) + except: pass + +if page < 1: page = 1 + +display = 10 +offset = page * display + +branch = form['branch'] +info = {'title' : "Recent changes to branch %s" % (hq(branch))} +req.write(template.header(info)) + +heads = mt.heads(branch) + +recent = mt.toposort(mt.ancestors(heads) + heads) + +if display > len(recent): display = len(recent) +if offset > len(recent): offset = len(recent) - display + +start = -1*offset +stop = start + display +if stop == 0: stop = None +recent = recent[start:stop] +recent.reverse() + +req.write('') +for idx, id in enumerate(recent): + certs = mt.certs(id) + + changelog, certdate, quicklog, certinfo = None, None, "", "" + for cert in certs: + name, value = None, None + for k, v in cert: + if k == "name": name = v + elif k == "value": value = v + if name == None or value == None: continue + if name == "date": + certdate = apply(datetime.datetime, time.strptime(value, "%Y-%m-%dT%H:%M:%S")[:6]) + if name == "branch": + value = link("branch", value) + else: + if name == "changelog": quicklog = hq(value.strip().split('\n')[0]) + value = '
'.join(map(hq, value.split('\n'))) + certinfo += '\n' % (prettify(name), value) + + now = datetime.datetime.utcnow() + ago = now - certdate + if ago.days > 0: + ago = "%d days, %d hours" % (ago.days, ago.seconds / 3600) + elif ago.seconds > 3600: + hours = ago.seconds / 3600 + minutes = (ago.seconds - (hours * 3600)) / 60 + ago = "%d hours, %d minutes" % (hours, minutes) + else: + minutes = ago.seconds / 60 + seconds = (ago.seconds - (minutes * 60)) + ago = "%d minutes, %d seconds" % (minutes, seconds) + style = "font-size: 130%%; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: black;" + if idx != 0: + style += "border-top-style: solid; border-top-width: 1px; border-top-color: black;" + req.write('\n' % (style, ago, quicklog, link("revision", id, "more info"))) + req.write(certinfo) +req.write('
%s:%s
%s ago: %s (%s)
') + +%> + +<% + +req.write(template.footer(info)) + +%> +