Mercurial 中的廉价克隆/本地分支
几天前刚开始使用 Mercurial,有一些我不明白的地方。
我想做一个实验性的事情,所以正常的做法是克隆我的存储库,在克隆上工作,如果最终我想保留这些更改,我会将它们推送到我的主存储库。
问题是克隆我的存储库需要大量时间(我们有很多代码),而仅编译克隆的副本就需要一个小时。
因此,我需要以某种方式在不同的存储库上工作,但仍在我的原始工作副本中。
输入本地分支。
问题是仅仅创建一个本地分支就需要很长时间,而且与他们一起工作也不是那么有趣。因为在本地分支之间移动时不会“恢复”到目标分支状态,所以我必须发出 hg purge
(以删除在移动分支中添加的文件),然后 hg update -c
(恢复已移出分支中的已修改文件)。 (注意:我确实尝试了本地分支扩展的 PK11 分支,它是一个简单的本地分支创建,但会因异常而崩溃)
归根结底,这太复杂了。我有什么选择?
Just started working with Mercurial a few days ago and there's something I don't understand.
I have an experimental thing I want to do, so the normal thing to do would be to clone my repository, work on the clone and if eventually I want to keep those changes, I'll push them to my main repository.
Problem is cloning my repository takes alot of time (we have alot of code) and just compiling the cloned copy would take up to an hour.
So I need to somehow work on a different repository but still in my original working copy.
Enter local branches.
Problem is just creating a local branch takes forever, and working with them isn't all that fun either. Because when moving between local branches doesn't "revert" to the target branch state, I have to issue a hg purge
(to remove files that were added in the moved from branch) and then hg update -c
(to revert modified files in the moved from branch). (note: I did try PK11 fork of local branch extension, it a simple local branch creation crashes with an exception)
At the end of the day, this is just too complex. What are my options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
除了克隆之外,还有多种使用本地分支的方法:
您可能有兴趣阅读一篇非常有洞察力的 Mercurial 分支指南。我想 书签 扩展是您所描述的上下文中最合适的分支方式。
There are several ways of working with local branches besides cloning:
You may be interested in reading a very insightful guide to branching in Mercurial. I guess the bookmarks extension is the most appropriate way of branching in the context you've described.
可能不是您想听到的答案,但我想说也许您应该考虑将存储库拆分为更易于管理的块:)。例如,该文档和那些设计文件是否确实需要包含在同一个存储库中,该编辑器工具是否不值得拥有自己的存储库,等等。
因为当克隆创建硬链接时,它几乎已经达到了最快的速度;如果克隆已经需要 5-10 分钟,那么制作文件系统副本肯定会更糟。 (提示:请记住
hg clone -U
如果您不需要工作副本,它会快得多。)否则,是的,带有书签的匿名分支是通常的方法 -地点切换。
Probably not the answer you want to hear, but I would say maybe you should consider splitting your repository into a little more manageable chunks :). E.g. does that documentation and those design files really need to be included in the same repository, does that editor tool not deserve its own repository, etc.
Because as cloning creates hard links, it’s pretty much already as fast as it can get; if cloning takes 5-10 minutes already, making a file system copy must be even worse. (Tip: keep in mind
hg clone -U
if you do not need a working copy, it will be much much faster.)Otherwise, yeah, anonymous branches with bookmarks is the usual way to do in-place switching.
克隆本地存储库需要多长时间?
听起来你的构建过程可能是我的薄弱环节 - 也许你需要类似 ccache 的东西?以便您可以快速克隆和构建
how long does cloning a local repo take?
it sounds like you build process might be the weak link to me - perhaps you need something like ccache? so that you can clone and build quickly
难道您不能在现有克隆之上进行实验吗?当您想对主线进行一些更改时,请返回并更新到开始实验之前的最后一个版本?
couldn't you make your experiments on top of your existing clone and when you want to make some changes to the main line go back and update to the last revision before you started the experiments?