#
#
# patch "branch.psp"
# from [108c313ba4eea9134a05b39de84d38b89492522b]
# to [bdf0c2d5dd84a1c60dc670e1250e74a1cecf5c02]
#
# patch "common.py"
# from [e8e82ca9c5ed76b31f076d37c83a9baf87d91ed8]
# to [8f2e9062393d27695011b09ddcde0e3d9277ded6]
#
# patch "diff.psp"
# from [5ecbb7f72740996923bedbd99d320455d8454b15]
# to [4c495def64a5c64f8da213eaa870663f859b404e]
#
# patch "revision.psp"
# from [8b65ca428414125f517b6a0332d04ef450541bcc]
# to [af70805914c0a1615433e44a3a99019ecbb5acf5]
#
============================================================
--- branch.psp 108c313ba4eea9134a05b39de84d38b89492522b
+++ branch.psp bdf0c2d5dd84a1c60dc670e1250e74a1cecf5c02
@@ -1,9 +1,10 @@
<%
import datetime
import config
import urllib
import time
+from common import parse_timecert, ago_string
#
# branch.psp
@@ -99,7 +100,7 @@
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])
+ certdate = parse_timecert(value)
if output == 'rss': req.write("\t%s\n" % hq(certdate.strftime("%a, %d %b %Y %H:%M:%S +0000")))
elif name == "branch":
value = link("branch", value)
@@ -114,17 +115,7 @@
certinfo += '
%s: | %s |
\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)
+ ago = ago_string(certdate, now)
if output == 'html':
style = "border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: black;"
============================================================
--- common.py e8e82ca9c5ed76b31f076d37c83a9baf87d91ed8
+++ common.py 8f2e9062393d27695011b09ddcde0e3d9277ded6
@@ -1,6 +1,8 @@
+import datetime
import urllib
import pydoc
+import time
escape_function = pydoc.HTMLRepr().escape
@@ -12,6 +14,24 @@
else:
return e(x)
+def parse_timecert(value):
+ return apply(datetime.datetime, time.strptime(value, "%Y-%m-%dT%H:%M:%S")[:6])
+
+def ago_string(event, now):
+ now = datetime.datetime.utcnow()
+ ago = now - event
+ 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)
+ return ago
+
#
# FIXME
#
@@ -30,7 +50,7 @@
if description == None: rv = '[' + rv + ']'
return rv
elif link_type == "diff" or link_type == "download_diff":
- link_to = map(urllib.quote, link_to)
+ link_to = map(urllib.quote, filter(lambda x: x != None, link_to))
if link_type == "diff":
handler = "diff.psp"
else:
============================================================
--- diff.psp 5ecbb7f72740996923bedbd99d320455d8454b15
+++ diff.psp 4c495def64a5c64f8da213eaa870663f859b404e
@@ -31,8 +31,10 @@
fname = form.get('fname', None)
if fname != None:
title = 'of file %s ' % hq(fname)
+ files = [fname]
else:
title = ''
+ files = []
title = 'Diff %sbetween revisions [%s..] and [%s..]' % (title, hq(id1[:8]), hq(id2[:8]))
@@ -55,7 +57,7 @@
### FIXME FIXME
### this means having _the entire file_ in memory
### which is pointless and dumb.
-contents = mt.diff(id1, id2, [fname])
+contents = mt.diff(id1, id2, files)
colourise_code(req, hq, 'a.diff', contents, filter='diffu')
req.write(template.footer(info))
============================================================
--- revision.psp 8b65ca428414125f517b6a0332d04ef450541bcc
+++ revision.psp af70805914c0a1615433e44a3a99019ecbb5acf5
@@ -1,9 +1,11 @@
<%
import config
import monotone
+import datetime
import common
import urllib
+from common import parse_timecert, ago_string
#
# revision.psp
@@ -30,9 +32,15 @@
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)
+ value += '\n' + ago + ' ago'
if name == "branch":
branches.append(value)
value = link("branch", value)
+
else:
value = '
'.join(map(hq, value.split('\n')))
cert_table += '%s | %s |
' % (prettify(name), value)