Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

broken revlog and orphan revlog in Mercurial - How to repair?

Tags:

mercurial

This is what i get when i do hg verify :

repository uses revlog format 1
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
 includes/base/class/ViewInstanceAdapter.class.php@7: broken revlog! (index data/includes/base/class/ViewInstanceAdapter.class.php.i is corrupted)
warning: orphan revlog 'data/includes/base/class/ViewInstanceAdapter.class.php.i'
158 files, 61 changesets, 270 total revisions
1 warnings encountered!
1 integrity errors encountered!
(first damaged changeset appears to be 7)

I do not use Mercurial for a long time and i don't understand what this means.

(I'm on windows using TortoiseHg, and the project is local only)

like image 557
Leto Avatar asked Oct 16 '11 10:10

Leto


2 Answers

As said before (although you already confirmed this doesn’t work), you should start by trying to clone the repository; if the problems are related to the dirstate this can bypass it.

Next, every clone contains a complete repository, so every clone is effectively a back-up. Don’t you have a central server or colleague or another local copy? Try cloning that, then pulling from your corrupted repository. As the first damaged changeset is reported as being no. 7 (out of 270), this should be a pretty old one so likely easy to recover, and hopefully the damage does not prevent Mercurial from pulling changesets beyond that.

A third option you could try is to run a Mercurial-Mercurial conversion on your repository (hg convert repo repo-copy); a verbatim conversion should the keep changeset IDs intact, although it will probably run into the same problem. You could also try to specify a filemap to filter out the ViewInstanceAdapter file.

Because the damaged changeset is so old, and given that Mercurial uses an append-only writing method, the probable cause for this problem is a hardware failure or some kind of random disk corruption.

Note that Mercurial is not a backup system and does not provide redundancy. Making frequent back-ups (which in Mercurial’s case is as easy as a ‘hg push’) is the only way to make sure you don’t lose your precious code.

An alternate cause that I feel I should warn you about are virus scanners or the Windows indexing service. These lock files in a certain way that prevents them from being deleted during short time windows. Although Mercurial does its best to be robust, it is hard to defend against all cases. It is recommended to white-list your repositories, see this note.

like image 94
Laurens Holst Avatar answered Nov 11 '22 03:11

Laurens Holst


I found a solution (Thanks to Laurens Holst) ONLY if you have a clean bakcup (with no error) including the issue revision.

In my problem rev issue is 7 and i have a backup until rev 18.

Steps :

  • Clone the backup repository at the last common rev (here it is 18)

  • Pull broken repository revs into cloned one (you have now two heads but no modifications on the working directory of course)

  • Update cloned repository to the most recent revision (tip)

You have now a working .hg dir :)

like image 1
Leto Avatar answered Nov 11 '22 03:11

Leto