在 Windows/Mac 之间共享存储库时如何避免 Mercurial 存储库损坏?

发布于 2024-09-03 08:24:14 字数 335 浏览 1 评论 0原文

我有几个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福%小乖 2024-09-10 08:24:14

windows端和OSX端都使用相同版本的mercurial。 Mercurial 在网络和文件级别具有很好的向后兼容性,任何版本都可以推送/拉取/提交到任何先前版本的存储库,但它不向前兼容,因此如果您的 Windows 端使用 Mercurial 1.0 而 OSX 端使用 1.5那么 Windows 不应该提交给 OSX 端创建的克隆。

一般来说,mercurial 是为每个系统每个用户克隆而构建的,并且通过推和拉来调解冲突的操作。不建议使用由多个客户端访问的共享存储库来执行仅限本地的操作(例如提交)。

在两个系统上编辑都可以,但只能从 OSX 提交。在 Windows 端,您可以通过在 %USER_PROFILE%\Mercurial.ini 文件中放置类似的内容来强制执行此操作:

[hooks]
pre-commit = c:\doesnotexist.exe

这应该足以使挂钩失败,这将阻止提交进行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文