changeset 28110:2b41f8655bbc

tests: add tests for missing revlogs and revlog entries The verify code is pretty poorly tested. It's easy to test missing revlogs and missing revlog entries, so let's add tests for that. Also add some more tests corrupting each type of revlog, so we test the messages presented when reading a revision fails. The pure and native implementations produce different error messages, so we have to use (glob) in the tests.
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 31 Jan 2016 21:55:52 -0800
parents b892e424f88c
children 06205989264b
files tests/test-verify.t
diffstat 1 files changed, 202 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-verify.t	Fri Feb 12 14:50:10 2016 -0800
+++ b/tests/test-verify.t	Sun Jan 31 21:55:52 2016 -0800
@@ -63,6 +63,208 @@
   $ cd ../../..
   $ cd ..
 
+Set up a repo for testing missing revlog entries
+
+  $ hg init missing-entries
+  $ cd missing-entries
+  $ echo 0 > file
+  $ hg ci -Aqm0
+  $ cp -r .hg/store .hg/store-partial
+  $ echo 1 > file
+  $ hg ci -Aqm1
+  $ cp -r .hg/store .hg/store-full
+
+Entire changelog missing
+
+  $ rm .hg/store/00changelog.*
+  $ hg verify -q
+   0: empty or missing changelog
+   manifest@0: d0b6632564d4 not in changesets
+   manifest@1: 941fc4534185 not in changesets
+  3 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Entire manifest log missing
+
+  $ rm .hg/store/00manifest.*
+  $ hg verify -q
+   0: empty or missing manifest
+  1 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Entire filelog missing
+
+  $ rm .hg/store/data/file.*
+  $ hg verify -q
+   warning: revlog 'data/file.i' not in fncache!
+   0: empty or missing file
+   file@0: 362fef284ce2 in manifests not found
+   file@1: c10f2164107d in manifests not found
+  1 warnings encountered!
+  hint: run "hg debugrebuildfncache" to recover from corrupt fncache
+  3 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Entire changelog and manifest log missing
+
+  $ rm .hg/store/00changelog.*
+  $ rm .hg/store/00manifest.*
+  $ hg verify -q
+  warning: orphan revlog 'data/file.i'
+  1 warnings encountered!
+  $ cp -r .hg/store-full/* .hg/store
+
+Entire changelog and filelog missing
+
+  $ rm .hg/store/00changelog.*
+  $ rm .hg/store/data/file.*
+  $ hg verify -q
+   0: empty or missing changelog
+   manifest@0: d0b6632564d4 not in changesets
+   manifest@1: 941fc4534185 not in changesets
+   warning: revlog 'data/file.i' not in fncache!
+   ?: empty or missing file
+   file@0: 362fef284ce2 in manifests not found
+   file@1: c10f2164107d in manifests not found
+  1 warnings encountered!
+  hint: run "hg debugrebuildfncache" to recover from corrupt fncache
+  6 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Entire manifest log and filelog missing
+
+  $ rm .hg/store/00manifest.*
+  $ rm .hg/store/data/file.*
+  $ hg verify -q
+   0: empty or missing manifest
+   warning: revlog 'data/file.i' not in fncache!
+   0: empty or missing file
+  1 warnings encountered!
+  hint: run "hg debugrebuildfncache" to recover from corrupt fncache
+  2 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Changelog missing entry
+
+  $ cp -f .hg/store-partial/00changelog.* .hg/store
+  $ hg verify -q
+   manifest@?: rev 1 points to nonexistent changeset 1
+   manifest@?: 941fc4534185 not in changesets
+   file@?: rev 1 points to nonexistent changeset 1
+   (expected 0)
+  1 warnings encountered!
+  3 integrity errors encountered!
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Manifest log missing entry
+
+  $ cp -f .hg/store-partial/00manifest.* .hg/store
+  $ hg verify -q
+   1: changeset refers to unknown manifest 941fc4534185
+   file@1: c10f2164107d not in manifests
+  2 integrity errors encountered!
+  (first damaged changeset appears to be 1)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Filelog missing entry
+
+  $ cp -f .hg/store-partial/data/file.* .hg/store/data
+  $ hg verify -q
+   file@1: c10f2164107d in manifests not found
+  1 integrity errors encountered!
+  (first damaged changeset appears to be 1)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Changelog and manifest log missing entry
+
+  $ cp -f .hg/store-partial/00changelog.* .hg/store
+  $ cp -f .hg/store-partial/00manifest.* .hg/store
+  $ hg verify -q
+   file@?: rev 1 points to nonexistent changeset 1
+   (expected 0)
+   file@?: c10f2164107d not in manifests
+  1 warnings encountered!
+  2 integrity errors encountered!
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Changelog and filelog missing entry
+
+  $ cp -f .hg/store-partial/00changelog.* .hg/store
+  $ cp -f .hg/store-partial/data/file.* .hg/store/data
+  $ hg verify -q
+   manifest@?: rev 1 points to nonexistent changeset 1
+   manifest@?: 941fc4534185 not in changesets
+   file@?: c10f2164107d in manifests not found
+  3 integrity errors encountered!
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Manifest and filelog missing entry
+
+  $ cp -f .hg/store-partial/00manifest.* .hg/store
+  $ cp -f .hg/store-partial/data/file.* .hg/store/data
+  $ hg verify -q
+   1: changeset refers to unknown manifest 941fc4534185
+  1 integrity errors encountered!
+  (first damaged changeset appears to be 1)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Corrupt changelog base node to cause failure to read revision
+
+  $ printf abcd | dd conv=notrunc of=.hg/store/00changelog.i bs=1 seek=16 \
+  >   2> /dev/null
+  $ hg verify -q
+   0: unpacking changeset 08b1860757c2: * (glob)
+   manifest@?: rev 0 points to unexpected changeset 0
+   manifest@?: d0b6632564d4 not in changesets
+   file@?: rev 0 points to unexpected changeset 0
+   (expected 1)
+  1 warnings encountered!
+  4 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Corrupt manifest log base node to cause failure to read revision
+
+  $ printf abcd | dd conv=notrunc of=.hg/store/00manifest.i bs=1 seek=16 \
+  >   2> /dev/null
+  $ hg verify -q
+   0: reading manifest delta d0b6632564d4: * (glob)
+   file@0: 362fef284ce2 not in manifests
+  2 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+Corrupt filelog base node to cause failure to read revision
+
+  $ printf abcd | dd conv=notrunc of=.hg/store/data/file.i bs=1 seek=16 \
+  >   2> /dev/null
+  $ hg verify -q
+   file@0: unpacking 362fef284ce2: * (glob)
+  1 integrity errors encountered!
+  (first damaged changeset appears to be 0)
+  [1]
+  $ cp -r .hg/store-full/* .hg/store
+
+  $ cd ..
+
 test changelog without a manifest
 
   $ hg init b