将一些修订版与 Mercurial 合并,但不合并其他修订版
我最近开始使用 Mercurial 跟踪我的项目的变化。在开始研究某个功能之前,我做了几次修改。现在,我想回到实现该功能之前的修订,并尝试以非常不同的方式实现它。但是,我想保留在第一个实现时所做的一些更改,因为无论我选择哪种实现,它们都同样适用。
在开始实现该功能之前,更新回修订版本的最佳方法是什么,但有选择地将默认分支上的更改合并到新的单独分支中?这是与 Mercurial 合并/分支的正确方法吗?如果我这样做,我以后可以“删除”其中一个分支以支持此功能的一个特定实现吗?
I recently started tracking changes for my project with Mercurial. I made several revisions before I started working on a certain feature. Now, I want to go back to my revision before I implemented that feature and try implementing it a very different way. However, I want to keep some of the changes I made while working on the first implementation because they apply equally no matter what implementation I choose.
What's the best way to update back to the revision before I started implementing the feature, but selectively incorporate changes along the default branch into a new, separate branch? Is this the right way to merge/branch with Mercurial? If I do this, can I later "drop" one of those branches in favor of one particular implementation of this feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有像 Beyond Compare 这样的外部 diff 程序,这将非常容易。
hg bcompare
将运行 Beyond Compare)将hgbranch
) 或设置一个书签 (hg bookmark
) 来跟踪这组新的更改。请参阅http://stevelosh.com/blog/ 2009/08/a-guide-to-branching-in-mercurial/ 了解差异的描述。当您决定想要哪种实现时,您可以更新到您不想要的分支的头部,并使用合并它,但保留所有想要的更改。
hg commit --close-branch
将其标记为已关闭,这仍然将其作为存储库中的头部。如果您想将其作为头部删除,请更新为您想要的分支的头部并使用 hg merge --toolinternal:localThis is very easy if you have an external diff program like Beyond Compare.
hg bcompare
will run Beyond Compare)hg branch
) or set a bookmark (hg bookmark
) to track this new set of changes against. See http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/ for a description of the differences.When you decide which implementation you want, you can either update to the head of the branch you don't want and use
hg commit --close-branch
to mark it as closed, which still leaves it as a head in the repository. If you want to remove it as a head, update to the head of the branch you do want and usehg merge --tool internal:local <rev-of-the-other-head>
to merge it, but keep all the wanted changes.我知道这个问题有点老了,但我今天在做一个项目时遇到了类似的问题。我花了几天时间尝试默认分支上的一个功能。这是我用来使代码库恢复良好状态的过程。
hg update -R 0
通过 tranplant 从另一个分支提交(hg port -b
默认 revNumberToPick)
移植现在随 Mercurial 一起发货,只需要您启用它。该文档位于 Mercurial wiki。希望这有帮助!
I know this question is a bit old, but I ran into something similar today when working on a project. I had spent a few days going down a dead-end trying out a feature on the default branch. Here's the process I used to get my code base back in a good condition.
hg update -R 0
commits from the other branch via tranplant (hg transplant -b
default revNumberToPick)
Transplant is shipping in the box with mercurial now, and just requires you to enable it. The documentation is located on Mercurial wiki. Hope this helps!