2703: --guess-summary doesn't work when summary has newline characters in it

Alexande*********@gmai***** (Google Code) (Is this you? Claim this profile.)
Oct. 7, 2012
What version are you running?
RBTools 0.4.1
Review Board 1.6.9
Mercurial Distributed SCM (version 2.2.1)

What's the URL of the page containing the problem?


What steps will reproduce the problem?
1. Commit Mercurial change with newline character in commit message.
2. invoke post-review -p --revision-range=tip --guess-summary

What is the expected output? 

Review request #11440 posted.

What do you see instead?

Error creating review request: One or more fields had errors (HTTP 400, API Error 105)



What operating system are you using? What browser?

Windows 7 x64


Please provide any additional information below.

When I run it with -d option I get the following output:

>>> RBTools 0.4.1
>>> Home = C:\Users\username\AppData\Roaming
>>> HTTP GETting api/
>>> HTTP GETting http://server.address.company.com/api/info/
>>> Using the new web API
>>> Attempting to create review request on 337 for None
>>> HTTP POSTing to http://server.address.company.com/api/review-requests/: {'repository': 337}
>>> Review request created
>>> Attempting to set field 'target_people' to 'name' for review request '11442'
>>> HTTP PUTting to http://server.address.company.com/api/review-requests/11442/draft/: {'target_people': 'name'}
>>> Attempting to set field 'summary' to 'Product: Added new feature.
' for review request '11442'
>>> HTTP PUTting to http://server.address.company.com/api/review-requests/11442/draft/: {'summary': 'Product: Added new feature.\n'}
>>> Got API Error 105 (HTTP code 400): One or more fields had errors
>>> Error data: {u'fields': {u'summary': [u'Summary cannot contain newlines']}, u'stat': u'fail', u'draft': {u'last_updated': u'2012-08-13 05:15:09', u'description': u'', u'links': {u'self': {u'href':
 u'http://server.address.company.com/api/review-requests/11442/draft/', u'method': u'GET'}, u'update': {u'href': u'http://server.address.company.com/api/review-requests/11442/draft/', u'method': u'PUT'}, u'draft_
screenshots': {u'href': u'http://server.address.company.com/api/review-requests/11442/draft/screenshots/', u'method': u'GET'}, u'draft_file_attachments': {u'href': u'http://server.address.company.com/api/review-r
equests/11442/draft/file-attachments/', u'method': u'GET'}, u'review_request': {u'href': u'http://server.address.company.com/api/review-requests/11442/', u'method': u'GET', u'title': u'(no summary)'}, u'del
ete': {u'href': u'http://server.address.company.com/api/review-requests/11442/draft/', u'method': u'DELETE'}}, u'changedescription': u'', u'target_groups': [], u'bugs_closed': [], u'target_people': [{u'href
': u'http://server.address.company.com/api/users/name/', u'method': u'GET', u'title': u'name'}], u'testing_done': u'', u'branch': u'', u'id': 15005, u'summary': u'', u'public': False}, u'err': {u'msg': u'
One or more fields had errors', u'code': 105}}
Error creating review request: One or more fields had errors (HTTP 400, API Error 105)
#1 Alexande*********@gmai***** (Google Code) (Is this you? Claim this profile.)
I propose the attached fix.
  • +
    From 1864b260c116c59a93a70f4d35eddc50e4e88003 Mon Sep 17 00:00:00 2001
    From: Alexander Kouznetsov <Alexander.Minolta@gmail.com>
    Date: Sep 27, 2012 1:21:00 PM
    Fix for --guess-summary doesn't work when summary has newline characters in it
    http://code.google.com/p/reviewboard/issues/detail?id=2703
    diff --git a/rbtools/clients/mercurial.py b/rbtools/clients/mercurial.py
    index 17f305c..57f421f 100644
    --- a/rbtools/clients/mercurial.py
    +++ b/rbtools/clients/mercurial.py
    @@ -157,8 +157,8 @@
                 parent = self.options.parent_branch
     
             if self.options.guess_summary and not self.options.summary:
    -            self.options.summary = self.extract_summary(".")
    -
    +            self.options.summary = self.extract_summary(".").replace('\n', ' ')
    +			
             if self.options.guess_description and not self.options.description:
                 self.options.description = self.extract_description(parent, ".")
     
    @@ -214,8 +214,8 @@
                 bottom_rev = None
     
             if self.options.gu
chipx86
#2 chipx86
Can you post your patch on http://reviews.reviewboard.org/ ?
  • +Confirmed
  • +Component-RBTools
david
#3 david
Pushed to master (423b9bb). Thanks!
  • -Confirmed
    +Fixed