hooks: use commitparser.py to find reviewers in prevent_webidl_changes.py (bug 1358608) r?gps draft
authorWes Kocher <wkocher@mozilla.com>
Mon, 25 Sep 2017 17:30:47 -0700
changeset 11714 29cfffbf9ce00c7e7df18f8d237a4c7152a8fda1
parent 11707 6a20a18a2d58b167d2180f6604866b4149bba5c2
push id1803
push userbmo:wkocher@mozilla.com
push dateWed, 27 Sep 2017 05:42:36 +0000
reviewersgps
bugs1358608
hooks: use commitparser.py to find reviewers in prevent_webidl_changes.py (bug 1358608) r?gps MozReview-Commit-ID: 8KWd1CMOG0N
hghooks/mozhghooks/prevent_webidl_changes.py
--- a/hghooks/mozhghooks/prevent_webidl_changes.py
+++ b/hghooks/mozhghooks/prevent_webidl_changes.py
@@ -18,16 +18,18 @@
 This hook is to prevent changes to files with strict review requirements in pushes
 without proper peer review.
 """
 
 import re
 from mercurial.node import short
 from mercurial import util
 
+from mozautomation import commitparser
+
 backoutMessage = [re.compile(x) for x in [
     r'^(back(ing|ed)?\s+out|backout)',
     r'^(revert(ed|ing)?)'
 ]]
 
 def isBackout(message):
     for r in backoutMessage:
         if r.search(message):
@@ -128,17 +130,17 @@ def hook(ui, repo, hooktype, node, sourc
             message = c.description().lower()
             email = util.email(c.user()).lower()
 
             # Ignore backouts
             if isBackout(message):
                 continue
 
             def search(authors, peers):
-              matches = re.findall('\Ws?r\s*=\s*(\w+(?:,\w+)*)', message)
+              matches = list(commitparser.parse_requal_reviewers(message))
               for match in matches:
                   if any(reviewer in peers for reviewer in match.split(',')):
                       return True
               # We allow peers to commit changes without any review
               # requirements assuming that they have looked at the changes
               # they're committing.
               if any(peer == email for peer in authors):
                   return True