Hook failure corrupts repository
Created originally on Bitbucket by Anonymous
When commiting changes, if a hook raises an error (invalid commit message for example), the repository becomes corrupted.
To reproduce the problem, I have written a very little python hook that will alway raise an error
#!python
from mercurial import util
def checkCommit(ui, repo, hooktype, node=None, **kwargs):
raise util.Abort(_('Hook failure'))
#in my hgrc file, I have added the following line
#pretxncommit.check = python:xxx.py:checkCommit
After committing, I get the following error (which seems normal):
#!
error: pretxncommit.check hook failed: Hook failure
transaction abort!
rollback completed
But running a verification on the repositroy gives me the following output : (NB : 592 is the revision I tried to push)
#!
% hg verify --verbose
repository uses revlog format 1
checking changesets
changelog@?: data length off by -111 bytes
592: unpacking changeset 1b5835da2de8: integrity check failed on 00changelog.i:592
checking manifests
manifest@?: data length off by -786 bytes
manifest@?: rev 591 points to unexpected changeset 592
manifest@?: efb039319d22 not in changesets
crosschecking files in changesets and manifests
checking files
1726 files, 593 changesets, 4816 total revisions
5 integrity errors encountered!
(first damaged changeset appears to be 592)
[command returned code 1 Thu Sep 10 10:24:56 2015]