# HG changeset patch # User Martin von Zweigbergk # Date 1503701407 25200 # Node ID 9180f8f593f3e3a2d9aa444f9fcd305f7a9096bb # Parent e43264525ce513dab1ea23e39d2cf1051975c8ca revlog: abort on attempt to write null revision My repo got corrupted yesterday by something that ended up writing the null revision to the revlog (nullid hash, not nullrev index, of course). We use many extensions internally (narrowhg, remotefilelog, evolve, internal extensions) and treemanifests are on. The null revision was written to the changelog, the root manifest log, and one subdirectory manifest log. I have no idea exactly why the null revision was written, but it seems cheap enough to check that we should fail instead of corrupting the repo. Differential Revision: https://phab.mercurial-scm.org/D522 diff -r e43264525ce5 -r 9180f8f593f3 mercurial/revlog.py --- a/mercurial/revlog.py Tue Aug 22 23:39:05 2017 -0700 +++ b/mercurial/revlog.py Fri Aug 25 15:50:07 2017 -0700 @@ -1694,6 +1694,9 @@ - rawtext is optional (can be None); if not set, cachedelta must be set. if both are set, they must correspond to each other. """ + if node == nullid: + raise RevlogError(_("%s: attempt to add null revision") % + (self.indexfile)) btext = [rawtext] def buildtext(): if btext[0] is not None: