Mercurial 中的部分(每个文件/文件夹)分支/标记?
在经典的 VCS (CVS/SVN) 中,我可以在一个分支中添加新文件/文件夹,然后用一些分支标签“标记”它们,以便它们也出现在另一个分支上(它们可能会从那里发散)再次)。这是通过将工作副本更新到特定状态然后设置分支标签来实现的。
我怎样才能在 Mercurial 中实现类似的目标?我进行了广泛的搜索,但似乎无法仅将几个文件/文件夹移动到另一个分支上。
就我而言,某些历史分支收到了一些更新,现在应该将这些更新移至当前活动分支(即在存储库从 Subversion 转换为 Mercurial 之前)。有没有什么方法可以保留这些文件/此文件夹的历史记录?或者我是否必须将这些文件的当前状态重新引入到另一个分支(即从头开始)?
旁注:两个分支的提示之间有数百个相互冲突的更改。这就是为什么我正在寻找分支之间全面合并的替代方案(这也将是一个问题,因为合并后其中一个分支将不再存在)。
In the classic VCSs (CVS/SVN) I can add new files/folders in one branch and then "tag" them with some branch tag so they appear on another branch as well (from where they may diverge again). This works by updating your working copy to a particular state and then setting the branch tag.
How can I achieve something similar in Mercurial? I searched, far and wide, but there appears to be no way of moving only a few files/folders onto another branch.
In my case some historical branch received some updates that should now be moved onto the currently active branch (that was before the repo was converted from Subversion to Mercurial). Is there any method that retains the history of these files/this folder? Or would I have to re-introduce the current state of these files to the other branch (i.e. start from scratch)?
Side-note: there are several hundred conflicting changes between the tips of both branches. That's why I'm looking for an alternative to full-fledged merging between the branches (which would also be a problem because one of the branches would cease to exist after a merge).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mercurial 移植扩展n 应该可以解决问题。移植将变更集重新应用到您选择的分支。它通常用作将错误修复从一个分支移动到另一个分支的一种方法(即:从与代码发布版本相对应的某个长期运行的分支移动到积极开发的默认分支)。
Transplant 随 Mercurial 一起分发,但您可能必须通过将以下行添加到 Mercurial.ini(或 .hgrc)来启用它:
从 TortoiseHg 您可以更新到目标变更集(即:您要放置修复的位置),然后右键单击要移动的变更集,然后选择“移植到本地”。命令行帮助可以在上面的链接中找到。
需要注意的是,移植适用于变更集,并且它希望应用整个变更集。因此,如果变更集包含一些您想要应用的更改和一些您不想应用的更改,则您必须做更多的工作。解决此问题的一种方法是使用 histedit 扩展并将此类变更集分成两部分。这可能很复杂,如果您的存储库不在本地包含(即:如果它位于某个服务器上),则不建议这样做。一个强力的选择是移植一个变更集,然后简单地撤消不需要的更改并将这些 mods 作为第二个变更集提交。
The Mercurial transplant extension should do the trick. Transplant re-applies a changeset to a branch of your choice. It's commonly used as a way to move a bug fix from one branch to another (ie: from some long-running branch corresponding to a released version of code to the actively developed default branch).
Transplant is distributed with Mercurial, but you might have to enable it by adding the following lines to your Mercurial.ini (or .hgrc):
From TortoiseHg you can update to the destination changeset (ie: where you are placing the fixes) and then right-click on the changeset you want to move and select "Transplant to local". Command line help can be found at the link above.
One caveat is that transplant applies to changesets, and it want to apply the entire changeset. So, if a changeset contains some changes you want to apply and some you do not, you've got to do a little more work. One way to get around this is to use the histedit extension and break such a changeset into two. This can be complex, and is not recommended if your repo is not locally contains (ie: if it's on a server somewhere). A brute-force option would be to transplant a changeset and then simply undo unwanted changes and commit those mods as a second changeset.