Import Mode (front door)
Subversion revisions are imported into a running Perforce Server. The Perforce Server could be new or contain existing data, but it must be running. Subversion revisions are added sequentially; file content is 'imported' and metadata such as file attributes, descriptions, dates and usernames are added to the Perforce changelist.
The recommended use of 'Import Mode' is to start a new Perforce server to import each Subversion revision into a Perforce changelist. Using this method will produce a one-to-one mapping of Subversion revision numbers to Perforce changelists. The new Perforce server can be used in isolation to confirm the success of the migration and then merged with an existing Perforce Server using the 'perfmerge++' tool.
Convert Mode (back door)
SVN revisions are converted in full, creating a Perforce journal and set of archive files. Once replayed the resulting conversion is just as if the changes had always been in Perforce. The results can be merged into an existing Perforce Server using 'perfmerge++'. The Import mode is considered to be the safest method as all files are imported through a Perforce Client. However, the Convert mode is significantly faster and requires less user interaction.
Convert mode is an advanced feature and should only be attempted by a Perforce expert familiar with replaying and upgrading databases. Incremental conversions are not supported using Convert mode; however the slower Import mode can be used after the a conversion to update the migration.
Incremental Updates (front door)
Incremental updates are possible only using the Import mode where new revision from Subversion are imported into Perforce. However, no changes should be made to the import area of the Perforce Server or conflicts may occur.
p4convert is supplied by Perforce Software in the hope that it will be useful. It is a support utility, not a Perforce product. All use of this software is at the user's own risk and subject to the following terms and conditions.
THIS SOFTWARE IS PROVIDED BY PERFORCE SOFTWARE, INC. 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Resource Tips:
Running some conversions, particularly in Conversion Mode can be very memory intensive, as we keep a mapping of revisions and integrations in memory. For large conversions or conversions with excessive branching, more memory will needed by the JVM.
The--info
option will scan the Subversion dump file and report usage data to help estimate the required memory for Convert Mode. For example:
java -jar p4convert.jar --info <path_to_svn_dumpfile>
Use the-Xmx
flags to increase the memory allocated to the JVM. For example, to allocate 64GB (65536MB) use:java -Xmx65536M -jar p4convert.jar myConfig.cfg
Operating System |
10.2 |
13.1 |
Ubuntu 10.04.4 |
supported |
supported |
Darwin 11.4.0 |
supported | supported |
Windows 7x64 |
supported | supported |
SunOS 5.10 |
supported | supported |
Download the self-contained JAR from Perforce and check that Java SE runtime is installed with version 1.7 or greater.
For usage details, execute the jar with no options (this will generate a default configuration file):java -jar p4convert.jar
WARNING: No configuration file specified... Usage: java -jar p4convert.jar <config file> java -jar p4convert.jar --version java -jar p4convert.jar --info <dump file> java -jar p4convert.jar --users <dump file> java -jar p4convert.jar --extract rev.node <dump file> Generating default config file 'default.cfg'...
java -jar p4convert.jar config.txt
Both the Import and Convert modes require a Subversion dumpfile as the history data source. A dumpfile can be generated in several different ways; two of which are detailed below:
svnadmin dump local_repo_path > dumpfile.dmp
Replace local_repo_path with the path to the
Subversion repo. Do not use the '--delta'
flag option
as the results cannot be parsed by the conversion tool.
rsvndump url > dumpfile.dmp
Replacing url
with the remote Subversion server. For
example: http://
or file:///
or svn://
.
Note that for large servers generating the dump file locally is
significantly faster, you might also consider creating a local copy
of the subversion depot using svnsync,
before generating the dump file.
java -jar p4convert.jarOnce you have "
WARNING: No configuration file specified... Usage: java -jar p4convert.jar <config file> java -jar p4convert.jar --version java -jar p4convert.jar --info <dump file> java -jar p4convert.jar --users <dump file> java -jar p4convert.jar --extract rev.node <dump file> Generating default config file 'default.cfg'...
default.cfg
" copy it to "yourconfig.cfg
"
and then customize it as needed for the conversion.
com.p4convert.svn.dumpFile=/Users/pallen/MyDumpFile.dmp
true
' for Import mode and 'false
'
for Conversion mode
com.p4convert.svn.mode=true
//import/...
com.p4convert.core.depotPath=import
//import/sub/...
(Note that the path must end with a '/' even if no path is used)
com.p4convert.core.subPath=sub/
(Default: com.p4convert.core.subPath=/)
startRevision
' and 'endRevision
'.
The default is to start at revision 1 and import all revisions,
defined by setting 'endRevision
' to 0.
com.p4convert.svn.start=1
com.p4convert.svn.end=0
com.p4convert.svn.start=1
com.p4convert.svn.end=100
Importing Subversion ranges:
start: 1
end: 100
last: 23000
com.p4convert.svn.start=101
com.p4convert.svn.end=200
# exclude Subversion tags:Then start the conversion to verify the map:
^tags/.*
pallen-mac:main$ java -jar dist/p4convert.jar Config/foo.cfg loading ChangeMap: changeMap.txt loading TypeMap: types.map importing revisions: 1 to 20635 out of 20635 exclude.map: ^tags/.* Verifying exclusion map... issue: tags/rel-1.0.14/api issue: tags/rel-1.0.14/sys issue: tags/rel-2.0.3Looking at the reported issues the tags 'rel-1.0.14' and 'rel-2.0.3' have some actions that conflict with our exclusion, to resolve this simply add the exclusions to the 'include.map' file:
Issues found, saving issue map... Caught EXIT shutting down ...
# issues reported for tags/ folder
^tags/rel-1.0.14/.*
^tags/rel-2.0.3/.*
com.p4convert.adv.offset=0
com.p4convert.log.changeMap=changeMap.txt
A changemap looks like this:
# <Change>, <SVN revision>
1, 1
2, 2
3, 3
...
The following Unicode enable options apply to Unicode support for 'Import Mode' and 'Convert Mode'. The Charset options are only applicable to 'Import Mode', when translating a file through the Perforce client. In 'Convert Mode' archive files are always written in UTF-8 for a Unicode enabled Perforce server.
Defaults (for non-Unicode servers):A UTF8 client example: (for a full list see 'p4 help charset')com.p4convert.p4.unicode=false com.p4convert.p4.charset=<none>
For Unicode conversions set the JVM arg:com.p4convert.p4.unicode=true com.p4convert.p4.charset=utf8
Some Solaris and Linux conversions may need the locale set:-Dfile.encoding=UTF-8
Once a Perforce server is switched to Unicode enabled mode (export LC_ALL=en_GB.UTF-8
-xi
), all client workspaces need to define a character set. (For details see: http://kb.perforce.com/article/524). Note: A non-Unicode enabled Perforce Server will accept UTF16 files.
Normalisation
Platform Unicode normalisation is detected when the configuration file is generated, however it can be changed by setting the following configuration option to 'NFC
' or 'NFD
':
The default detection is based on the following:com.p4convert.svn.normalisation=NFD
Platform
Normalisation
Windows
NFC
Mac
NFD
*nix / *nux
NFC
Sun
NFC
Subversion Properties
By default the converter parses Subversion properties as UTF-8 strings. The conversion uses properties such as
svn:log
,svn:author
for attributes in Perforce and must decode the byte sequence to UTF-8. In some data sets Windows users may have added high ASCII characters in one or more code pages. This release now supports a configuration option:com.p4convert.svn.propTextType=UNKNOWN
The following strings denote the supported char-sets:
UNKNOWN Big5 Shift_JIS windows-1251 US-ASCII ISO-2022-JP ISO-8859-1 windows-1254 UTF-8 ISO-2022-CN ISO-8859-2 windows-1252 UTF-16BE ISO-2022-KR ISO-8859-5 windows-1256 UTF-16LE GB18030 ISO-8859-6 IBM424_rtl UTF-32BE EUC-JP ISO-8859-7 IBM424_ltr UTF-32LE EUC-KR ISO-8859-8 IBM420_rtl BINARY KOI8-R ISO-8859-9 IBM420_ltr The first scan is always 'UTF-8' followed by the configuration option. BINARY implies a skip and the string
<binary property>
is inserted.
Directory Properties
The following options allow Subversion Directory Properties to be stored as versioned files in Perforce:
To enable this mode set the following property to 'true
'To select the property name and format (Note: only 'com.p4convert.svn.propEnabled=true
ini
' mode is supported)com.p4convert.svn.propEncoding=ini com.p4convert.svn.propName=.svn.properties
Empty changelists
The following property will attempt to skip empty changes (where the change contains no revisions). This is typically the default behavior of the client or 'Import Mode' so is only really used in 'Convert Mode'.com.p4convert.adv.skipEmpty=false
Username translation
A username map file ('
users.map
') can be generated using the '--users
' option and then the right-hand-side modified with the new user name. The rename will only occur if the conversion tool finds theusers.map
file in the current working directory.Binary file detection
Binary files can be identified by adding their extensions to the type map file 'types.map'. The format is based on Perforce typemap spec, however it is limited to paths of the form '//....ext' (where .ext is the binary extension).
Default Type map (types.map):
TypeMap: binary //....zip binary //....gif binary //....png binary //....jpg binary //....dll binary //....class binary //....jar binary //....ecsfr
Modification bits (+mxwlk) are supported and can be added using the type mapping. Binary detection though the type map is recommended as conversion is much faster. Binary files not identified in the type map will be scanned by the ICU4J libraries and if no text/Unicode match is found they are assumed to be binary. Warning: ICU4J may incorrectly identify small binary files as text creating sync issues on Windows clients.
Changelist Description Format
The
logRevID
option can be used to reformat the Subversion revision descriptions to include the revision ID using the template:
<rev>
substituted with the Subversion revision<description>
substituted with the Subversion log
Default (as-is):
com.p4convert.svn.logRevID=<description>
Case Sensitivity
The platform case sensitivity is detected when generating the configuration file. There is normally no reason to change this behavior from the detected defaults. Conversions between different platforms should be avoided especially when converting from a case sensitive environment (such as Linux) to a case insensitive environment (such as Windows). The advanced case handling options supported are set using one of the following options:
com.p4convert.adv.caseMode=FIRST
NONE
- treat all paths as case sensitive (Linux).LOWER
- convert all paths to lower caseUPPER
- convert all paths to upper caseFIRST
- use the first encountered case combination (Windows)When using the Convert mode the generated Perforce archive files are based on the platforms case sensitivity. However on Linux platforms it can be useful to store archives files as if on a case insensitive server (
p4d -C1
). This can be simulated by setting the following option to 'true':Note: that if this option is set the path to the Perforce root directory, defined bycom.p4convert.adv.lowerCase=true
com.p4convert.adv.p4root
, must be in lower case and the case mode ofFIRST
must be used.RCS Keyword expansion (
svn:keywords
)By default RCS keyword expansion attributes are imported; however setting the configuration option:
com.p4convert.svn.keepKeyword=true
Setting a value of
false
will ignore all previous keyword attributes and import the files as normal text. See keyword notes for known issues.Merge Information (
svn:mergeinfo
)Supports SVN 1.5-1.7 merge information and calculates the corresponding Perforce integration credit for the various actions. The feature is not enabled by default and if required the following configuration option must be set to true:
com.p4convert.svn.mergeInfoEnabled=true
com.p4convert.svn.mode
'
to true
.:
' with '\:
')
com.p4convert.p4.port=localhost\:4444
com.p4convert.p4.client=svn-client
com.p4convert.p4.user=svn-user
com.p4convert.p4.clientRoot=/Users/pallen/ws/
com.p4convert.p4.passwd=PaSSwoRd
com.p4convert.svn.mode
'
to false
./
')com.p4convert.adv.p4root=/full/path/to/p4_root/
com.p4convert.adv.offset=0
com.p4convert.adv.jnlIndex=0
com.p4convert.adv.jnlPrefix=jnl.
true
')
com.p4convert.adv.downgrade=false
false
':
com.p4convert.adv.lineEnding=true
false
' will store the file
as 'binary
':
com.p4convert.p4.unicode=false
$ cd p4_root
$ p4d -r . -jr jnl.0
Perforce db files in '.' will be created if missing...
Recovering from jnl.0...
Perforce server info:
Server version 33 is replaying a version 0 journal/checkpoint.
Note: the Server version is set to 0 to remind the administrator that
an upgrade is required, see step 3.$ p4d -r . -jr jnl.0 jnl.1 ....
and with nohup:
nohup p4d -r . -jr jnl.0 jnl.1 .... &
$ p4d -r . -xu
Perforce db files in '.' will be created if missing...
2001.1: splitting db.integ into db.integed/db.resolve.
2001.1: splitting db.have into db.have and db.label.
2002.1: splitting pending db.change into db.changex.
2002.2: upgrading tempobj filetype in db.rev.
2002.2: upgrading tempobj filetype in db.working.
2003.1: initialize default depot.
2003.2: upgrading db.user.
2005.1: building db.revhx (headrev) table.
2005.1: building db.locks from db.working.
2005.2: building db.revdx (delrev) table.
2005.2: moving spec depot entries into db.revsx.
2007.3: (re)building haveMap from db.have/db.working.
2007.3: (re)building db.archmap (lazy-copy map) table.
2007.3: removing old db.archive.
2008.1: upgrading db.change.
2009.2: moving db.boddate/db.ixdate into db.bodtext/db.ixtext.
2009.2: removing db.boddate/db.ixdate.
2010.2: adding db.config.
2011.1: upgrading tiny.db.
...upgrades done
com.p4convert.p4.unicode=true
)
and users are going to continue to add Unicode content then you may
wish to set the server to Unicode mode. To enable Unicode run the
following command from the P4ROOT directory:
$ p4d -r . -xi
com.p4convert.adv.lowerCase=true
will have been used with the case mode set to com.p4convert.adv.caseMode=FIRST
. All p4d commands must be include the '-C1
' flag, this
includes the earlier step 1 and step 2.$ cd p4_root
$ p4d -C1 -r . -jr jnl.0
$ p4d -C1 -r . -xu
$ p4 verify -u //...
$Revision: 25005 $
(a change number in Perforce)
Another example is the keyword $Date$, which in Subversion gives
you the time as well...
$Date: 2006-02-17 12:09:10 +0000 (Fri, 17 Feb 2006) $
and in Perforce...
$Date: 2006/02/17 $
Here is a list of alternatives, (based on the above example):
$Revision$ ==> $Change$ gives $Change: 25005 $Due to the differences in keyword expansion the MD5 sum in Subversion is not valid for use in Perforce. This is why any keyword expanded files has an empty MD5 sum and why the
$Date$ ==> $DateTime$ gives $DateTime: 2006/02/17 12:09:10 $
p4 verify -u //...
command is
recommended in the 'Optional Steps' section.
com.p4convert.log.audit.enabled=true
com.p4convert.log.audit.filename=audit.log
A sample line of the audit log:
# <SVN path>, <SVN revision>, <P4 change>, <MD5 sum> trunk/src/foo.c, 1, 1, 1234567890abcdef1234567890abcdef
Please use or refer to the sample 'debug.log4j.xml' for logging options.java -Dlog4j.configuration=file:log4j.xml -jar p4convert.jar
com.p4convert.core.test
com.p4convert.core.version
com.p4convert.svn.emptyDirEnabled
com.p4convert.svn.emptyDirName
com.p4convert.adv.mimeTypes=false
Importing Subversion ranges: start: 1 end: 23091 last: 23091 1.0 A:D - trunk 1.1 A:D - trunk/src 1.2 A:F - trunk/src/foo.c (UTF-8) mapping: r1 => @1 2.0 A:F - trunk/src/bar.png (BINARY) mapping: r2 => @2 ...
Explanation of output lines, for example: 1.2 A:F -
trunk/src/foo.c (UTF-8)
The numbering '1.2' refers to the current Subversion revision and the node action. ('1' Subversion revision 1 and '.2' = the third node action as '.0' would be the first index)
The letters 'A:F' refers to the Subversion action and if it is a file or directory operation.
'trunk/src/foo.c'
is followed by the
detected type. Note: The detected type is based on language detection using ICU4J and not Subversion MIME or Perforce detection.
Detected type
Perforce base type
UTF-8
Unicode
UTF-16BE
utf16
UTF-16LE
utf16
UTF-32BE
Unicode
UTF-32LE
Unicode
Shift_JIS
Unicode
ISO-2022-JP
downgraded to binary
ISO-2022-CN
downgraded to binary
ISO-2022-KR
downgraded to binary
GB18030
Unicode
EUC-JP
Unicode
EUC-KR
Unicode
Big5
Unicode
ISO-8859-1
Unicode
ISO-8859-2
Unicode
ISO-8859-5
Unicode
ISO-8859-6
downgraded to binary
ISO-8859-7
Unicode
ISO-8859-8
Unicode
windows-1251
Unicode
windows-1254
Unicode
windows-1256
downgraded to binary
KOI8-R
Unicode
ISO-8859-9
Unicode
IBM424_rtl
downgraded to binary
IBM424_ltr
downgraded to binary
IBM420_rtl
downgraded to binary
IBM420_ltr
downgraded to binary
BINARY
binary
Finally 'mapping: r223 => @223
' refers to the
Subversion revision number ('r223
') to the Perforce
changelist number ('@223
'). Typically 1:1 unless offset or
merged against an live or pre-existing Perforce Server.
46.3 A:F - repo/trunk/my.file
WARNING: p4java: //import/repo/trunk/my.file - file(s) up-to-date.
In 'Conversion Mode' errors are reported as 'Panics' and an
exception is thrown.$ java -jar dist/p4convert.jar --extract 46.3 mysvndump.dump
searching for node: 46.3...
Node-path: repo/trunk/my.file
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 308
Text-content-md5: 6a339b6ccf2af72d77169ef29b98eb0b
Content-length: 318
PROPS-END
A file is then generated called 'node.46.3.dump
' and will
contain the Subversion record to be sent to Perforce. (The content
highlighted in green is the Subversion meta-data, also contained in the
file).