如何将命名分支与 Mercurial 中的不同变更集关联起来?
我将存储库从 Git 转换为 Mercurial,并为我们的生产开发创建了一个命名分支 product
。不幸的是,一周后,我们刚刚意识到生产
分支位于错误的变更集上。
尽管我们对存储库进行了许多更改,但尚未对 生产
分支进行任何提交。我需要以某种方式将生产
名称与正确的变更集重新关联,或者删除分支并重新创建它。
这样做的最佳方法是什么?
I converted a repository from Git to Mercurial, and created a named branch production
for our production development. Unfortunately, a week later, we've just realized the production
branch is on the wrong changeset.
Although we've made a number of changes to the repository, there haven't been any commits to the production
branch yet. I need to somehow reassociate the production
name with the correct changeset, or delete the branch and recreate it.
What's the best way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
mq
扩展轻松完成此操作。显然,这需要每个人都获得存储库的新克隆。如果
生产
分支是在变更集 869 中创建的,并且您希望在变更集 842 上创建它,您可以说:这将从存储库中删除变更集 869(及其所有后代),对任何后续变更集重新编号以填充在间隙中,然后将
生产
名称分配给正确的变更集。You can do it, very easily, by using the
mq
extension. Obviously, this requires everyone to get a new clone of the repository.If the
production
branch was created in changeset 869, and you wanted it on changeset 842, you can say:This will remove changeset 869 (and all its descendants) from the repository, renumbering any subsequent changesets to fill in the gaps, and then assign the
production
name to the correct changeset.如果还没有“提交到
生产
分支”,则该分支尚不存在。在 Mercurial 的命名分支中,分支名称是已提交变更集上不可磨灭的标签。变更集永远不会改变它所在的分支。我假设您至少有一个带有生产
分支标签的变更集,否则这将成为一个没有问题的问题。如果你采取这些行动,我想你最终会好起来的:
hg update
到你希望的生产头hg分支生产
这只是说下一次提交应该有生产标签hg commit
您现在将拥有一个带有标签生产
的新提交现在,当人们克隆生产时:
或者
或更新它
他们会得到您想要的发展分支。旧的变更集仍然(并且始终)具有
生产
标签,但这可能没问题。如果确实不行,您可以重建存储库并从这些提交中删除标签,但是上面的过程可以让人们克隆/更新生产
正确的东西,所以您应该没问题。If there have been no "commits to the
production
branch yet" then the branch doesn't yet exist. In mercurial's named branches a branch name is an indelible label on a committed changeset. A changeset never changes what branch it's on. I'm going to assume you've got at least one changeset with theproduction
branch label or this turns into a no-problem question.If you take these actions I think you'll end up okay:
hg update
to the revision you wish was the production headhg branch production
this just says the next commit should have the production labelhg commit
you'll now have a new commit with the labelproduction
Now when people do a clone of just production:
or
or update to it
They'll get the branch of development you want. That old changeset(s) will still (and always will) have the
production
label, but that's likely okay. If it's really not okay you could rebuild the repo and remove the labels from those commits, but the process above gets people cloning/updatingproduction
the right stuff, so you should be fine.