如何将一些变更集移动到 Mercurial 中的新分支

发布于 2024-08-20 18:59:56 字数 273 浏览 5 评论 0原文

我想将变更集从一个分支移动到另一个分支。基本上,我目前有:

A -> B -> C -> D # default branch

我想要:

A # default branch
 \-> B -> C -> D # some_new_branch

some_new_branch 尚不存在。我习惯了 git,所以我想我缺少一种简单的“mercurial”方式。

I want to move a changeset from one branch to another. Basically, I currently have:

A -> B -> C -> D # default branch

And I want:

A # default branch
 \-> B -> C -> D # some_new_branch

Where some_new_branch does not exist yet. I am used to git, so I guess there is a simple "mercurial" way I am missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

绿萝 2024-08-27 18:59:56

一种方法是导出B、C、D的补丁;更新为A;分支;应用补丁:

hg export -o patch B C D
hg update A
hg branch branchname
hg import patch

要从默认分支中删除 B、C、D,请使用 mq 扩展的 strip 命令。

One way is to export a patch for B,C,D; update to A; branch; apply patch:

hg export -o patch B C D
hg update A
hg branch branchname
hg import patch

To remove B,C,D from the default branch, use the mq extension's strip command.

童话 2024-08-27 18:59:56

听起来有点像 git 中的择优挑选操作。 移植扩展可能就是您正在寻找的。

Sounds a bit like a cherry-pick operation in git. The Transplant Extension may be what you're looking for.

俏︾媚 2024-08-27 18:59:56

使用 Mercurial 队列:

# mark revisions as draft in case they were already shared
#hg phase --draft --force B:D
# make changesets a patch queue commits
# (patches are stored .hg/patches)
hg qimport -r B:D
# pop changesets from current branch
hg qpop -a
# 
hg branch some_new_branch
# push changesets to new branch
hg qpush -a
# and make them commits
hg qfinish -a

没有注释:

hg qimport -r B:D
hg qpop -a
hg branch some_new_branch
hg qpush -a
hg qfinish -a

With Mercurial Queue:

# mark revisions as draft in case they were already shared
#hg phase --draft --force B:D
# make changesets a patch queue commits
# (patches are stored .hg/patches)
hg qimport -r B:D
# pop changesets from current branch
hg qpop -a
# 
hg branch some_new_branch
# push changesets to new branch
hg qpush -a
# and make them commits
hg qfinish -a

Without comments:

hg qimport -r B:D
hg qpop -a
hg branch some_new_branch
hg qpush -a
hg qfinish -a
烈酒灼喉 2024-08-27 18:59:56

除了移植或修补之外,您还可以使用 graft

hg update A
hg branch branchname
hg graft -D "B:D"
hg strip B

请注意,改变历史是不好的做法。仅当您尚未推动时才应脱衣。否则,您仍然可以撤销您的更改。

Alternative to transplant or patch, you could use graft.

hg update A
hg branch branchname
hg graft -D "B:D"
hg strip B

Note that changing history is bad practice. You should strip only if you haven't pushed yet. Otherwise, you could still backout your changes.

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