[PATCH] validate: check for spurious incoming filelog entries
Sune Foldager
cryo at cyanite.org
Tue Dec 11 19:15:51 UTC 2012
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1355253201 -3600
# Node ID 25a36cb85e7acda9901505832a186dfb883c451f
# Parent 5522a7951bd7e2b16831ba1736feb2e9145d7e58
validate: check for spurious incoming filelog entries
Accepting those will lead to "mild corruption", correctly reported as
an error by hg verify, but often not a problem in practice.
Enabled when server.validate is switched on.
diff -r 5522a7951bd7 -r 25a36cb85e7a mercurial/localrepo.py
--- a/mercurial/localrepo.py Mon Dec 10 12:14:55 2012 -0800
+++ b/mercurial/localrepo.py Tue Dec 11 20:13:21 2012 +0100
@@ -2430,6 +2430,9 @@
n = fl.node(new)
if n in needs:
needs.remove(n)
+ else:
+ raise util.Abort(
+ _("received spurious file revlog entry"))
if not needs:
del needfiles[f]
self.ui.progress(_('files'), None)
diff -r 5522a7951bd7 -r 25a36cb85e7a tests/test-push-validation.t
--- a/tests/test-push-validation.t Mon Dec 10 12:14:55 2012 -0800
+++ b/tests/test-push-validation.t Tue Dec 11 20:13:21 2012 +0100
@@ -18,7 +18,48 @@
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+Test spurious filelog entries:
+
$ cd test-clone
+ $ echo blah >> beta
+ $ cp .hg/store/data/beta.i tmp1
+ $ hg ci -m 2
+ $ cp .hg/store/data/beta.i tmp2
+ $ hg -q rollback
+ $ mv tmp2 .hg/store/data/beta.i
+ $ echo blah >> beta
+ $ hg ci -m '2 (corrupt)'
+
+Expected to fail:
+
+ $ hg verify
+ checking changesets
+ checking manifests
+ crosschecking files in changesets and manifests
+ checking files
+ beta at 1: dddc47b3ba30 not in manifests
+ 2 files, 2 changesets, 4 total revisions
+ 1 integrity errors encountered!
+ (first damaged changeset appears to be 1)
+ [1]
+
+ $ hg push
+ pushing to $TESTTMP/test
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ transaction abort!
+ rollback completed
+ abort: received spurious file revlog entry
+ [255]
+
+ $ hg -q rollback
+ $ mv tmp1 .hg/store/data/beta.i
+ $ echo beta > beta
+
+Test missing filelog entries:
+
$ cp .hg/store/data/beta.i tmp
$ echo blah >> beta
$ hg ci -m '2 (corrupt)'
@@ -37,8 +78,6 @@
(first damaged changeset appears to be 1)
[1]
-Expected to fail:
-
$ hg push
pushing to $TESTTMP/test (glob)
searching for changes
More information about the Mercurial-devel
mailing list