--- a/review/api.py Fri Jul 09 22:32:17 2010 -0400
+++ b/review/api.py Fri Jul 09 22:46:09 2010 -0400
@@ -4,7 +4,7 @@
import base64, datetime, operator, os
import messages
-from util import fromlocal
+from rutil import fromlocal
from mercurial import cmdutil, error, hg, patch, util
from mercurial.node import hex
from mercurial import ui as _ui
--- a/review/cli.py Fri Jul 09 22:32:17 2010 -0400
+++ b/review/cli.py Fri Jul 09 22:46:09 2010 -0400
@@ -6,7 +6,7 @@
"""
import api, helps, messages
-from util import fromlocal, tolocal
+from rutil import fromlocal, tolocal
from mercurial import help, templatefilters, util
from mercurial.node import short
@@ -245,7 +245,7 @@
ui.write(header, label=label)
for line in signoff.message.splitlines():
- ui.write(messages.REVIEW_LOG_SIGNOFF_LINE % line, label=label)
+ ui.write(messages.REVIEW_LOG_SIGNOFF_LINE % tolocal(line), label=label)
ui.write(after)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/rutil.py Fri Jul 09 22:46:09 2010 -0400
@@ -0,0 +1,8 @@
+from mercurial import encoding
+
+def tolocal(s):
+ return encoding.tolocal(s.encode('UTF-8'))
+
+def fromlocal(s):
+ return encoding.fromlocal(s).decode('UTF-8')
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/tests/test_encoding.py Fri Jul 09 22:46:09 2010 -0400
@@ -0,0 +1,25 @@
+# coding=utf-8
+#
+import os
+
+from nose import with_setup
+from util import setup_reviewed_sandbox, teardown_sandbox, review, should_fail_with
+from util import get_datastore_repo, get_sandbox_repo, get_ui
+from util import check_comment_exists_on_line
+
+from .. import api, messages, rutil
+
+from mercurial.node import hex
+
+
+@with_setup(setup_reviewed_sandbox, teardown_sandbox)
+def test_comment_encoding():
+ review(comment=True, message=rutil.tolocal(u'Téstíng.'))
+ output = review()
+ assert messages.REVIEW_LOG_COMMENT_LINE % rutil.tolocal(u'Téstíng.') in output
+
+@with_setup(setup_reviewed_sandbox, teardown_sandbox)
+def test_signoff_encoding():
+ review(signoff=True, message=rutil.tolocal(u'Téstíng.'))
+ output = review()
+ assert messages.REVIEW_LOG_SIGNOFF_LINE % rutil.tolocal(u'Téstíng.') in output
--- a/review/util.py Fri Jul 09 22:32:17 2010 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-from mercurial import encoding
-
-def tolocal(s):
- return encoding.tolocal(s.encode('UTF-8'))
-
-def fromlocal(s):
- return encoding.fromlocal(s).decode('UTF-8')
-
--- a/review/web.py Fri Jul 09 22:32:17 2010 -0400
+++ b/review/web.py Fri Jul 09 22:46:09 2010 -0400
@@ -118,12 +118,15 @@
body = request.form.get('new-signoff-body', '')
style = 'markdown' if request.form.get('signoff-markdown') else ''
- current = request.form.get('current')
- if current:
- g.datastore.edit_signoff(current, body, signoff, style=style)
- else:
- rcset = g.datastore[revhash]
- rcset.add_signoff(body, signoff, style=style)
+ try:
+ current = request.form.get('current')
+ if current:
+ g.datastore.edit_signoff(current, body, signoff, style=style)
+ else:
+ rcset = g.datastore[revhash]
+ rcset.add_signoff(body, signoff, style=style)
+ except error.RepoLookupError:
+ abort(404)
return redirect("%s/changeset/%s/" % (app.site_root, revhash))
@@ -139,13 +142,16 @@
body = request.form['new-comment-body']
style = 'markdown' if request.form.get('comment-markdown') else ''
- if body:
- current = request.form.get('current')
- if current:
- g.datastore.edit_comment(current, body, ufilename, filename, lines, style)
- else:
- rcset = g.datastore[revhash]
- rcset.add_comment(body, ufilename, filename, lines, style)
+ try:
+ if body:
+ current = request.form.get('current')
+ if current:
+ g.datastore.edit_comment(current, body, ufilename, filename, lines, style)
+ else:
+ rcset = g.datastore[revhash]
+ rcset.add_comment(body, ufilename, filename, lines, style)
+ except error.RepoLookupError:
+ abort(404)
return redirect("%s/changeset/%s/" % (app.site_root, revhash))
@@ -178,7 +184,10 @@
@app.route('/changeset/<revhash>/patch/')
def patch(revhash):
result = StringIO.StringIO()
- cmdutil.export(g.datastore.target, [revhash], fp=result)
+ try:
+ cmdutil.export(g.datastore.target, [revhash], fp=result)
+ except error.RepoLookupError:
+ abort(404)
return Response(result.getvalue(), content_type="text/plain")
@app.route('/pull/', methods=['POST'])