Bug 1032531 - Change the webidl hook to allow commits authored by a DOM reviewer; r=ted
--- a/hghooks/mozhghooks/prevent_webidl_changes.py
+++ b/hghooks/mozhghooks/prevent_webidl_changes.py
@@ -15,16 +15,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
This hook is to prevent changes to .webidl files in pushes without proper DOM peer review.
"""
import re
from mercurial.node import short
+from mercurial import util
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:
@@ -42,16 +43,29 @@ def hook(ui, repo, hooktype, node, **kwa
'bent', # Ben Turner
'mounir', # Mounir Lamouri
'khuey', # Kyle Huey
'jlebar', # Justin Lebar
'hsivonen', # Henri Sivonen
'mrbkap', # Blake Kaplan
'bholley', # Bobby Holley
]
+ DOM_authors = [
+ 'jst@mozilla.com', # Johnny Stenback
+ 'peterv@propagandism.org', # Peter Van der Beken
+ 'bzbarsky@mit.edu', # Boris Zbarsky
+ 'jonas@sicking.cc', # Jonas Sicking
+ 'olli.pettay@helsinki.fi', # Olli Pettay
+ 'bent.mozilla@gmail.com', # Ben Turner
+ 'mounir@lamouri.fr', # Mounir Lamouri
+ 'khuey@kylehuey.com', # Kyle Huey
+ 'justin.lebar@gmail.com', # Justin Lebar
+ 'hsivonen@hsivonen.fi', # Henri Sivonen
+ 'mrbkap@gmail.com', # Blake Kaplan
+ ]
error = ""
webidlReviewed = False
changesets = list(repo.changelog.revs(repo[node].rev()))
if 'a=release' in repo.changectx(changesets[-1]).description().lower():
# Accept the entire push for code uplifts.
return 0
# Loop through each changeset being added to the repository
for i in reversed(changesets):
@@ -61,22 +75,28 @@ def hook(ui, repo, hooktype, node, **kwa
# Skip merge changesets
continue
# Loop through each file for the current changeset
for file in c.files():
# Only Check WebIDL Files
if file.endswith('.webidl'):
message = c.description().lower()
+ email = util.email(c.user())
def search():
matches = re.findall('\Ws?r\s*=\s*(\w+(?:,\w+)*)', message)
for match in matches:
for reviewer in match.split(','):
if reviewer in DOM_peers:
return True
+ # We allow DOM peers to commit changes to WebIDL files without any review
+ # requirements assuming that they have looked at the changes they're committing.
+ for peer in DOM_authors:
+ if peer == email:
+ return True
return False
webidlReviewed = search()
if not webidlReviewed and not isBackout(message):
error += "WebIDL file %s altered in changeset %s without DOM peer review\n" % (file, short(c.node()))
# Check if an error occured in any of the files that were changed
if error != "":
print "\n\n************************** ERROR ****************************"
ui.warn("\n" + error + "\n")
--- a/hghooks/runtests.py
+++ b/hghooks/runtests.py
@@ -903,16 +903,24 @@ class TestPreventWebIDLHook(unittest.Tes
def testWebIDLEditWithoutProperReviewShouldFail(self):
""" Test that editing .webidl file without proper DOM peer review should fail """
u = self.ui
editFile(join(self.clonedir, "original.webidl"), "interface Foo{};", "interface Bar{};")
commit(u, self.clonerepo, message="checkin 1 bug 12345; r=foobar")
self.assertRaises(util.Abort, push, u, self.clonerepo, dest=self.repodir)
+ def testWebIDLEditWithoutReviewFromDOMPeerShouldPass(self):
+ """ Test that editing .webidl file by DOM peers without review should pass """
+ u = self.ui
+ editFile(join(self.clonedir, "original.webidl"), "interface Foo{};", "interface Bar{};")
+ commit(u, self.clonerepo, message="checkin 1 bug 12345", user="Johnny Stenback <jst@mozilla.com>")
+ result = push(u, self.clonerepo, dest=self.repodir)
+ self.assertEqual(result, 0)
+
def testWebIDLEditWithoutProperReviewInReleaseMergeShouldPass(self):
""" Test that editing .webidl file without proper DOM peer review when doing a code uplift should pass """
u = self.ui
editFile(join(self.clonedir, "original.webidl"), "interface Foo{};", "interface Bar{};")
commit(u, self.clonerepo, message="checkin 1 bug 12345; r=foobar")
appendFile(join(self.clonedir, "dummy"), "foo")
add(u, self.clonerepo, join(self.clonedir, "dummy"))
commit(u, self.clonerepo, message="Doing the code uplift, a=release")