Add APPROVAL REQUIRED hook for trees that... require approval. r=bsmedberg
authorJohnathan Nightingale <johnath@mozilla.com>
Thu, 13 Aug 2009 11:45:13 -0400
changeset 359106 c856567ce92d5bd75bee760a0d74331b744cee55
parent 359105 4dce70ca876182106c979ec9d14626c600ca6a1e
child 359107 db95bd16d634700d7e81d6fa05b7b0eeb36cc866
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
reviewersbsmedberg
Add APPROVAL REQUIRED hook for trees that... require approval. r=bsmedberg Silent on success, message and rejection on failure to include a=...
hghooks/mozhghooks/treeclosure.py
--- a/hghooks/mozhghooks/treeclosure.py
+++ b/hghooks/mozhghooks/treeclosure.py
@@ -25,20 +25,28 @@ def hook(ui, repo, **kwargs):
         
         url = hgNameToTinderboxURL[name];
         u = urlopen(url)
         text = ''.join(u.readlines()).strip()
         if re.compile('<span id="treestatus".*CLOSED.*<span id="extended-status">').search(text) :
             print "Tree %s is CLOSED! (%s)" % (name, url)
             
             # Block the push unless they know the magic words
-            if repo.changectx('tip').description().find(magicwords) < 0:
+            if repo.changectx('tip').description().find(magicwords) == -1:
                 print "To push despite the closed tree, include \"%s\" in your push comment" % magicwords
                 return 1
             else:
                 print "But you included the magic words.  Hope you had permission!"
                 return 0
+        elif re.compile('<span id="treestatus".*APPROVAL REQUIRED.*<span id="extended-status">').search(text) :
+            # Block the push unless they have approval
+            if repo.changectx('tip').description().lower().find('a=') == -1:
+                print "Pushing to an APPROVAL REQUIRED tree requires your top changeset comment to include: a=..."
+                return 1
+            else:
+                return 0
+            
     except IOError, (err):
         # fail open, I guess. no sense making hg unavailable
         # if the wiki is down
         print "IOError: %s" % err
         pass
     return 0