views:

126

answers:

1

I have several projects which are shared between Windows and Mac. The dev machine is a Mac running 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?

+2  A: 

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.

Ry4an
I like your pre-commit idea!Both clients are hg 1.5.1, so I don't think I'll get relief from that. But just being able to prevent commits on Windows would end my worst suffering, so I'll try the pre-commit hook.
Stabledog
Ok, I added the hook and it works great. Thanks!
Stabledog
Glad to hear it! Mind picking the answer then?
Ry4an