Search code examples
mercurialbackupchecksumconsistencygit-fsck

How to check a Mercurial repository for consistency (checksums)?


Assume I recover a Mercurial repository from a broken file system (e.g. bad hard drive), and I want to be sure that this one was not affected.

How can I force a self-check in Mercurial? That is, Mercurial walks through the whole history and checks that all checksums fit their respective dataset, and that the repository as a whole is consistent.

Is it sufficient to perform a local "hg clone" to enforce that check?

It there something like "git fsck" for Mecurial?


Solution

  • The command for a pure check is:

    hg verify
    

    In case the repository is corrupt, the Mercural wiki provides recovery instructions:

    Of course, this only checks the commits, not the working directory. That it, it neither checks local changes that were not yet committed, nor ignored files such as build results. All those can't be verified by Mercurial, of course. Those would either have to be verified by different means, or simply be reset using a fresh Mercurial checkout and a fresh build.