Reputation: 4735
In the project I'm currently working on (say, name is "rinjani"), we have multiple mercurial repos (almost 10 separate repos!) and recently we want to transform it to a single repo.
Actual:
- rinjani-a
- rinjani-b
- ...
- rinjani-g
Expected:
rinjani
├── rinjani-a
├── rinjani-b
├── ...
└── rinjani-g
What's the best (safest) way to do this? I've read this following blogpost but still not sure whether that's the way to go since the example there is showcased for two separate repos only. We, of course, want to keep the history/changesets from each repo intact.
Upvotes: 0
Views: 61
Reputation: 178115
The blogpost is the basic way to do it, although the mv
and hg addremove --similarity 100
steps can be simplified using hg rename
.
Basic steps:
Example:
hg init rinjani
cd rinjani
hg pull -f <path_to>\rinjani-a
hg update tip
md rinjani-a
hg rename * rinjani-a
hg ci -m "renamed rinjani-a"
<repeat for other projects>
Then "hg merge" each of the heads together.
Of course this is completely safe, since all modifying operations are done only to the new repository. If you make a mistake, you can always start over!
Here's what a very simple graph might look like after preparing three repositories to be merged using the above scheme:
@ 5:renamed rinjani-c files
|
o 4:rinjani-c file
o 3:renamed rinjani-b files
|
o 2:rinjani-b file
o 1:renamed rinjani-a files
|
o 0:rinjani-a file
Then merge the heads (rev 1, 3, and 5 in this case). The key point is to modify the heads of the independent histories before merging them together:
@ 7:Merge
|\
| o 6:Merge
| |\
| | o 5:renamed rinjani-c files
| | |
| | o 4:rinjani-c file
| |
| o 3:renamed rinjani-b files
| |
| o 2:rinjani-b file
|
o 1:renamed rinjani-a files
|
o 0:rinjani-a file
Upvotes: 2