开发者

Combining multiple repositories of multiple projects into a single repository of an over-arching solution in Visual Studio 2010?

开发者 https://www.devze.com 2023-02-19 17:27 出处:网络
Suppose I have two Visual Studio 2010 projects, both in the same solution. One project is a dll library for perform开发者_如何学Cing task x. And the other is a Windows Forms GUI Frontend for that lib

Suppose I have two Visual Studio 2010 projects, both in the same solution.

One project is a dll library for perform开发者_如何学Cing task x. And the other is a Windows Forms GUI Frontend for that library.

Let's also suppose that I started developing both these projects using two different mercurial repositories, (one for each project).

Suppose I wanted to combine these two repositories into one repository of the overarching solution of both projects (without losing any of my commit messages).

Would this be possible (or even for that matter a good idea?)


You bet! Here's the short answer: https://www.mercurial-scm.org/wiki/MergingUnrelatedRepositories

Let's say you have two repositories

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         3/24/2011   7:33 AM            r1
d----         3/24/2011   7:35 AM            r2

Here's r1:

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         3/24/2011   7:33 AM            .hg
-a---         3/24/2011   7:33 AM         85 file1.txt

Here's r2:

Mode                LastWriteTime     Length Name
----               -------------     ------ ----
d----         3/24/2011   7:35 AM            .hg
-a---         3/24/2011   7:33 AM         89 file2.txt

We'll make create another repository called "merged" by cloning "r1".

$>hg clone r1 merged
updating to branch default
resolving manifests
getting file1.txt
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$>cd merged

Now we need to pull "r2" in:

$>hg pull -f ..\r2
pulling from ..\r2
searching for changes
warning: repository is unrelated
2 changesets found
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)

Finally, we need to merge them together and commit the changes:

$>hg merge
resolving manifests
getting file2.txt
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$>hg commit -m "Merged two both repos"
file2.txt
committed changeset 4:40028ef336d9

All done! Here's our merged repo:

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         3/24/2011   7:36 AM            .hg
-a---         3/24/2011   7:36 AM         85 file1.txt
-a---         3/24/2011   7:36 AM         89 file2.txt

Let's see what we've got in history...

$>hg log
changeset:   4:40028ef336d9
tag:         tip
parent:      1:464b7426220c
parent:      3:3b5eba6d03ef
user:        Joe Schmoe <schomej@inter.net>
date:        Thu Mar 24 07:36:58 2011 -0700
description:
Merged two both repos

changeset:   3:3b5eba6d03ef
user:        Joe Schmoe <schomej@inter.net>
date:        Thu Mar 24 07:35:02 2011 -0700
files:       file2.txt
description:
Added second line to second file

changeset:   2:c26449adfb4d
parent:      -1:000000000000
user:        Joe Schmoe <schomej@inter.net>
date:        Thu Mar 24 07:32:52 2011 -0700
files:       file2.txt
description:
Added first line of second file

changeset:   1:464b7426220c
user:        Joe Schmoe <schomej@inter.net>
date:        Thu Mar 24 07:33:47 2011 -0700
files:       file1.txt
description:
Added second line to first file

changeset:   0:51cb60e8a68a
user:        Joe Schmoe <schomej@inter.net>
date:        Thu Mar 24 07:31:59 2011 -0700
files:       file1.txt
description:
Added first line to first file

Success!

0

精彩评论

暂无评论...
验证码 换一张
取 消