简体   繁体   English

Mercurial:如何在不丢失历史记录的情况下将单个分支拆分为两个?

[英]Mercurial: how can I split a single branch into two without losing history?

I have a mercurial repository with a default branch containing two directories at the top level: "demo/" and "product/".我有一个带有默认分支的 mercurial 存储库,其中包含两个顶级目录:“demo/”和“product/”。 I want to do the following, retaining change history if possible:我想执行以下操作,如果可能,保留更改历史记录:

1) Put everything in "demo/" into a new demo branch. 1) 将“demo/”中的所有内容放入一个新的演示分支。 All the files under demo/ would be moved one level down in this new branch, and no demo/ folder would exist in either the default or demo branch. demo/ 下的所有文件都将在这个新分支中向下移动一级,并且默认分支或 demo 分支中都不存在 demo/ 文件夹。

2) Move everything in "product/" one level down in the default branch, and remove the product/ directory. 2) 将默认分支中“product/”中的所有内容向下移动一级,并删除 product/ 目录。

The second part seems simple enough and can be done with simply "hg mv" on all files and folders stored in product/ to one level below.第二部分看起来很简单,只需在 product/ 中存储的所有文件和文件夹上使用“hg mv”即可完成。 So I think that will work as long as hg mv handles the fact that the path for all files in the product/ directory tree change.所以我认为只要 hg mv 处理 product/ 目录树中所有文件的路径更改的事实,这就会起作用。

The first issue is what I'm having trouble with.第一个问题是我遇到的问题。 Specifically, how to do without losing all the history of files contained in demo/.具体来说,如何在不丢失 demo/ 中包含的所有文件历史记录的情况下做。 After some reading, hg rebase doesn't seem like a solution.经过一些阅读,hg rebase 似乎不是一个解决方案。 There's a ton of history here (this repository was originally CVS, then migrated to SVN, now is in Mercurial).这里有很多历史(这个存储库最初是 CVS,然后迁移到 SVN,现在在 Mercurial 中)。 I searched for solutions to this issue and all of them focused on moving entire changesets to a different branch, which is not what I desire.我搜索了这个问题的解决方案,他们都专注于将整个变更集移动到不同的分支,这不是我想要的。 What would be the best approach for me to take here?我在这里采取的最佳方法是什么?

If I understand right, this would take 3 steps.如果我理解正确,这将需要 3 个步骤。

Step 1第1步

  • in the default branchdefault分支中
  • move "product/"移动“产品/”
  • commit ( commit A )提交(提交 A

Step 2第2步

  • still in the default branch仍然在default分支
  • move "demo/"移动“演示/”
  • merge or create demo branch (commit B )合并或创建demo分支(提交 B

Step 3第 3 步

  • update to commit A (should be back in the default branch)更新到提交 A (应该回到default分支中)
  • remove "demo/"删除“演示/”
  • commit ( commit C )提交(提交 C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM