Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 33956:9180f8f593f3
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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 25 Aug 2017 15:50:07 -0700 |
parents | ac6446611ad2 |
children | b2eb0aa445cb |
comparison
equal
deleted
inserted
replaced
33955:e43264525ce5 | 33956:9180f8f593f3 |
---|---|
1692 | 1692 |
1693 invariants: | 1693 invariants: |
1694 - rawtext is optional (can be None); if not set, cachedelta must be set. | 1694 - rawtext is optional (can be None); if not set, cachedelta must be set. |
1695 if both are set, they must correspond to each other. | 1695 if both are set, they must correspond to each other. |
1696 """ | 1696 """ |
1697 if node == nullid: | |
1698 raise RevlogError(_("%s: attempt to add null revision") % | |
1699 (self.indexfile)) | |
1697 btext = [rawtext] | 1700 btext = [rawtext] |
1698 def buildtext(): | 1701 def buildtext(): |
1699 if btext[0] is not None: | 1702 if btext[0] is not None: |
1700 return btext[0] | 1703 return btext[0] |
1701 baserev = cachedelta[0] | 1704 baserev = cachedelta[0] |