How to avoid Mercurial repo corruption when sharing a repository between Windows/Mac?
I have several projects which are shared between Windows and Mac. The dev machine is a Mac r开发者_如何学Cunning Parallels: the files are stored on the Mac side, and the source is shared to the Windows side. This is very convenient, as I can switch back and forth between Windows and Mac tools rapidly without having to sync files.
Recently I switched from Subversion to Mercurial, and now I'm having problems with the Mercurial repository becoming corrupt if I use the Windows tools to add/update, etc. I have to be very careful about which operations on the Windows side are safe (mainly the read-only stuff) and of course I forget rather regularly.
Does anybody know why the corruption occurs? I thought Mercurial repositories were platform-agnostic. Any ideas how to prevent it without removing the Windows tools entirely?
Are both the windows side and the OSX side using the same version of mercurial. Mercurial has great backwards compatibility at the network and file level in that any version can push/pull/commit to any previous version's repositories, but it's not forward-compatible, so if your windows side is using mercurial 1.0 and your OSX side is at 1.5 then windows shouldn't be committing to a clone created by the OSX side.
In general mercurial was built for a clone-per-user-per-system and having conflicting actions mediated through push and pull. Shared repos accessed by multiple clients for local-only actions like commit isn't the recommended use case.
Editing on both systems is fine, but commit from OSX only. On the windows side you could enforce that by putting something like this in your %USER_PROFILE%\Mercurial.ini file:
[hooks]
pre-commit = c:\doesnotexist.exe
That should be enough for the hook to fail, which will stop the commit from going through.
精彩评论