Miscellaneous Utilities | Back to Table of Contents |
p4abuse.pl | p4abuse.pl is a small perl script designed to help a system administrator detect abuses of a Perforce system. Currently, it will highlight two common errors: using a client from multiple hosts, and use of a client by multiple users. |
rename_depot.pl | rename_depot.pl allows a sysadmin to rename a Perforce depot whilst preserving the entire history of the depot. It does this by editing a checkpoint file, so the user must checkpoint their database first, and then recover from the edited checkpoint at the end. ALWAYS ensure that appropriate backups are taken before using this script. |
specsaver.rb | specsaver.rb versions all client/label/branch specs along with global data like typemaps, protections and jobspec. It requires a working build of P4Ruby from //guest/tony_smith/perforce/API/Ruby/... in order to work, but is much more efficient as a result. |
P4table.rb |
P4table is a Ruby module rather than a script. P4table allows you to treat a Perforce repository a bit like a database with the concept of tables and records. Each record is a Perforce job so the fields in the table are specified using the Perforce jobspec. Using jobs means that all records are indexed so you can search on any field. Additionally each record is also archived as a versioned text file so you not only have the records, but also all revisions of every record. WARNING: P4table was designed to be used against its own Perforce server (2-user download is fine). If you run it against an existing server or a server used for other data then you do so at your own risk Records may also have files attached to them. These files are just versioned and their names are stored in the "files" field in the jobspec. There's no documentation other than the code at the moment. That said, to get people started quickly the big hints are that your jobspec must
# A Perforce Job Spec Specification. # # Updating this form can be dangerous! # See 'p4 help jobspec' for proper directions. Fields: 101 job word 32 required 102 status select 10 required 103 owner word 32 required 104 modified_date date 20 always 105 note text 0 optional 106 sender line 32 optional 107 fax_number line 32 optional 108 files text 80 optional 109 date_received date 20 once 110 date_closed date 20 optional Values: status open/closed Presets: status open owner $user modified_date $now date_received $now Comments:A simple usage example might be something like this: #!/usr/bin/ruby $:.unshift( "." ) require "P4table" class FaxTable < P4Table def initialize super( "fax" ) end end P4Global.connect ft = FaxTable.new rec = ft.new_record rec._sender = "A.N. Other" rec._fax_number = "01252 861123" rec._note = "New fax received" pdf = rec.add_file( "fax.pdf" ) pdf.write( pdf_buffer ) rec.save( "New fax received from #{rec._sender}" )This would create a new job called "fax/nnnnnn" where the sequence number is taken from a counter called fax (using "p4 counter fax"). The job is then archived into the meta-data: file for the record (e.g //depot/fax/nnnnnn/meta ) and the pdf file is also archived in the same depot location. Note that the syntax "rec._fieldname" gives you direct access to the fields in the job form. Note also that P4Table is not (currently) thread-safe. That may change, but since I don't need it to be thread-safe it's not a priority. Docs are scarce at the moment - read the code. I'll add RDoc support to the code sometime. |