Commenting specs: fo_comment_spec.pl, fi_comment_spec.pl
Here are a couple of triggers that allow comments to be added to specs.
This will be of particular interest to those that would like to remember
why they have put that strange rule in the protection table six months
ago, or who requested that typemap in the depot !
The triggers allow adding comments persistently without having to resort
to invoking the p4 commands from wrapper scripts. They work like this,
taking the example of the protection table:
When running "p4 protect", the first of two triggers kicks in: a form-out
trigger on the protect spec reads the temporary form file generated by the
Perforce server, and matches lines to the keys of a hash table that is read
from a file (call it a comments file). If a match is found then the comment
is inserted just above its matching line in the temporary protection table
form file, which is presented to the superuser running the command.
The superuser can then edit the protection table, adding, changing or
removing comments and/or rules.
Once done, saving the protection table invokes a form-in trigger. This
trigger parses the protection table form that is full of comments, isolates
each comment in a hash keyed by matching spec rule, and saves the hash
to the "comments file".
Here's a typical trigger table entry to achieve the above.
record_comments form-in protect "/usr/local/bin/perl /home/perforce/triggers/fi_comment_spec.pl %formfile% /home/perforce/triggers/protect_comments.inc"
record_comments form-out protect "/usr/local/bin/perl /home/perforce/triggers/fo_comment_spec.pl %formfile% /home/perforce/triggers/protect_comments.inc"
--------------------------
Setting a default client: fo_customise_client.pl
Form-out trigger that kicks in whenever p4 client is invoked. The script
checks whether the client already exists, and if so exits without doing
anything. Using p4 info seems to be the least expensive way to do that.
Otherwise, the client form is modified for a site's preferred defaults.
Guillaume Barthelemy