在 Windows/Mac 之间共享存储库时如何避免 Mercurial 存储库损坏?
我有几个在 Windows 和 Mac 之间共享的项目。开发机器是运行Parallels的Mac:文件存储在Mac端,源共享到Windows端。这非常方便,因为我可以在 Windows 和 Mac 工具之间快速来回切换,而无需同步文件。
最近我从 Subversion 切换到 Mercurial,现在如果我使用 Windows 工具添加/更新等,我会遇到 Mercurial 存储库损坏的问题。我必须非常小心 Windows 端的哪些操作是安全的(主要是只读的东西)当然我经常忘记。
有谁知道腐败现象为何发生?我认为 Mercurial 存储库与平台无关。有什么想法可以在不完全删除 Windows 工具的情况下阻止它吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
windows端和OSX端都使用相同版本的mercurial。 Mercurial 在网络和文件级别具有很好的向后兼容性,任何版本都可以推送/拉取/提交到任何先前版本的存储库,但它不向前兼容,因此如果您的 Windows 端使用 Mercurial 1.0 而 OSX 端使用 1.5那么 Windows 不应该提交给 OSX 端创建的克隆。
一般来说,mercurial 是为每个系统每个用户克隆而构建的,并且通过推和拉来调解冲突的操作。不建议使用由多个客户端访问的共享存储库来执行仅限本地的操作(例如提交)。
在两个系统上编辑都可以,但只能从 OSX 提交。在 Windows 端,您可以通过在 %USER_PROFILE%\Mercurial.ini 文件中放置类似的内容来强制执行此操作:
这应该足以使挂钩失败,这将阻止提交进行。
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:
That should be enough for the hook to fail, which will stop the commit from going through.