Reputation: 33
When I started with Mercurial about a year ago I created one repository called SandBox to put all my projects in it, now about a year later I realize that wasn’t very smart choice I have 19 project in it some of them are big. I would like to give each project its own repository also keeping the history. Is there an easy way I accomplish this?
Upvotes: 3
Views: 101
Reputation: 6327
Take a look at the Convert extension: https://www.mercurial-scm.org/wiki/ConvertExtension
What you actually need is --filemap
: https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap
Upvotes: 1
Reputation: 27050
Well, consider a project with the following structure (in bitbucket):
$ find hgmultiproject
hgmultiproject
hgmultiproject/proj2
hgmultiproject/proj2/mysndfile
hgmultiproject/proj1
hgmultiproject/proj1/myfirstfile
hgmultiproject/proj3
hgmultiproject/proj3/mythirdfile
This project has this log:
revision: 7:6bbc26c1a34d
tag: tip
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:49:22 2012 -0300
summary: correcting
revision: 6:32c312e7072e
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 5:f332e0ecee4d
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:48:39 2012 -0300
summary: Moving to correct name
revision: 4:5850a93d80dd
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:48:05 2012 -0300
summary: More content on second file
revision: 3:0098ebd2cea5
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:47:41 2012 -0300
summary: A third file
revision: 2:096c984a8f2a
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 1:b9491918efcc
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:46:52 2012 -0300
summary: My second file
revision: 0:4e429ac2fee9
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
You can extract the projects using the Convert extension with the --filemap option.
How to do it? First, you should create a filemap file. In this case, the content should be:
rename proj1 .
exclude proj2
exclude proj3
The first line will move everything inside the proj1
dir to the root of the new repository. The second line will remove the proj2
dir from the new repository, and the third line will remove the proj3
.
To use it, just call this way:
$ hg convert --filemap proj1filemap hgmultiproject/ extracted-proj1
Now, enter the new repo:
$ cd extracted-proj1/
It has no working copy...
extracted-proj1 $ ls
y but you just need to update:
extracted-proj1 $ hg update
1 updated files, 0 merged files, 0 deleted files, 0 nonresolved files
extracted-proj1 $ ls
myfirstfile
And the new log is...
extracted-proj1 $ hg log
revision: 2:eb31727c0df8
tag: tip
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:48:55 2012 -0300
summary: Adding period
revision: 1:e701f0ad5335
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:47:09 2012 -0300
summary: More content on 1st file
revision: 0:c0b6ad18ff22
user: Adam Victor Nazareth Brandizzi <[email protected]>
date: Wed Aug 08 11:46:23 2012 -0300
summary: My first file
You should follow these steps for each project of your repository.
Upvotes: 3