大约一年前,当我开始使用 Mercurial 时,我创建了一个名为 SandBox 的存储库来存放我所有的项目,大约一年后,我意识到这不是一个非常明智的选择,我有 19 个项目,其中一些很大。我想为每个项目提供自己的存储库,同时保留历史记录。有没有一种简单的方法可以做到这一点?
问问题
91 次
2 回答
3
好吧,考虑一个具有以下结构的项目(在 bitbucket 中):
$ find hgmultiproject
hgmultiproject
hgmultiproject/proj2
hgmultiproject/proj2/mysndfile
hgmultiproject/proj1
hgmultiproject/proj1/myfirstfile
hgmultiproject/proj3
hgmultiproject/proj3/mythirdfile
这个项目有这个日志:
revision: 7:6bbc26c1a34d
tag: tip
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:49:22 2012 -0300
summary: correcting
revision: 6:32c312e7072e
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 5:f332e0ecee4d
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:48:39 2012 -0300
summary: Moving to correct name
revision: 4:5850a93d80dd
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:48:05 2012 -0300
summary: More content on second file
revision: 3:0098ebd2cea5
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:47:41 2012 -0300
summary: A third file
revision: 2:096c984a8f2a
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 1:b9491918efcc
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:46:52 2012 -0300
summary: My second file
revision: 0:4e429ac2fee9
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
怎么做?首先,您应该创建一个文件映射文件。在这种情况下,内容应该是:
rename proj1 .
exclude proj2
exclude proj3
第一行会将proj1
目录中的所有内容移动到新存储库的根目录。第二行将proj2
从新存储库中删除目录,第三行将删除proj3
.
要使用它,只需这样调用:
$ hg convert --filemap proj1filemap hgmultiproject/ extracted-proj1
现在,输入新的仓库:
$ cd extracted-proj1/
它没有工作副本...
extracted-proj1 $ ls
y 但你只需要更新:
extracted-proj1 $ hg update
1 updated files, 0 merged files, 0 deleted files, 0 nonresolved files
extracted-proj1 $ ls
myfirstfile
新的日志是...
extracted-proj1 $ hg log
revision: 2:eb31727c0df8
tag: tip
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 1:e701f0ad5335
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 0:c0b6ad18ff22
user: Adam Victor Nazareth Brandizzi <brandizzi@gmail.com>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
您应该为存储库的每个项目执行这些步骤。
于 2012-08-08T15:06:16.703 回答
1
看看转换扩展:https ://www.mercurial-scm.org/wiki/ConvertExtension
你真正需要的是--filemap
:https ://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap
于 2012-08-08T14:53:22.577 回答