<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Tony Smith's P4Ruby Library - Perforce Public Depot</TITLE>
<META content="text/html; charset=iso8859-1" http-equiv=Content-Type>
<LINK REL="stylesheet" TYPE="text/css" HREF="../../shared/rubystyle.css">
</HEAD>
<BODY>
<table width="100%" border=0>
<tr>
<td>
<img src="../../images/ruby2.jpg">
</td>
<td>
<H2>P4Ruby Library: Scripts/Modules for use with P4Ruby</H2>
</td>
</tr>
</table>
<h3>Introduction</h3>
<p>
I've started to put together some commonly used/requested scripts both
to provide examples of good scripting using
<a href="../API/Ruby/index.html">P4Ruby</a>
and also to solve some common problems in what I hope is an efficient way.
<p>
I hope that over time, this will grow into a fairly broad range of
resources for Perforce users.
</p>
<p>
<b>
All of these scripts require you to install
<a href="http://www.ruby-lang.org">Ruby</a> and
<a href="../API/Ruby/index.html">P4Ruby</a>
</b>
</p>
<h3>Library Contents</h3>
<ol>
<li><a href="#triggers">Triggers</a>
<li><a href="#lib">Library Modules</a>
<li><a href="#utils">General Purpose Scripts</a>
</ol>
<h3>Support</h3>
If you have any problems or questions with these scripts you can
contact me at
<a href="mailto:tony@perforce.com">tony@perforce.com</a> or
<a href="mailto:tony@smee.org">tony@smee.org</a>. These scripts are
not supported by Perforce Software, but by me personally. I'll answer
questions as quickly as I can.
<a name="triggers">
<h3>Triggers</h3>
These are some example trigger scripts. The documentation for all of these
scripts is
<a href="triggers/doc/index.html">available here</a>.
<h4>Common files</h4>
<p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Script</th>
<th>Description</th>
</tr>
<tr>
<td><a href="triggers/P4Triggers.rb">P4Triggers.rb</a></td>
<td>
A generalised framework for implementing Perforce triggers
used by all of the other scripts. If you're going to use these scripts
at all, you'll need this file to be installed in the same directory
as the scripts themselves.
</td>
</tr>
</table>
<h4>Pre-Submit Triggers</h4>
<p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Script</th>
<th>Description</th>
</tr>
<tr>
<td><a href="triggers/checkjob.rb">checkjob.rb</a></td>
<td>
Ensures that all changelists are associated with a job before
they can be submitted. This is the simplest example of using
my trigger framework.
</td>
</tr>
<tr>
<td><a href="triggers/checktype.rb">checktype.rb</a></td>
<td>
Ensures that new files being added/branched have the correct Perforce
filetypes. Whilst "p4 typemap" goes a long way towards ensuring
filetype consistency, it's easily overridden. Since a user cannot
override a trigger, sysadmins who want more enforcement may want
to use this trigger.
</td>
</tr>
<tr>
<td><a href="triggers/checkcase.rb">checkcase.rb</a></td>
<td>
Script to ensure that new files being added/branched respect
the case of existing directories in the path. For example, if
//depot/test/fileA already exists, then this script will reject
an attempt to add //depot/TEST/fileB or //Depot/test/fileB for
that matter.
<p>
This is very useful if you have Windows clients or if your Perforce
server runs on Windows. In an all Unix environment it's not so
much of a problem.
</td>
</tr>
</table>
<p>
<h4>Post-Submit (Commit) Triggers (2004.2 and later)</h4>
<p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Script</th>
<th>Description</th>
</tr>
<tr>
<td><a href="triggers/autointeg.rb">autointeg.rb</a></td>
<td>
A script for keeping a slave branch in sync with its master. Whenever
a change is submitted to the master branch, it's automatically
propagated to the slave via this commit trigger. The files that are
integrated can be limited both by the trigger spec, and by the branch
spec used.
</td>
</tr>
</table>
<h4>Spec Triggers (2004.2 and later)</h4>
<p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Script</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><a href="triggers/defaultclient.rb">defaultclient.rb</a></td>
<td>out</td>
<td>
A small script to ensure that the default client view for all new
clients that are created are based on the view of an existing template
client. This allows system administrators to define a default client
mapping only a small section of the depot, and by default that's all
new users will see when they create their clients.
</td>
</tr>
</table>
<a name="lib">
<h3>Library Modules</h3>
<p>
Useful library modules you may want to use in your apps
</p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Module</th>
<th>Description</th>
</tr>
<tr>
<td><a href="lib/p4table.rb">p4table.rb</a></td>
<td>
<p>
A module that allows you to use a Perforce repository as a database.
Using Perforce as a database is surprisingly powerful. You get a fast
database engine capable of storing anything and with automatic
indexing of record fields.
</p>
<p>
p4table.rb stores the fields for every record as a job and then
versions the job in the depot. It also allows you to attach files
to records and versions them too. Using Perforce jobs ensures that
all records are indexed and searchable.
</p>
<p>
See the <a href="lib/doc/index.html">Documentation</a> for more
information.
</p>
</td>
</tr>
</table>
<a name="utils">
<h3>General Purpose Scripts</h3>
These are some useful non-trigger scripts
<p>
<table border="1" cellspacing="0" cellpadding="5" width="95%">
<tr>
<th>Script</th>
<th>Description</th>
</tr>
<tr>
<td><a href="scripts/integrename.rb">integrename.rb</a></td>
<td>
A script to integrate changes using a branch view and attempt to
follow renames in both the source and target branches. Early alpha
state at the moment.
</td>
</tr>
<tr>
<td><a href="scripts/oldclients.rb">oldclients.rb</a></td>
<td>
A script to find the oldest <n> clients - useful to locate
candidates for deletion.
</td>
</tr>
<tr>
<td><a href="scripts/reversechange.rb">reversechange.rb</a></td>
<td>
A script to back out a specified change. Handles many cases, but
may be defeated by older changes. See the notes in the script
for more information.
</td>
</tr>
</table>
<p>
</BODY></HTML>
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #11 | 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. |
||
| #10 | 4656 | Tony Smith |
Rework the defaultclient.rb trigger to be more robust and more efficient. This involved a certain amount of rework to the P4Triggers.rb module to include functionality that will be useful to other spec triggers - there's a new class P4Trigger::FormFile that helps scripts manage their interaction with the temporary formfile supplied by the server. |
||
| #9 | 4654 | Tony Smith |
Add an example spec trigger to show how you might restrict the default view for all new clients to a pre-defined set of mappings. |
||
| #8 | 4640 | Tony Smith |
Add a sample post-commit trigger that can be used to keep a master and slave branch in sync. |
||
| #7 | 4544 | Tony Smith |
Update index page to make it clearer that you must have P4Ruby to use these scripts. |
||
| #6 | 4258 | Tony Smith | Update index page to include new script | ||
| #5 | 4254 | Tony Smith | Convert P4Ruby pages to CSS style sheet instead of horrid tags. | ||
| #4 | 4249 | Tony Smith |
Add a script to back out a change. Features: * Prepares a fresh pending changelist with the files needed to back out the change. * Attempts to resolve merges for backing out older edits using "p4 resolve -am" * Leaves conflict resolution (if any) to the user Shortcomings are numerous, but include: * Does not (yet) re-branch deleted branched files. * Does not handle filetype changes (yet). The odds of success are highest with new changes. For older changes things are much more complicated and you can expect to have some work to do. |
||
| #3 | 4243 | Tony Smith |
Add my script to follow renames when integrating using a branchview. Lots of limitations, and I'm sure it doesn't catch everything but it does try to handle renames in both source and target. |
||
| #2 | 3637 | Tony Smith | Add RDoc documentation to the sample triggers. | ||
| #1 | 3634 | Tony Smith |
Kick off a library of P4Ruby resources with some sample trigger implementations based on Jeff Bowles and Wes Peters' scripts. These are not strict ports of their scripts to P4Ruby, but are roughly in the same area. |