How to migrate from Mercurial (hg) to Perforce (p4)?
I've got a Mercurial database that I want to migrate to Perforce and preserve all the changes开发者_StackOverflow社区. Tell me a way I can do this.
Update Mar/2013:
Just to make the informations up to date:
svn -> p4
There is a new tool called p4convert-svn: p4convert-svn doc
Beware of filesystem case in/sensitivity.
hg -> p4
Following tool is not mentioned a lot, but it's recommended by perforce support:
hg convert p4 sink depot
It adds p4 sink into hg convert extension. Disadvantage is that it fits in mercurial 1.7.3 which is a bit outdated as of today (current is 2.2.5). It can be merged by hand easily into 2.0.2 version which may be sufficient even for largefile extension users.
For more information read file Readme-P4.txt in the depot.
One way that I thought of doing this is to clone the repository into my workspace and execute a python script to do the migration. The script would loop through each revision starting with 0 and ending with the tip, checking in files to p4 along the way.
I figure that I can get all the changeset comments via the log
command, then I can use hg log -r i --template {rev}: {file_adds}|{file_dels}|{file_mods}\n
, where i
is the current revision, to get the files that were added, removed, renamed, etc. When I notice that I'm on a new branch, I can check for the branch in P4 and create it if necessary.
At the end of the day, all that stuff should be checked in accordingly to P4.
Take a look at the Perforce section of the Mercurial wiki page on Converting Repositories. There seems to be support for pushing changes from Mercurial to Perforce.
I have recently started researching how to migrate an Alienbrain repository to Perforce. As there are no tools publicity available to do this, my research had lead to several resources on how to write your migration program.
Read the "Migration Planning Guide" on the Perforce website (pdf link). The document is written for ClearCase to Perforce, however the three approaches are still relevant. In particular, have a look at the "Baseline Branch Import" technique to see if that would make sense for you.
Download a copy of svn2p4sync from Tigris (link) as it is one of the most tested migration scripts available. Whilst on the Tigris site, read the svn2p4sync release notes/issues page for a good history of how the script was developed (link).
I've also just found the Generic Conversion page (link) on the Mercurial wiki (thanks to the link in Wim Coenen answer).
Edit: for your specific case where there is a script, I would recommend you use the linked in Wim Coenen answer (link).
HTH,
精彩评论