重命名Mercurial的承诺分支机构 [英] Rename a committed to branch in Mercurial

查看:72
本文介绍了重命名Mercurial的承诺分支机构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mercurial-在创建分支并提交给分支之后(本地和中央仓库中),要完成重命名需要执行哪些步骤.

Mercurial - What are the steps involved to accomplish the rename of a branch after it has been created and committed to (both locally and in the central repo).

例如,我创建了一个名为Zelda的分支,然后提交并推送到中央存储库.现在,我想将分支的名称更改为Triforce.

For example, I've created a branch called Zelda and then committed and pushed to a central repository. I now want to change the name of the branch to Triforce.

是否有扩展程序可以做到这一点?除了任何扩展解决方案之外,还有很长的路要走吗?

Is there an extension that accomplishes this? What might be the long way in addition to any extension solution?

推荐答案

简短的回答是.

长答案是,Mercurial分支是附加到变更集的名称.如果您有多个变更集提交给分支 zelda 并被放弃(即,推送到中央存储库),则无法在不重新创建这些变更集的情况下重命名该分支,这意味着要重写历史记录.

The long answer is, Mercurial branches are names attached to changesets. If you have several changesets committed to the branch zelda and given away (i.e., pushed to the central repo), there's no way you can rename that branch without re-creating these changesets, which means rewriting history.

即使您在存储库和中央存储库中都剥离了这些变更集,然后将其重新创建为属于分支 triforce ,然后再次按重命名"分支,所有协作者最终将拥有变更集的两个副本,一个在分支 zelda 上,另一个在分支 triforce 上.

Even if you strip those changesets both in you repo and in the central repo, then re-create them as belonging to the branch triforce, and push the "renamed" branch again, all of your collaborators will end up having two copies of the changesets, one set on branch zelda, another on branch triforce.

是的, https://stackoverflow.com/a/7245187/67988 中介绍了您应该做的事情. .要从那里引用,调整到您的分支名称,即 zelda 是要关闭的旧分支,而 triforce 是要创建的新分支.

So yes, what you should do is described in https://stackoverflow.com/a/7245187/67988. To quote from there, adjusted to your branch names, i.e. zelda is the old branch to be closed and triforce is the new branch to be created.

hg update zelda
hg commit --close-branch -m "mgmt: Close branch zelda"
hg branch triforce
hg commit -m "mgmt: Create branch triforce"
hg push --new-branch

P.S..如果还没有人从中央仓库中撤出,您可以尝试从此处剥离 zelda .或者,如果您可以访问所有其他开发人员的PC(假设环境受控),并且确实想走一条非常危险的道路,则可以从所有存储库中删除该分支.绝对不认为这是一种好习惯,只能作为不得已的措施.

P.S. If no one else pulled from the central repo yet, you can try stripping zelda from there. Or, if you have access to all other devs' PCs (assuming a controlled environment), and really want to go one very dangerous road, you can strip this branch from all the repos. This is definitely not considered good practice, and can only be used as a last resort measure.

这篇关于重命名Mercurial的承诺分支机构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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