Bug 67935

Summary: webkit-patch should add reviewer if "Reviewed by NOBODY (OOPS!)." is missing
Product: WebKit Reporter: Csaba Osztrogonác <ossy>
Component: Tools / TestsAssignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, abecsi, bank, dpranke, eric, galpeter, kkristof, ojan, ossy, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 89605    
Bug Blocks:    
Attachments:
Description Flags
proposed fix
abarth: review-
proposed fix
none
proposed fix
none
proposed fix
none
proposed fix
none
proposed fix
none
proposed fix
rniwa: review+, rniwa: commit-queue-
proposed fix
none
Patch
none
proposed fix none

Description Csaba Osztrogonác 2011-09-12 07:57:59 PDT
http://trac.webkit.org/changeset/94955

It was an r+ -ed patch, but "Reviewed by NOBODY (OOPS!)." line 
was deleted from the patch accidentally and webkit-patch didn't 
add the name of the reviewer to the changelog and commit log.

It would be great if webkit-patch can handle this situation.
Comment 1 Balazs Ankes 2012-05-11 08:49:46 PDT
Created attachment 141425 [details]
proposed fix

This modification do the same just send a boolean value if the reviewer was set and handle it.
Comment 2 Rafael Brandao 2012-05-11 09:09:47 PDT
Comment on attachment 141425 [details]
proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=141425&action=review

Just an informal review.

> Tools/Scripts/webkitpy/common/checkout/changelog.py:345
> +        founded_reviewer = re.search(".*NOBODY\s*\(OOPS!\).*", latest_entry, re.MULTILINE)

English typo, it should be "found" not "founded".
Also, you look for the pattern "NOBODY (OOPS!)" and if you find it, you add the reviewer name. How is this going to fix what has been proposed on bug title?

> Tools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py:72
> +            has_been_set = ChangeLog(changelog_path).set_reviewer(reviewer)

Name is weird. What has been set? Also, it doesn't look natural that a function called "set_reviewer" also returns something.
Comment 3 Adam Barth 2012-05-11 09:57:26 PDT
Comment on attachment 141425 [details]
proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=141425&action=review

Changes to webkitpy require unit tests.  Both changelog.py and updatechangelogswithreviewer.py have unit tests that should be easy to extend to test this change.

> Tools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py:75
> +                if not self._tool.user.confirm("Do you want to continue?", default="n"):

Do we need to check the --non-interactive option before prompting the user?

> Tools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py:76
> +                        self._exit(1)

Is this the proper way to exist, or should we call error() ?
Comment 4 Adam Barth 2012-05-11 09:57:42 PDT
Likely Eric should review this change.
Comment 5 Eric Seidel (no email) 2012-05-11 11:42:41 PDT
Comment on attachment 141425 [details]
proposed fix

The change does not appear to do what it claims to in the bug title. :)
Comment 6 Balazs Ankes 2012-05-14 06:12:14 PDT
(In reply to comment #5)
> (From update of attachment 141425 [details])
> The change does not appear to do what it claims to in the bug title. :)

You're right, Ossy and I discussed it and we concluded that the script should only inform the user about the issue because it's not clear where should put the "Reviewed by NOBODY (OOPS!)." line from code.
Comment 7 Adam Barth 2012-05-14 11:07:36 PDT
> You're right, Ossy and I discussed it and we concluded that the script should only inform the user about the issue because it's not clear where should put the "Reviewed by NOBODY (OOPS!)." line from code.

Why not just put it after the first blank line after the bug URL?
Comment 8 Balazs Ankes 2012-05-16 06:18:42 PDT
Created attachment 142238 [details]
proposed fix

Now it does what the bug title says.
Comment 9 Eric Seidel (no email) 2012-05-16 12:52:28 PDT
Comment on attachment 142238 [details]
proposed fix

