<html> <head> <title>P4Replicate</title> <style TYPE="text/css"> <!-- BODY {font: 12px/16px verdana, arial, sans-serif !important; text-align: left; margin-left: 2cm; color:#000000 !important;} .cell {font: 12px/16px verdana, arial, sans-serif !important; text-align: left; color:#000000 !important;} TD {font: 12px/16px verdana, arial, sans-serif !important; text-align: left; color:#000000 !important;} H1 {font: 18px/18px verdana, arial, sans-serif !important; text-align: left; color:#333333 !important;} H2 {font: 18px/18px verdana, arial, sans-serif !important; text-align: left; color:#333333 !important; font-weight: bold; margin-bottom: 14px} H3 {font: 14px/14px verdana, arial, sans-serif !important; text-align: left; color:#333333 !important; font-weight: bold; margin-bottom: 14px} pre { border-right: #646464 1px solid; padding-right: 0.5em; border-top: #646464 1px solid; padding-top: 0.5em; border-left: #646464 1px solid; padding-left: 0.5em; border-bottom: #646464 1px solid; padding-bottom: 0.5em; white-space: pre; background-color: #f6e6e6; color: black; margin-left: 1em; width: 90%; display: table; font-size: 100%; } --> </style> </head> <body> <h1><a name="top"></a>p4replicate</h1> <p>This script (<a href="p4replicate.rb">p4replicate.rb</a>) is written by <a href="http://public.perforce.com/guest/robert_cowham/pcp.html"> Robert Cowham</a> of Vaccaperna Systems Ltd.</p> <p>License - see <a href="license.txt">license.txt</a> (BSD).</p> <h2>This Utility now deprecated!</h2> <p>This script has not been actively maintained for years, and is now deprecated.</p> <p>There is a publically available <a href="https://swarm.workshop.perforce.com/files/guest/perforce_software/p4transfer"> equivalent utility called P4Transfer.py</a>. That utility has unit tests and takes account of more recent Perforce actions include move/add, move/delete and various other permutations. It works in a broadly similar way.</p> <h2>Overview</h2> <p>The script replicates changelists between a source and client p4 server (with caveats - see below).</p> <p>It is written in Ruby and uses the official version of P4Ruby (2007.3 or 2008.1) - available from the Perforce ftp site, e.g. <a href="ftp://ftp.perforce.com/perforce/r08.1/bin.ntx86/"> ftp://ftp.perforce.com/perforce/r08.1/bin.ntx86/</a>.</p> <h2>Configuration File</h2> <p>All the potential fields are shown below. Comments start with "#".</p> <p>Normal fields require "=" sign to specify, the View field is the only multi-line field.</p> <pre># I am a configuration file for p4replicate.rb src_p4port=1777 src_p4client=repl-client-src src_p4clientroot=c:\work\p4replicate\root src_p4user=robert # Comment out if no password # src_p4password= # The following is used to record which changelist we have processed. # Was originally src_counter but users often have more control over dest than src dest_counter=p4replicate dest_p4port=1777 dest_p4client=repl-client-dest dest_p4user=bruno # Comment out if no password #dest_p4password=bruno # The next 2 fields are required if email is to be used for notification of success or failure mail_server=smtp.somewhere.uk mail_from=rc@vaccaperna.co.uk # Comment out either of the following two fields to not receive email notification # Multiple addresses should be comma seperated #mail_success_to=success@vaccaperna.co.uk #mail_fail_to=fail@vaccaperna.co.uk,fail@somehwere.else # Note that this is a standard Perforce view but LHS is source repository # and RHS is destination repository # All the normal Perforce wildcards can be used. # If there are spaces in paths then use quotes. view: //depot/repl/src/... //depot/repl/dest/... "//depot/repl/src two/*" "//newdepot/repl/dest 2/*" </pre> <font SIZE="2"> <h2>Usage</h2> <p>Basic usage is either to specify the ini file on the command line or it assumes "p4replicate.ini" exists in current directory.<br> <br> Give "-v" option to output (lots of) debug info in case of error - otherwise just returns number of changelists transferred.</p> <pre>p4replicate.rb -v p4replicate.rb --verbose p4replicate.rb new.ini</pre> <pre><a href="file:///c:/work">c:\work</a>> p4replicate.rb Number of changes replicated: 1 Last change processed: 2917</pre> <pre><a href="file:///c:/work">c:\work</a>> p4replicate.rb Number of changes replicated: 0 Last change processed: 2917 </pre> <h3>Testing</h3> <p>For testing purposes you can use the same p4 server for source and dest. In between runs you will need to reset the p4replicate counter, e.g.</p> <pre>p4 counter p4replicate 0</pre> <p>(or some other value before first changelist to be replicated)</p> <p>Obliterate the dest files so that area is nice and clean.</p> <p>Note there is a <a href="test-p4replicate.rb">partial test harness</a> which needs to be considerably enhanced!</p> <h2>Notes</h2> <ul> <li><b>for any changelist that applied to more files than are in the replicate view, only the ones in the view are replicated - this can mean that changelists have different contents in source and target</b></li> <li><b>it can cause problems if you start replicating with a "narrow" view and then try and widen the view later (including more files), since there are now older changelists that have already been partially replicated. Basically it won't cope with this (and it is not obvious what the right behaviour should be - don't do it!).</b></li> <li>there is some commented out code to update existing source changelists descriptions but for those the user running the script must have superuser access</li> <li>it stores processed changelists in a counter and increment after processing (don't zap this counter!)</li> <li>expects to be only thing using the source/dest clients</li> <li>creates source and dest clients on the fly or update already existing ones (warning - make sure people don't try and use the clients reserved for this script) - these are done using the replicate view from the config file. Both source and dest clients share the same root directory so the files are synched into source and then are in the right place to be added for dest.</li> <li>the specified source and target views allow for spaces in filenames</li> <li>each individual changelist that applies to the source client is then processed and every file in the changelist is handled separately (add/branch -> add, edit/integrate -> edit, delete -> delete). Obviously branching history is lost.</li> <li>no changelists will be skipped over - so complete history of the file is replicated.</li> <li>this also copes with things like edit with no changes to files etc</li> <li>Use standard Windows scheduler ("at" command or Control Panel>Scheduled Tasks) to run on a regular basis as desired</li> </ul> </font> <p> <a href="#top">Top</a> </p> <p> Vaccaperna Systems Ltd 2005-8</p> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 9755 | Robert Cowham | Deprecate and add link to P4Transfer | ||
#5 | 7188 | Robert Cowham |
Optimize the fstats into a single call. Rename src_counter to dest-counter |
||
#4 | 6447 | Robert Cowham | Updated to use official P4Ruby | ||
#3 | 6422 | Robert Cowham | Change link | ||
#2 | 5159 | Robert Cowham | Tidied up docs. | ||
#1 | 5148 | Robert Cowham | Added replicate script |