This script (p4replicate.rb) is written by Robert Cowham of Vaccaperna Systems Ltd.
License - see license.txt (BSD).
The script replicates changelists between a source and client p4 server (with caveats - see below).
It is written in Ruby and uses the p4ruby API written by Tony Smith and available from the Perforce Public Repository.
All the potential fields are shown below. Comments start with "#".
Normal fields require "=" sign to specify, the View field is the only multi-line field.
# I am a configuration file for p4replicate.rb src_p4port=1777 src_p4client=repl-client-src src_p4clientroot=c:\Data\TTPCom\Scripts\root src_p4user=robert # Comment out if no password # src_p4password= src_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/*"
Basic usage is either to specify the ini file on the command line or it
assumes "p4replicate.ini" exists in current directory.
Give "-v" option to output (lots of) debug info in case of error - otherwise
just returns number of changelists transferred.
p4replicate.rb -v p4replicate.rb --verbose p4replicate.rb new.ini
c:\work> p4replicate.rb Number of changes replicated: 1 Last change processed: 2917
c:\work> p4replicate.rb Number of changes replicated: 0 Last change processed: 2917
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.
p4 counter p4replicate 0
(or some other value before first changelist to be replicated)
Obliterate the dest files so that area is nice and clean.
Note there is a partial test harness which needs to be considerably enhanced!
© Vaccaperna Systems Ltd 2005