<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Tony Smith's Utilities - Perforce Public Depot</TITLE> <META content="text/html; charset=iso8859-1" http-equiv=Content-Type> <BODY bgColor=#ffffff> <CENTER> <A name=toc><H2>Perforce Utilities</H2></A> </CENTER> <br> Here are some scripts which I've written in the hope they will be useful to others. You them at your own risk.<br> <P> <TABLE border=0 cellSpacing=0 width="100%"> <TBODY> <TR> <TD bgColor=#ffcc66><A name=tools></A> <H2>Miscellaneous Utilities</H2> <TD align=right bgColor=#ffcc66 width="5%"><FONT size=-2><A href="#toc">Back to Table of Contents</A></FONT></TD> </TR> </tbody> </table> <p> <TABLE border=0 cellpadding="10" width="100%"> <TBODY> <tr> <td><a href="http://public.perforce.com//guest/tony_smith/perforce/utils/p4abuse.pl">p4abuse.pl</a></td> <td>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. </td> </tr> <tr> <td><a href="http://public.perforce.com//guest/tony_smith/perforce/utils/rename_depot.pl">rename_depot.pl</a></td> <td>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. </td> </tr> <tr> <td><a href="http://public.perforce.com//guest/tony_smith/perforce/utils/specsaver.rb">specsaver.rb</a></td> <td>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 <a href="http://public.perforce.com//guest/tony_smith/perforce/API/Ruby/index.html">//guest/tony_smith/perforce/API/Ruby/...</a> in order to work, but is much more efficient as a result. </td> </tr> <tr> <td valign="top"> <a href="http://public.perforce.com//guest/tony_smith/perforce/utils/P4table.rb">P4table.rb</a> </td> <td> <p> 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. <p> 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 <p> 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. <p> 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 <ul> <li>Contain only lowercase field names <li>Contain a field called "job" <li>Contain a field called "files" for attached files </ul> As a sample, here's the jobspec for our Fax tracking application which is based on P4table. <PRE> # 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: </PRE> A simple usage example might be something like this: <PRE> #!/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}" ) </PRE> 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. <p> Note that the syntax "rec._fieldname" gives you direct access to the fields in the job form. <p> 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. <p> Docs are scarce at the moment - read the code. I'll add RDoc support to the code sometime. </td> </tr> </TBODY> </TABLE> </BODY></HTML>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#11 | 5871 | Tony Smith |
Add script to incrementally convert large sets of archive files from Windows to Unix line endings using d2u. It is still a little unpolished, but it's a start and may be useful to others. |
||
#10 | 5870 | Tony Smith |
Add d2u source code for those who want to use it. dos2unix isn't suitable for Perforce migrations, and Perl can be too slow for large repositories. This small program does fast, accurate line ending conversion using the Perforce API |
||
#9 | 4677 | Tony Smith |
Move P4table.rb to the P4Ruby library and rename it to p4table.rb instead. There's an update coming so this is just the move. |
||
#8 | 3095 | Tony Smith | First batch of documentation for specsaver.rb | ||
#7 | 3093 | Tony Smith |
Move docs for P4Table in preparation for upcoming docs for specsaver.rb |
||
#6 | 2396 | Tony Smith |
Add RDoc documentation for P4Table.rb. Very pretty. |
||
#5 | 2393 | Tony Smith |
Publish P4Table Ruby module that allows you to treat a Perforce repository as a sort of relational database with inbuilt versioning of all its records. Very simple, but effective. |
||
#4 | 1909 | Tony Smith | HTML corrections. | ||
#3 | 1871 | Tony Smith |
First release of specsaver.rb a script to version all "specs" in your depot. Currently this means, clients/labels/branches and protections, typemaps and jobspecs. Groups and users to follow. It does not currently handle deletion of these objects. |
||
#2 | 1792 | Tony Smith | Change URL's to be direct webkeeper links instead of P4DB | ||
#1 | 1791 | Tony Smith | Correct case typo in index filename | ||
//guest/tony_smith/perforce/utils/Index.html | |||||
#3 | 544 | Tony Smith |
Deleted Journal parsing scripts as they will be sent out only on request. |
||
#2 | 543 | Tony Smith |
Added my Checkpoint/Journal parsing perl module to the depot. Now supports an OO interface to journal records and to the parsing in general. |
||
#1 | 414 | Tony Smith | First implementations of some of my p4 scripts. |