Bug 1019206 - Add an exception to the WebIDL hook for code uplifts; r=ted
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 04 Jun 2014 16:12:29 -0400
changeset 359285 bcc78aafdd006d59c2a1216f506f110e21fe1ce0
parent 359284 57b51fdb0c8767101be83495c4bad90667623c6c
child 359286 01497ffbe0fdc6607e1eda28540db67d5d88f47d
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
reviewersted
bugs1019206
Bug 1019206 - Add an exception to the WebIDL hook for code uplifts; r=ted
hghooks/mozhghooks/prevent_webidl_changes.py
hghooks/runtests.py
--- a/hghooks/mozhghooks/prevent_webidl_changes.py
+++ b/hghooks/mozhghooks/prevent_webidl_changes.py
@@ -44,18 +44,21 @@ def hook(ui, repo, hooktype, node, **kwa
         'khuey',            # Kyle Huey
         'jlebar',           # Justin Lebar
         'hsivonen',         # Henri Sivonen
         'mrbkap',           # Blake Kaplan
         'bholley',          # Bobby Holley
     ]
     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
-    changesets = list(repo.changelog.revs(repo[node].rev()))
     for i in reversed(changesets):
         c = repo.changectx(i)
 
         if len(c.parents()) > 1:
             # Skip merge changesets
             continue
 
         # Loop through each file for the current changeset
--- a/hghooks/runtests.py
+++ b/hghooks/runtests.py
@@ -903,16 +903,37 @@ 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 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")
+    result = push(u, self.clonerepo, dest=self.repodir)
+    self.assertEqual(result, 0)
+
+  def testWebIDLEditWithoutProperReviewInNonReleaseMergeButWithAEqualsReleaseShouldFail(self):
+    """ Test that editing .webidl file without proper DOM peer review when doing a code uplift should pass """
+    u = self.ui
+    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")
+    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 testWebIDLEditWithProperReviewShouldPass(self):
     """ Test that editing .webidl file with proper DOM peer 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; r=foobar,jst")
     result = push(u, self.clonerepo, dest=self.repodir)
     self.assertEqual(result, 0)
     editFile(join(self.clonedir, "original.webidl"), "interface Bar{};", "interface Baz{};")