使用 hg 将不同的项目与存储库合并到一个解决方案中?
我在 Visual Studio 2010 中启动了两个不同的项目,每个项目都有自己的 hg 存储库。
后来我决定这两个项目属于一个解决方案,因此属于一个 hg 存储库。
新的解决方案具有以下文件结构:
SolutionFolder
|---.hg
+---Lib
| ∟ dlls
+---Source
| ∟ Project_A
| ∟--.hg
| ∟ Project_B
| ∟--.hg
+---OverarchingSolution.sln
有没有一种方法可以将 Project_A
和 Project_B
的变更集合并到解决方案文件夹的存储库中吗?
从而导致:
SolutionFolder
|---.hg
+---Lib
| ∟ dlls
+---Source
| ∟ Project_A
| ∟ Project_B
+---OverarchingSolution.sln
Project_A
和 Project_B
的所有变更集都登陆到 SolutionFolder 的存储库中?
I started two disparate projects in Visual Studio 2010, each with their own hg repository.
Later I decided that the two projects belonged under one solution, and thus one hg repository.
The new solution the following file structure:
SolutionFolder
|---.hg
+---Lib
| ∟ dlls
+---Source
| ∟ Project_A
| ∟--.hg
| ∟ Project_B
| ∟--.hg
+---OverarchingSolution.sln
Is there a way that I can merge Project_A
's and Project_B
's changesets into the solution folder's repository?
Thus resulting in:
SolutionFolder
|---.hg
+---Lib
| ∟ dlls
+---Source
| ∟ Project_A
| ∟ Project_B
+---OverarchingSolution.sln
With all of the changesets from Project_A
's and Project_B
's landing in the SolutionFolder's repository?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您同意更改历史记录(即:使该项目的其他人的克隆无效),您可以使用“转换”扩展。
创建文本文件,我们将其命名为
rename-map-a.txt
其中这一行:然后进入
Source
并运行:对 B 重复相同的过程,以便现在你有了:
然后进入
SolutionFolder
并运行这些命令:如果有效,你可以删除(或者更好地移动到某个地方来备份这些目录:
让你得到你问题中的目标,话虽如此,请参阅我的其他答案,了解我认为更好的想法。
If you're okay with altering history (ie: invalidating everyone else's clones of this project) you can use the 'convert' extension.
Create text file, we'll call it
rename-map-a.txt
this line in it:Then go into
Source
and run:Repeat the same process for B so that now you have:
Then go into
SolutionFolder
and run these commands:If that worked you can remove (or better move somewhere for backup these directories:
leaving you with exactly what you have as the goal in your question, and with all history and everything tracked. That said, see my other answer for what I think is a better idea.
实现此目的的一种方法是使用
从不相关的存储库中提取 hg pull -f 。
这将导致存储库具有多个根。
您仍然会拥有两个存储库的历史记录,这些历史记录将由存储库中的两条开发线表示。
这里唯一的技巧是使目录结构正确。您希望合并存储库的根目录与组合存储库的根目录相匹配。
因此,对于您的情况,我会想象这样的事情:
查看 Mercurial Wiki
这是一个具有实际输出的通用示例:
One way you can do this is to pull from an unrelated repo, using
hg pull -f
.This will result in a repository that has multiple roots.
You will still have the history from both repos, which will be represented by two lines of development in the repository.
The only trick here is to get the directory structure right. You want to root of your merged-in repos to match the root of your combined repo.
So for your case, I would imagine something like this:
Check out the section beginning "It is possible to pull from completely unrelated repository..." in the Mercurial Wiki
Here is a generic example with real output:
如果您认为您有可能永远想要再次单独使用这两个存储库(即:在不同的解决方案中使用一个存储库,而不是另一个),那么您可以将它们作为新顶级的子存储库级别存储库。
为此,您只需 cd 进入
SolutionFolder
并创建一个名为.hgsub
的文件,其中包含以下几行:然后运行这些命令(仍在
SolutionFolder
中) >):之后,您可以使用附加的
--subreposstatus
、commit
等) code> 参数,它们将级联到子存储库中。If you think there's a chance you'll ever want to use those two repositories separately again (i.e: use one in a different solution but not the other) then you can just make them subrepositories of a new top level repository.
To do that you'd just cd into
SolutionFolder
and create a file named.hgsub
containing these lines:then you run these commands (still in
SolutionFolder
):After that you can do most all the normal Mercurial commands up in Solution Folder (
status
,commit
, etc) with an additional--subrepos
argument and they'll cascade down into the sub-repos.