Skip to main content
Migrate from Perforce to SVN
Toshi Dávila avatar
Written by Toshi Dávila
Updated today

Overview


There are 2 ways to migrate from Perforce to SVN:

  1. With p42svn

  2. With Git in the middle

In this tutorial, we will use p42svn which is a Perl script written by Ray Miller. It is currently hosted here. So let's get started!

1. Requirements


We will assume you already have p4 and SVN installed. So let's go directly to what you need!

1.1 Perl

Perl is already installed in Linux and UNIX systems, on windows you will have to install it. We will use ActivePerl but not its latest version because we will need P4Perl and it only supports perl 5.12, 5.14 or 5.16.

Once you download the file, double click on it to install it.


Accept the terms


Click on Next


And Install it!


And it's installed our Perl v5.16.3! To confirm perl is installed OK, open your CMD and type

$ perl -v


If your output looks like this:

$ This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-thread...


You have installed perl successfully.

1.2 Perforce Perl API

You can find it here


Let's double click on it and start!


Select Perl 5.16 API


Enter your assembla server and username


And we are ready to install it!


And we are done!


Note: If any perl package is not installed and you see errors while exporting your p4 repo, you will have to install them. You need to open the Perl Package Manager, to do it just press win + r and type ppm. Find the package you want to install > right click > Install > ctrl + enter.

1.3 Perforce C/C++ API

We will need this to build the Perforce Perl API. You can download it from:

Download it and extract its content. I did it under C:\.

1.4 Get the p42svn source code

Checkout the code using svn command:​

git clone git@github.com:trentfisher/p42svn.git


Now let's confirm if p42svn is working!

$ cd p42svn
$ perl p42svn.pl


The output should looks like this:

$ Must specify at least one branch or label...

2. Let's export the p4 into a dump file!


We will connect to Assembla and export our p4 repo into a dump file.

2.1 Connect to p4

If you have more than 1 p4 repository in assembla just make sure you are pointing to the right repository. To check on what repo you currently are type:

$ p4 info


If you want to change to a different repo, run this command:

$ p4 set P4CONFIG="C:\workspace_directory\p4config.txt"


Check again:

$ p4 info


If you are in the right p4, you will to login. User your assembla credentials:

$ p4 login
$ Enter password:


The output should looks like:

$ User toshidavila logged in.

2.2 Let's export our repo!

Make sure you are on the p42svn folder. Run the following command:

$ perl p42svn.pl --branch //depot/main=trunk --debug > Myp4.dump


This is how the output looks like:


Note: If you see an error about some files that can't be created because they already exist, open the p42svn.pl file with any text editor like notepad++ or sublime and go to line 1303 and edit UNLINK =>1 to UNLINK =>0, save it and run again the command.


If you check your p42svn folder, your Myp4.dump file is in there.

3. Finally let's load our dump file!

You have 2 options at this point. You can whether import your file into assembla or have a local SVN repo. Let's see how to do both.

3.1 Import your dump file into Assembla

To import your dump file, you will have to zip it. We only accept .zip or .gz.


You will also need a new and empty SVN repository in Assembla. You can install it from Admin > Tools page. Once it is installed, go to your SVN repo > Import/Export and you will see 2 options:

  1. Upload a local .zip file

  2. Upload from a web directory - Use this option if your file is bigger than 200MB and make sure the URL is the direct downloadable link.

3.2 Import your dump file locally

We need an SVN repo for our dump file. Let's create one.

$ cd ..
$ svnadmin create MyP4Repo


It creates an SVN repository called MyP4Repo. Now we need to load our dump file into our SVN repo.

$ svnadmin load --force-uuid MyP4Repo 


Note: Don't forget to replace your current path where your file is, or you can move the file where you are and just enter its name.

$ svnadmin load --force-uuid MyP4Repo 


The output looks like this:


If you look at your SVN repo, you will see your MyP4Repo folder doesn't contain your files. But don't worry, they are there. You can run this command:

$ svnlook tree MyP4Repo


You will see your files in there


The final step is to check them out!

$ svn checkout file:///C:/Users/toshi/MyP4Repo/


And this is how it looks like


If you have any questions or need assistance. Please always feel free to email us at support@assembla.com. We will be happy to assist.

Did this answer your question?