secretbase.log

.NET/C#/Pythonなど

Mercurial で壊れたリポジトリを復旧する方法

 Windows で Mercurial リポジトリサーバを構築しているとウイルス対策ソフトウェアが悪さをしてリポジトリを壊してしまうことがあるそうです(スキャン対象から外せればいいのですが、設定ができないようにガードされていることもよくある話です)
万が一壊れてしまったときに備えてメモしておきます。

ネタ元


リカバリー方法

その1 : hg convert によるリカバリー

RepositoryCorruption - Mercurial

$ hg convert --config convert.hg.ignoreerrors=True REPO REPOFIX
scanning source...
sorting...
converting...
[Various messages, most of which will be the commit messages]
ignoring: data/.DS_Store.i@26a47e9188c: no match found
[More commit messages]
.hgtags@78ff9079978f, line 1: tag '1.0b1' refers to unknown node
updating tags

その2: ファイル削除後、convert によるリカバリー

上記 hg convert によるリカバリーでもダメだった場合、例えば履歴ファイルのヘッダ不正("index XXXX unknown YYYY" のようなメッセージが出る場合は、

  • .hg/store から破損したファイルを削除
  • hg convert

という手順になります。


入門Mercurial Linux/Windows対応

入門Mercurial Linux/Windows対応

参考