--- a/contrib/deploy/wsgi.py Sat Jul 03 16:18:48 2010 -0400
+++ b/contrib/deploy/wsgi.py Mon Jul 05 22:04:18 2010 -0400
@@ -17,7 +17,7 @@
from review.web import app
_ui = ui.ui()
-_ui.setconfig('ui', 'user', ANON_USER)
+_ui.setconfig('ui', 'username', ANON_USER)
repo = hg.repository(_ui, REPO)
app.read_only = READ_ONLY
--- a/fabfile.py Sat Jul 03 16:18:48 2010 -0400
+++ b/fabfile.py Mon Jul 05 22:04:18 2010 -0400
@@ -1,4 +1,5 @@
from __future__ import with_statement
+import os
from fabric.api import *
@@ -10,6 +11,7 @@
def deploy():
run('hg -R %s pull' % env.data_repo)
+ run('hg -R %s pull --update' % os.path.join(env.data_repo, '.hg', 'review'))
run('hg -R %s pull --update' % env.tool_repo)
sudo('supervisorctl restart %s' % env.supervisord_program)
--- a/review/api.py Sat Jul 03 16:18:48 2010 -0400
+++ b/review/api.py Mon Jul 05 22:04:18 2010 -0400
@@ -30,6 +30,12 @@
return join(*rel_list)
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+
DEFAULT_DATASTORE_DIRNAME = os.path.join('.hg', 'review')
class PreexistingDatastore(Exception):
@@ -138,14 +144,16 @@
def _parse_data(data):
"""Parse the data (string) of a stored _ReviewObject and return a dict."""
- meta, _, message = data.partition('\n\n')
+ result = {}
+ for k, v in json.loads(data).iteritems():
+ result[k.encode('UTF-8')] = v
- data = {}
- for m in meta.split('\n'):
- label, _, val = m.partition(':')
- data[label] = val
- data['message'] = message
- return data
+ if u'filename' in result:
+ result['filename'] = result['filename'].encode('UTF-8')
+ result['node'] = result['node'].encode('UTF-8')
+ result['style'] = result['style'].encode('UTF-8')
+
+ return result
def _datetime_from_hgdate(hgdate):
"""Return a datetime.datetime for the given Mecurial-style date tuple.
@@ -283,9 +291,9 @@
def get_items(self, identifier):
"""Return the comments and signoffs which match the given identifier.
-
+
WARNING: This is going to be slow. Send patches.
-
+
"""
rcsets = self.reviewed_changesets()
comments = _flatten_filter(rcset.comments for rcset in rcsets)
@@ -391,8 +399,6 @@
self.comments = []
for fn in commentfns:
data = _parse_data(self.repo['tip'][fn].data())
- data['lines'] = data['lines'].split(',')
- data['lines'] = map(int, filter(None, data['lines']))
data['hgdate'] = util.parsedate(data['hgdate'])
data['identifier'] = _split_path_dammit(fn)[-1]
self.comments.append(ReviewComment(**data))
@@ -826,10 +832,11 @@
of a ReviewChangeset will handle it for you.
"""
- rendered_date = util.datestr(self.hgdate)
- lines = ','.join(map(str, self.lines))
- return files.COMMENT_FILE_TEMPLATE % ( self.author, rendered_date,
- self.node, self.filename, lines, self.style, self.message )
+ return json.dumps({ 'author': self.author, 'node': self.node,
+ 'hgdate': util.datestr(self.hgdate),
+ 'filename': self.filename, 'lines': self.lines,
+ 'style': self.style, 'message': self.message
+ }, indent=4, sort_keys=True)
def __str__(self):
"""Stringify this comment for easy printing (for debugging)."""
@@ -906,8 +913,10 @@
of a ReviewChangeset will handle it for you.
"""
- rendered_date = util.datestr(self.hgdate)
- return files.SIGNOFF_FILE_TEMPLATE % ( self.author, rendered_date,
- self.node, self.opinion, self.style, self.message )
+ return json.dumps({ 'author': self.author, 'node': self.node,
+ 'hgdate': util.datestr(self.hgdate),
+ 'opinion': self.opinion, 'style': self.style,
+ 'message': self.message,
+ }, indent=4, sort_keys=True)
--- a/review/cli.py Sat Jul 03 16:18:48 2010 -0400
+++ b/review/cli.py Mon Jul 05 22:04:18 2010 -0400
@@ -37,7 +37,7 @@
if not message:
message = comment.message
-
+
if not fnames:
fnames = [comment.filename]
else:
@@ -62,7 +62,7 @@
if not message:
message = signoff.message
-
+
style = 'markdown' if mdown or signoff.style == 'markdown' else ''
rd.edit_signoff(signoff.identifier, message, opinion, style)
@@ -112,7 +112,7 @@
raise util.Abort(messages.COMMENT_LINES_REQUIRE_FILE)
if lines:
- lines = lines.split(',')
+ lines = map(int, lines.split(','))
fnames = map(lambda f: api.sanitize_path(f, repo), fnames) if fnames else ['']
@@ -284,7 +284,7 @@
for comment in line['comments']:
_print_comment(comment)
continue
-
+
ui.write('%s ' % (prefix % line['number']))
if line['content'].startswith('+'):
ui.write('%s\n' % line['content'], label='diff.inserted')
@@ -300,7 +300,7 @@
# TODO: require -f to delete some else's item
force = opts.pop('force')
rd = _get_datastore(ui, repo)
-
+
if not identifiers:
raise util.Abort(messages.REQUIRES_IDS)