From 9255a8ef244547ee826b0a60d0f329e8341733de Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 25 Aug 2017 15:50:07 -0700 Subject: [PATCH] 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 --- mercurial/revlog.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mercurial/revlog.py b/mercurial/revlog.py index a129a9146a..72be3f4bde 100644 --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1694,6 +1694,9 @@ class revlog(object): - 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: