mozreview: provide error msg when reviewer with emoji blocks reviews (
bug 1243343); r=mars
MozReview can't process the error message from Bugzilla when user blocks
reviews and has an emoji character in the name field.
Instead of str() we need to use unicode().
MozReview-Commit-ID: FoPBv9NLrEI
--- a/hgext/reviewboard/hgrb/proto.py
+++ b/hgext/reviewboard/hgrb/proto.py
@@ -467,17 +467,17 @@ def _processpublishreview(repo, req):
for rrid in req.get('rrids', []):
try:
rr = root.get_review_request(review_request_id=rrid)
draft = rr.get_draft()
draft.update(public=True)
res['results'].append({'rrid': rrid, 'success': True})
except APIError as e:
- res['results'].append({'rrid': rrid, 'error': str(e)})
+ res['results'].append({'rrid': rrid, 'error': unicode(e)})
return res
@wireproto.wireprotocommand('listreviewrepos')
def listreviewrepos(repo, proto, args=None):
"""List review repositories we can push to.
new file mode 100644
--- /dev/null
+++ b/hgext/reviewboard/tests/test-reviewer-unicode.t
@@ -0,0 +1,80 @@
+#require mozreviewdocker
+
+ $ . $TESTDIR/hgext/reviewboard/tests/helpers.sh
+ $ commonenv
+
+Create a bug
+
+ $ bugzilla create-bug TestProduct TestComponent 'First Bug'
+
+Create an initial commit.
+
+ $ cd client
+ $ echo foo > foo
+ $ hg commit -A -m 'root commit'
+ adding foo
+ $ hg phase --public -r .
+
+Adding a reviewer with emoji in name string
+
+ $ exportbzauth admin@example.com password
+ $ bugzilla create-user uni@example.com password 'Emoji here ⌚️ :uni'
+ /Users/zalun/Projects/CONDUIT/vct-pushingerror/version-control-tools/venv/lib/python2.7/site-packages/mach/dispatcher.py:103: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
+ elif '-h' in args or '--help' in args:
+ created user 6
+ $ exportbzauth default@example.com password
+ $ echo foo2 > foo
+ $ hg commit -m 'Bug 1 - awesome stuff; r?uni'
+ $ hg push
+ pushing to ssh://$DOCKER_HOSTNAME:$HGPORT6/test-repo
+ (adding commit id to 1 changesets)
+ saved backup bundle to $TESTTMP/client/.hg/strip-backup/9d48a700b5eb-316206f4-addcommitid.hg (glob)
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 2 changesets with 2 changes to 1 files
+ remote: recorded push in pushlog
+ submitting 1 changesets for review
+
+ changeset: 1:63b694541f47
+ summary: Bug 1 - awesome stuff; r?uni
+ review: http://$DOCKER_HOSTNAME:$HGPORT1/r/2 (draft)
+
+ review id: bz://1/mynick
+ review url: http://$DOCKER_HOSTNAME:$HGPORT1/r/1 (draft)
+
+ publish these review requests now (Yn)? y
+ (published review request 1)
+
+Adding a reviewer with emoji in name string who is not accepting reviews
+
+ $ mozreview exec bmoweb /var/lib/bugzilla/bugzilla/scripts/user-prefs.pl uni@example.com set block_reviews on
+ 'block_reviews' set to 'on'
+ $ echo foo3 > foo
+ $ hg commit -m 'Bug 1 - awesome stuff again; r?uni'
+ $ hg push
+ pushing to ssh://$DOCKER_HOSTNAME:$HGPORT6/test-repo
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 1 changesets with 1 changes to 1 files
+ remote: recorded push in pushlog
+ submitting 2 changesets for review
+
+ changeset: 1:63b694541f47
+ summary: Bug 1 - awesome stuff; r?uni
+ review: http://$DOCKER_HOSTNAME:$HGPORT1/r/2
+
+ changeset: 2:7f8eef10433f
+ summary: Bug 1 - awesome stuff again; r?uni
+ review: http://$DOCKER_HOSTNAME:$HGPORT1/r/3 (draft)
+
+ review id: bz://1/mynick
+ review url: http://$DOCKER_HOSTNAME:$HGPORT1/r/1 (draft)
+
+ publish these review requests now (Yn)? y
+ error publishing review request 1: Error publishing: Bugzilla error: Emoji here ?? :uni <uni@example.com> is not currently accepting 'review' requests. (HTTP 500, API Error 225)
+ (review requests not published; visit review url to attempt publishing there)
+