hghooks: don't process strips from commit-message hook (bug 1128698); r=bkero
authorGregory Szorc <gps@mozilla.com>
Wed, 04 Feb 2015 16:54:21 -0800
changeset 1979 4816d9611b081b444a830564dbda32b8cee1e1db
parent 1978 002c1562a56f33ad97456950bce0c8c4737e417a
child 1980 27e7ffebbfed52f73f64e3e78cfc11b7d4a462c1
push id543
push usergszorc@mozilla.com
push dateTue, 10 Feb 2015 20:31:55 +0000
treeherderversion-control-tools@33a0fa9dc70d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkero
bugs1128698
hghooks: don't process strips from commit-message hook (bug 1128698); r=bkero We don't want our hooks to fire when a strip is performed because it can cause the strip to abort mid operation. If a changeset is already in the repository, it made it in and the hook doesn't have any business rejecting it again.
hghooks/mozhghooks/commit-message.py
hghooks/tests/test-commit-messages.t
--- a/hghooks/mozhghooks/commit-message.py
+++ b/hghooks/mozhghooks/commit-message.py
@@ -68,17 +68,20 @@ def isGoodMessage(c):
     if dlower.startswith("back") or dlower.startswith("revert"):
         # Purposely ambiguous: it's ok to say "backed out rev N" or "reverted to rev N-1"
         message("Backout rev {rev} needs a bug number or a rev id.")
     else:
         message("Rev {rev} needs \"Bug N\" or \"No bug\" in the commit message.")
 
     return False
 
-def hook(ui, repo, node, hooktype, **kwargs):
+def hook(ui, repo, node, hooktype, source=None, **kwargs):
+    if source == 'strip':
+        return 0
+
     # All changesets from node to "tip" inclusive are part of this push.
     rev = repo.changectx(node).rev()
     tip = repo.changectx("tip").rev()
     rejecting = False
 
     for i in reversed(xrange(rev, tip + 1)):
         c = repo.changectx(i)
 
--- a/hghooks/tests/test-commit-messages.t
+++ b/hghooks/tests/test-commit-messages.t
@@ -482,22 +482,12 @@ Reapplying a stripped bundle should not 
   > [extensions]
   > strip=
   > 
   > [hooks]
   > pretxnchangegroup.commit_message = python:mozhghooks.commit-message.hook
   > EOF
 
   $ hg strip -r 1 --no-backup
-  
-  
-  ************************** ERROR ****************************
-  Rev e3d623084e10 needs "Bug N" or "No bug" in the commit message.
-  test
-  bad commit
-  *************************************************************
-  
-  
-  transaction abort!
-  rollback completed
-  strip failed, partial bundle stored in '$TESTTMP/striptest/.hg/strip-backup/46054ff63cbc-temp.hg'
-  abort: pretxnchangegroup.commit_message hook failed
-  [255]
+
+  $ hg log -T '{rev} {desc}\n'
+  1 bad commit
+  0 initial