#
#
# patch "common.py"
# from [8f2e9062393d27695011b09ddcde0e3d9277ded6]
# to [d2ea6fa516f36b77496097ec0efbc5844339b44d]
#
# patch "index.psp"
# from [6d0099247d31734a99caa03b8d2ac24acc034582]
# to [9c84eaaaa428a2ab700152993e3e12bb12cd2fa0]
#
# patch "tags.psp"
# from [bff6e85ed6a20a5de381d3cb2a6e60f48e51141c]
# to [7b81023a3fbf60ce0ed258d7c9b9086b233e4e8d]
#
============================================================
--- common.py 8f2e9062393d27695011b09ddcde0e3d9277ded6
+++ common.py d2ea6fa516f36b77496097ec0efbc5844339b44d
@@ -17,28 +17,40 @@
def parse_timecert(value):
return apply(datetime.datetime, time.strptime(value, "%Y-%m-%dT%H:%M:%S")[:6])
+def determine_date(certs):
+ 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":
+ return parse_timecert(value)
+ return None
+
def ago_string(event, now):
+ def plural(v, singular, plural):
+ if v == 1:
+ return "%d %s" % (v, singular)
+ else:
+ return "%d %s" % (v, plural)
now = datetime.datetime.utcnow()
ago = now - event
if ago.days > 0:
- ago = "%d days, %d hours" % (ago.days, ago.seconds / 3600)
+ rv = "%s, %s" % (plural(ago.days, "day", "days"),
+ plural(ago.seconds / 3600, "hour", "hours"))
elif ago.seconds > 3600:
hours = ago.seconds / 3600
minutes = (ago.seconds - (hours * 3600)) / 60
- ago = "%d hours, %d minutes" % (hours, minutes)
+ rv = "%s, %s" % (plural(hours, "hour", "hours"),
+ plural(minutes, "minute", "minutes"))
else:
minutes = ago.seconds / 60
seconds = (ago.seconds - (minutes * 60))
- ago = "%d minutes, %d seconds" % (minutes, seconds)
- return ago
+ rv = "%s, %s" % (plural(minutes, "minute", "minutes"),
+ plural(seconds, "second", "seconds"))
+ return rv
-#
-# FIXME
-#
-# make these links use the mt instance (stricly Automate only)
-# to add extra information when the user hovers on a link
-#
-
def link(mt, link_type, link_to, description = None, no_quote = False):
hq = html_escape()
if not no_quote and description != None: description = hq(description)
============================================================
--- index.psp 6d0099247d31734a99caa03b8d2ac24acc034582
+++ index.psp 9c84eaaaa428a2ab700152993e3e12bb12cd2fa0
@@ -1,6 +1,8 @@
<%
import common
+from common import parse_timecert, ago_string, determine_date
+import datetime
psp.set_error_page("error.psp")
info = { 'title' : "Branches" }
@@ -38,11 +40,25 @@
-Branch |
+Branch | Last update |
<%
+ now = datetime.datetime.utcnow()
branches.sort()
for branch in branches:
- req.write('%s |
' % (link("branch", branch, branch)))
+ heads = mt.heads(branch)
+ most_recent_change = None
+ for head in heads:
+ certs = mt.certs(head)
+ this_change = determine_date(certs)
+ if this_change == None:
+ continue
+ if most_recent_change == None or this_change > most_recent_change:
+ most_recent_change = this_change
+ if most_recent_change != None:
+ ago = ago_string(most_recent_change, now) + ' ago'
+ else:
+ ago = ''
+ req.write('%s | %s |
' % (link("branch", branch, branch), hq(ago)))
%>
============================================================
--- tags.psp bff6e85ed6a20a5de381d3cb2a6e60f48e51141c
+++ tags.psp 7b81023a3fbf60ce0ed258d7c9b9086b233e4e8d
@@ -1,6 +1,6 @@
<%
-from common import parse_timecert, ago_string
+from common import parse_timecert, ago_string, determine_date
import datetime
psp.set_error_page("error.psp")
@@ -31,22 +31,17 @@
Tag | Signed by | When |
<%
+ now = datetime.datetime.utcnow()
tags.sort(lambda x,y: cmp(x[0], y[0]))
for tag in tags:
tag_name, tag_id, signed_by = tag
certs = mt.certs(tag_id)
- ago = 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":
- event = parse_timecert(value)
- now = datetime.datetime.utcnow()
- ago = ago_string(event, now)
- req.write('%s | %s | %s ago |
' % \
+ ago = determine_date(certs)
+ if ago != None:
+ ago = ago_string(ago, now) + " ago"
+ else:
+ ago = ""
+ req.write('%s | %s | %s |
' % \
(link("revision", tag_id, tag_name),
hq(signed_by),
hq(ago or "")))