如何将命名分支与 Mercurial 中的不同变更集关联起来?

发布于 2024-09-27 11:04:37 字数 242 浏览 2 评论 0原文

我将存储库从 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 技术交流群。

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

发布评论

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

评论(2

好久不见√ 2024-10-04 11:04:37

您可以使用 mq 扩展轻松完成此操作。显然,这需要每个人都获得存储库的新克隆。

如果 生产 分支是在变更集 869 中创建的,并且您希望在变更集 842 上创建它,您可以说:

hg strip 869
hg update 842
hg branch production

这将从存储库中删除变更集 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:

hg strip 869
hg update 842
hg branch production

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.

秋叶绚丽 2024-10-04 11:04:37

如果还没有“提交到生产分支”,则该分支尚不存在。在 Mercurial 的命名分支中,分支名称是已提交变更集上不可磨灭的标签。变更集永远不会改变它所在的分支。我假设您至少有一个带有 生产 分支标签的变更集,否则这将成为一个没有问题的问题。

如果你采取这些行动,我想你最终会好起来的:

  1. hg update到你希望的生产头
  2. hg分支生产这只是说下一次提交应该有生产标签
  3. hg commit 您现在将拥有一个带有标签 生产 的新提交

现在,当人们克隆生产时:

hg clone repopath#production

或者

hg clone -r production repopath

或更新它

hg update production

他们会得到您想要的发展分支。旧的变更集仍然(并且始终)具有生产标签,但这可能没问题。如果确实不行,您可以重建存储库并从这些提交中删除标签,但是上面的过程可以让人们克隆/更新生产正确的东西,所以您应该没问题。

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 the production branch label or this turns into a no-problem question.

If you take these actions I think you'll end up okay:

  1. hg update to the revision you wish was the production head
  2. hg branch production this just says the next commit should have the production label
  3. hg commit you'll now have a new commit with the label production

Now when people do a clone of just production:

hg clone repopath#production

or

hg clone -r production repopath

or update to it

hg update production

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/updating production the right stuff, so you should be fine.

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