您可以关闭Mercurial分支而不先对其进行更新吗? [英] Can you close a Mercurial branch without updating to it first?

查看:36
本文介绍了您可以关闭Mercurial分支而不先对其进行更新吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用以下命令关闭Mercurial分支机构:

I am aware that you can close a Mercurial branch with:

hg update rev-number
hg commit --close-branch -m "Closing branch."

但是,我使用的某些存储库相当大,几年后发现我想关闭的一个松散分支后,首先更新到它可能需要花费几分钟(如果不是几个小时),只能执行一次提交然后更新回原来的工作版本(如果不是数小时,则需要更多分钟).

However, some of the repositories I work with a rather large, and after discovering a loose branch from years ago that I want to close, updating to it first can take many minutes (if not hours), only to do one commit and then update back to the original revision I was working from (more minutes, if not hours).

所以我的问题是,有没有办法在不先将工作目录更新到分支修订版本的情况下关闭Mercurial分支?

So my question, is there any way to close a Mercurial branch without updating the working directory to the branch revision first?

推荐答案

可以,但这在任何地方都没有记录.我已经使用这种技术很长时间了,不用担心,它很安全.

Yes you can, but this is not documented anywhere. I've used this technique for a long time, don't worry, it is safe.

代替更新,您可以发出以下命令

Instead of updating, you can issue the following commands

hg debugsetparent <revision>
hg branch <branchOfRevision>

请注意,顺序很重要.这将使您的存储库认为它是在新修订版上,而所有文件都来自初始版本.之后,您可以使用--close-branch提交,但可以使用-X *选项进行空提交.

Note that the order is important. This will make your repo think it is on the new revision, while all your files are from the initial one. After that, you can use the --close-branch commit, but use the -X * option to make an empty commit.

hg commit --close-branch -X * -m "Closing branch."

现在,就像什么都没发生一样,只需回到您的前脑袋即可.

Now, simply get back to your previous head, like nothing happened.

hg debugsetparent <InitialRevision>
hg branch <branchOfInitialRevision>

最后,如果您有子仓库,则可能要在提交--close-branch之前临时重命名.hgsub文件,然后再重命名.

Finally, if you have sub-repos, you might want to temporarily rename the .hgsub file before committing the --close-branch, and rename back afterward.

这篇关于您可以关闭Mercurial分支而不先对其进行更新吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