#
#
# patch "branch.psp"
# from [bdf0c2d5dd84a1c60dc670e1250e74a1cecf5c02]
# to [94b37a6e8978165d126a8a2bd71c0844c7829c7d]
#
# patch "common.py"
# from [6fb10f24e4921c4e9dfa6baec980b8f927a218cd]
# to [3e098cfe3f45351c5862f0175255e9d73e0f870d]
#
# patch "index.psp"
# from [2ccf95edb24824d8b6c03ccad51bd981507348b7]
# to [9671dd9415d1dd7ed98368488aee060bde77cbe1]
#
# patch "revision.psp"
# from [af70805914c0a1615433e44a3a99019ecbb5acf5]
# to [0e977e36ee68e44e2afaed2409c966b40dafd854]
#
# patch "viewmtn.js"
# from [d81eac728f091a04c0de4f00de2a9edbf0171e19]
# to [6a12619346e525c61942361704f78173e55d3499]
#
# patch "wrapper.py"
# from [225e4f37f55a61876170a8da4cc1e35d4f792cab]
# to [6ec8f71424b4ca0780d9733ac5ce45c0fb771cd8]
#
============================================================
--- branch.psp bdf0c2d5dd84a1c60dc670e1250e74a1cecf5c02
+++ branch.psp 94b37a6e8978165d126a8a2bd71c0844c7829c7d
@@ -1,8 +1,9 @@
<%
import datetime
import config
import urllib
+import common
import time
from common import parse_timecert, ago_string
@@ -106,8 +107,7 @@
value = link("branch", value)
else:
if name == "changelog":
- quicklog = hq(value.strip().split('\n')[0])
- if quicklog.startswith('*'): quicklog = quicklog[1:].strip()
+ quicklog = common.quicklog(value)
if output == 'rss': req.write("\t
%s\n%s\n" % (quicklog, hq(value)))
elif name == "author":
if output == 'rss': req.write("\t%s\n" % (hq(value)))
============================================================
--- common.py 6fb10f24e4921c4e9dfa6baec980b8f927a218cd
+++ common.py 3e098cfe3f45351c5862f0175255e9d73e0f870d
@@ -17,17 +17,30 @@
def parse_timecert(value):
return apply(datetime.datetime, time.strptime(value, "%Y-%m-%dT%H:%M:%S")[:6])
-def determine_date(certs):
+def extract_cert_from_certs(certs, certname):
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
+ if name == certname:
+ return value
+def determine_date(certs):
+ dateval = extract_cert_from_certs(certs, "date")
+ if dateval == None:
+ return None
+ else:
+ return parse_timecert(dateval)
+
+def quicklog(value):
+ hq = html_escape()
+ rv = hq(value.strip().split('\n')[0])
+ if rv.startswith('*'):
+ rv = rv[1:].strip()
+ return rv
+
def ago_string(event, now):
def plural(v, singular, plural):
if v == 1:
@@ -75,7 +88,8 @@
rv += ''
elif link_type == "download":
if type(link_to) == type([]):
- rv = '' % (urllib.quote(link_to[0]), urllib.quote(link_to[1]))
+ rv = '' % (urllib.quote(link_to[0]),
+ urllib.quote(link_to[1]))
link_id = link_to[0]
else:
rv = '' % (urllib.quote(link_to))
@@ -84,7 +98,8 @@
else: rv = "[" + rv + hq(link_id[:8]) + ".." + "]"
elif link_type == "file":
revision_id, path = link_to
- rv = '' % (urllib.quote(revision_id), urllib.quote(path))
+ rv = '' % (urllib.quote(revision_id),
+ urllib.quote(path))
if description != None: rv += description + ""
else: rv = "[" + rv + hq(path + '@' + revision_id[:8]) + ".." + "]"
elif link_type == "branch":
============================================================
--- index.psp 2ccf95edb24824d8b6c03ccad51bd981507348b7
+++ index.psp 9671dd9415d1dd7ed98368488aee060bde77cbe1
@@ -1,9 +1,5 @@
<%
-import common
-from common import parse_timecert, ago_string, determine_date
-import datetime
-
psp.set_error_page("error.psp")
info = { 'title' : "Branches" }
req.write(template.header(info))
@@ -42,26 +38,8 @@
Branch |
<%
-# now = datetime.datetime.utcnow()
branches.sort()
for branch in branches:
-# RATS! mt.heads() requires running
-# an actual monotone process. which is just too
-# slow.
-#
-# 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 |
' % (link("branch", branch, branch)))
%>
============================================================
--- revision.psp af70805914c0a1615433e44a3a99019ecbb5acf5
+++ revision.psp 0e977e36ee68e44e2afaed2409c966b40dafd854
@@ -40,7 +40,6 @@
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)
============================================================
--- viewmtn.js d81eac728f091a04c0de4f00de2a9edbf0171e19
+++ viewmtn.js 6a12619346e525c61942361704f78173e55d3499
@@ -33,15 +33,13 @@
info = null;
if (jsonData.type == "branch") {
- info = "branch: ";
+ info = "branch last updated " + jsonData.ago + " by " + jsonData.author;
} else if (jsonData.type == "revision") {
- info = "revision: ";
+ info = jsonData.ago + " ago by " + jsonData.author;
+ } else {
+ info = "unknown type: " + jsonData.type;
}
- if (info == null) {
- info = "";
- }
-
newBox = DIV({ 'id' : 'popupBox'},
info);
@@ -75,8 +73,15 @@
return updatePopup(boundTo, className);
}
- // var uri = "META.json";
- var uri = "getjson.py?className=" + className;
+ links = getElementsByTagAndClassName('a', null, boundTo);
+
+ if (links.length > 0) {
+ linkHref = links[0].href;
+ } else {
+ return;
+ }
+
+ var uri = "getjson.py?className=" + encodeURIComponent(className) + "&linkUri=" + encodeURIComponent(linkHref);
var d = loadJSONDoc(uri);
d.addCallback(jsonLoadComplete, boundTo, className);
============================================================
--- wrapper.py 225e4f37f55a61876170a8da4cc1e35d4f792cab
+++ wrapper.py 6ec8f71424b4ca0780d9733ac5ce45c0fb771cd8
@@ -1,7 +1,10 @@
from mod_python import apache,psp,util
+from common import parse_timecert, ago_string, determine_date
import mimetypes
import monotone
+import urlparse
+import datetime
import os.path
import tarfile
import common
@@ -54,12 +57,51 @@
def get_json(req, vars):
mt = vars['mt']
form = util.FieldStorage(req)
- #if not form.has_key('class') or not form.has_key('for'):
- # return apache.HTTP_BAD_REQUEST
+ if not form.has_key('className') or not form.has_key('linkUri'):
+ return apache.HTTP_BAD_REQUEST
+ class_name, link_uri = form['className'], form['linkUri']
req.content_type = "text/plain"
writer = json.JsonWriter()
+ query = {}
+ for key, value in [t.split('=', 1) for t in urlparse.urlparse(link_uri)[4].split('&')]:
+ query[key] = value
+
+ now = datetime.datetime.utcnow()
rv = {}
- rv['type'] = 'branch'
+ if class_name == "revisionLink":
+ rv['type'] = 'revision'
+ certs = mt.certs(query['id'])
+ rv['author'] = common.extract_cert_from_certs(certs, 'author')
+ change_date = determine_date(certs)
+ if change_date != None:
+ ago = ago_string(change_date, now)
+ else:
+ ago = ''
+ rv['ago'] = ago
+ elif class_name == "branchLink":
+ rv['type'] = 'branch'
+ heads = mt.heads(query['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
+ most_recent_change_certs = certs
+
+ if most_recent_change != None:
+ ago = ago_string(most_recent_change, now) + ' ago'
+ last_author = common.extract_cert_from_certs(most_recent_change_certs,
+ "author") or ''
+ else:
+ ago = ''
+
+ rv['ago'] = ago
+ rv['author'] = last_author
+
+ rv['hint'] = query
req.write(writer.write(rv))
return apache.OK