This needs tests. :(
Comment 10 Balazs Ankes 2012-05-17 06:52:02 PDT
Created attachment 142465 [details]
proposed fix

Here is the test.
I had to make 2 type from _new_entry_boilerplate because the set_reviewer function looks for bug url, but I had to keep the original _new_entry_boilerplate because the preparechangelog_unittest.py uses it.
Comment 11 Balazs Ankes 2012-06-14 05:46:06 PDT
Created attachment 147564 [details]
proposed fix

I updated the patch. Could somebody check it, please?
Comment 12 Ryosuke Niwa 2012-06-14 10:50:19 PDT
Comment on attachment 147564 [details]
proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=147564&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:365
> +                if found_bug_url and latest_entry:
> +                    print "\n        Reviewed by " + reviewer.encode("utf-8") + "."
> +                    latest_entry = False

People sometimes list multiple bug URLs so you'll probably need to account for that.
To detect the second entry, you can use date_line_regexp instead.
Comment 13 Peter Gal 2012-06-14 10:53:52 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=147564&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:348
> +        latest_entry = self.latest_entry()._contents

Didn't you wanted to use the .contents() method instead of the _contents? It is marked as non-public, we should honor the conventions.

> Tools/Scripts/webkitpy/common/checkout/changelog.py:349
> +        found_reviewer = re.search(".*NOBODY\s*\(OOPS!\).*", latest_entry, re.MULTILINE)

hmm.. do we really need the '.*' parts? It should work without those.

> Tools/Scripts/webkitpy/common/checkout/changelog.py:357
> +            latest_entry = True

Do you really wanted to name this the same as above? Maybe this should be renamed to describe its purpose better.

> Tools/Scripts/webkitpy/common/checkout/changelog.py:364
> +                    print "\n        Reviewed by " + reviewer.encode("utf-8") + "."

I think it'll be better to use the % operator to format strings (or .format)
Comment 14 Balazs Ankes 2012-06-15 09:46:12 PDT
Created attachment 147839 [details]
proposed fix

Improved patch based on comments.
Comment 15 Peter Gal 2012-06-18 04:13:48 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=147839&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:350
> +        bug_url_regexp = 'https://bugs.webkit.org/show_bug.cgi\?id='

This url is already present in the config_urls which is imported at the top. Also what if someone uses a short url for the bug?

> Tools/Scripts/webkitpy/common/checkout/changelog.py:366
> +                    bug_url_number -= 1
> +                elif found_bug_url:
> +                    bug_url_number -= 1

If you always decrement the counter, then there is no need to put it in both cases. Simply put it after the 'if' block.
Comment 16 Balazs Ankes 2012-06-18 06:44:57 PDT
Created attachment 148090 [details]
proposed fix

Update based on comment.
Comment 17 Peter Gal 2012-06-18 07:18:09 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=148090&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:358
> +            bug_url_number = len(re.findall(config_urls.bug_url_long, latest_entry, re.MULTILINE))
> +            bug_url_number += len(re.findall(config_urls.bug_url_short, latest_entry, re.MULTILINE))

Could we use a more descriptive name?

> Tools/Scripts/webkitpy/common/checkout/changelog.py:367
> +                if found_bug_url and bug_url_number == 1:
> +                    print "\n        Reviewed by %s." % (reviewer.encode("utf-8"))
> +                if found_bug_url:
> +                    bug_url_number -= 1

Ok, now I see what you wanted. So use something like this:
if found...:
    if bug_num.. == 1:
        print ...
    bug_num...
Comment 18 Balazs Ankes 2012-06-18 08:15:35 PDT
Created attachment 148102 [details]
proposed fix
Comment 19 Ryosuke Niwa 2012-06-19 00:59:03 PDT
Comment on attachment 148102 [details]
proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=148102&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:358
> +            bug_url_number_of_items = len(re.findall(config_urls.bug_url_long, latest_entry, re.MULTILINE))
> +            bug_url_number_of_items += len(re.findall(config_urls.bug_url_short, latest_entry, re.MULTILINE))

Please add a test case when we have multiple bug URLs before you land.
Comment 20 Ryosuke Niwa 2012-06-19 00:59:30 PDT
(In reply to comment #19)
> (From update of attachment 148102 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=148102&action=review
> 
> > Tools/Scripts/webkitpy/common/checkout/changelog.py:358
> > +            bug_url_number_of_items = len(re.findall(config_urls.bug_url_long, latest_entry, re.MULTILINE))
> > +            bug_url_number_of_items += len(re.findall(config_urls.bug_url_short, latest_entry, re.MULTILINE))
> 
> Please add a test case when we have multiple bug URLs before you land.

Ugh... I meant to say, please add a test case for having multiple bug URLs.
Comment 21 Balazs Ankes 2012-06-19 06:46:31 PDT
Created attachment 148323 [details]
proposed fix

Added the test case.
Comment 22 WebKit Review Bot 2012-06-19 20:29:16 PDT
Comment on attachment 148323 [details]
proposed fix

Rejecting attachment 148323 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 1

ERROR: /mnt/git/webkit-commit-queue/Tools/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).

Full output: http://queues.webkit.org/results/13006065
Comment 23 Csaba Osztrogonác 2012-06-20 08:07:21 PDT
Comment on attachment 148323 [details]
proposed fix

Landed manually - http://trac.webkit.org/changeset/120821
Comment 24 WebKit Review Bot 2012-06-20 14:50:36 PDT
Re-opened since this is blocked by 89605
Comment 25 Csaba Osztrogonác 2012-06-20 14:59:27 PDT
It made some duplicated reviwer entries:
- http://trac.webkit.org/changeset/120859
- http://trac.webkit.org/changeset/120863
- http://trac.webkit.org/changeset/120864
- http://trac.webkit.org/changeset/120865

We should guarantee somehow that the replace run only once. It seems it
replaced the "reviewed by nobody" string first, and on the second run 
it inserted reviewer again, because it can't find "reviewed by nobody".
Comment 26 Csaba Osztrogonác 2012-06-20 15:03:56 PDT
Julien told me that the problem is with webkit-patch apply-attachment + webkit-patch land combo. It is absolutely believable. apply-attachment
replace "the reviewed by nobody" line and land insert one more, because
it can't find. I think the new line should be added if it can't find
"the reviewed by nobody" line _and_ reviewed by isn't added already.
Comment 27 Csaba Osztrogonác 2012-06-20 15:05:40 PDT
Rolled out by http://trac.webkit.org/changeset/120867 .
Comment 28 Adam Barth 2012-06-20 18:26:43 PDT
"webkit-patch land" is supposed to work even on fully filed out ChangeLogs.
Comment 29 Ryosuke Niwa 2012-06-20 19:16:47 PDT
It appears that we shouldn't run this code in webkit-patch.
Comment 30 Adam Barth 2012-06-20 19:27:06 PDT
(In reply to comment #29)
> It appears that we shouldn't run this code in webkit-patch.

Can't we just check whether there's already a reviewer listed?
Comment 31 Ryosuke Niwa 2012-06-20 19:32:04 PDT
(In reply to comment #30)
> (In reply to comment #29)
> > It appears that we shouldn't run this code in webkit-patch.
> 
> Can't we just check whether there's already a reviewer listed?

Maybe but it's quite tricky to find out whether there's "reviewed by" line or not because people can get creative. e.g. Rubber-stamped by, etc...
Comment 32 Csaba Osztrogonác 2012-06-20 23:11:31 PDT
The problem is the following: webkit-patch apply-attachment and apply-from-bug 
commands uses Tools/Script/svn-apply perl script to apply the patch and add 
reviewer name with its --reviewer option. And then webkit-patch land uses
common/checkout/changelog.py to add reviewer's name again. It doesn't find "reviewed by nobody, oops", so it adds the reviewer line again.
Comment 33 Csaba Osztrogonác 2012-06-26 02:50:06 PDT
Created attachment 149498 [details]
Patch

Fixed patch. (Balázs isn't online now, but he asked me to upload his updated patch.
Comment 34 Csaba Osztrogonác 2012-06-26 03:05:03 PDT
Comment on attachment 149498 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149498&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:352
> +        (reviewer_text, reviewer_list) = ChangeLogEntry._parse_reviewer_text(latest_entry)
> +
> +        if not found_nobody and not reviewer_text:

Here is one more check to avoid adding one more "Reviewed by" line.
Comment 35 Peter Gal 2012-06-26 05:01:46 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=149498&action=review

> Tools/Scripts/webkitpy/common/checkout/changelog.py:350
> +        (reviewer_text, reviewer_list) = ChangeLogEntry._parse_reviewer_text(latest_entry)

It's not really nice to call a method which is marked az private. Also, the latest_entry() returns the last ChangeLogEntry and then you pass it back to the ChangeLogEntry to parse it?
Comment 36 Balazs Ankes 2012-07-04 09:25:00 PDT
Created attachment 150814 [details]
proposed fix

I hope it will be finally good :)
Comment 37 Ryosuke Niwa 2012-07-04 13:57:29 PDT
Comment on attachment 150814 [details]
proposed fix

Alright, let's give a shot.
Comment 38 WebKit Review Bot 2012-07-04 15:41:33 PDT
Comment on attachment 150814 [details]
proposed fix

Clearing flags on attachment: 150814

Committed r121873: <http://trac.webkit.org/changeset/121873>
Comment 39 WebKit Review Bot 2012-07-04 15:41:40 PDT
All reviewed patches have been landed.  Closing bug.