How to fix integrity errors

Matt Mackall mpm at selenic.com
Wed Mar 19 10:44:06 CDT 2008


On Wed, 2008-03-19 at 11:10 +0100, Luc Heinrich wrote:
> Hello,
> 
> In order to get my feet wet with git I'm trying to convert one of my  
> mercurial repository using hg-fast-export, but the process fails.  
> Running 'hg verify' on this repository gives the following error:
> 
> % hg verify
> checking changesets
> checking manifests
> crosschecking files in changesets and manifests
> checking files
>   tools/packer2.perl/SamplePacked.htm at 531: 5700f65ec184 in manifests  
> not found
> 852 files, 577 changesets, 3114 total revisions
> 1 integrity errors encountered!
> (first damaged changeset appears to be 531)
>
> Is there a way to fix this problem ? Thanks.

This error means can mean several things:

a) a single revision of the file is missing (very unusual, hard to fix)
b) there was only one revision but the entire revlog is missing

In most cases, you simply copy the revlog from .hg/store/data in another
clone, but if you don't have any intact clones, then things are more
difficult.

If you had a single missing file revision (case b) and you have the
-exact- file somewhere, you can do a hack like this:

hg clone myrepo myrepo-backup
hg clone -r 530 myrepo myrepo-hack # we need the next commit to be 531
cp myfile myrepo-hack/
hg add myfile
hg ci -m "A new 531"

Now we'll hopefully have a new revlog that has the exact missing
contents in myrepo-hack/.hg/store/data/myfile.i, including the "linkrev"
that says it's part of changeset 531. 

Here's an example:

$ hg clone hg hg-damage
739 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd hg-damage
$ rm .hg/store/data/_c_o_p_y_i_n_g.i # destroy the history for COPYING
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
 COPYING at 394: empty or missing revlog
851 files, 6316 changesets, 12035 total revisions
1 integrity errors encountered!
(first damaged changeset appears to be 394)
$ cd ..
$ hg clone -r 393 hg-damage hg-hack # one revision back
requesting all changes
adding changesets
adding manifests
adding file changes
added 394 changesets with 762 changes to 90 files
77 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd hg-hack
$ cp ../hg/COPYING . # pristine copy of missing revision
$ hg st
? COPYING
$ hg add COPYING
$ hg ci -m "our new 394"
$ cp .hg/store/data/_c_o_p_y_i_n_g.i ../hg-damage/.hg/store/data
$ cd ..
$ cd hg-damage
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
851 files, 6316 changesets, 12036 total revisions

Again, for this hack to work, you must have the exact missing revision,
otherwise the hashes won't agree and you'll now have two integrity
errors (missing revision, unknown revision) instead of one.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list