Perforce's change review functionality allows users to be notified via email whenever files that they're interested in have been updated in the depot. Since change review is provided via a background Perl script, or daemon, this functionality can be modified. Other daemons can be created to perform entirely different functions.
Providing Change Review Parameters
Any user wishing to receive email notification of changed files must provide two pieces of information to the Perforce server: her email address, and a list of the files and directories that she wants to track (or subscribe to). This information is provided in the p4 user
form.README
or document files are changed. She types p4 user
and fills in the resulting form with her email address and file review list:
User: sarahm
Email: [email protected]
Update: 04/29/1997 11:52:08
Access: 04/29/1997 11:52:08
FullName: Sarah MacLonnogan
Reviews:
//depot/doc/...
//depot/.../README
Review:
list are changed. This includes all README
files, and all files in the doc
subdirectory.p4 user
form Reviews:
specification. Running the Daemon
Change review is implemented via a Perl script, perfreview.perl
, which can be downloaded from
http://www.perforce.com/perforce/loadsupp.html
This review daemon must be run under Perl 4 or higher; Sendmail is also required. It's usually run from the p4d
server account, in the same directory as the p4d
server, although it can be installed anywhere. Once it's been installed, do the following:
P4PORT
is set the proper port so the review daemon can communicate with the p4 server.
perfreview.perl
in the background, with
perfreview.perl &
The daemon is implemented as follows:
p4 review
;
p4 reviews
is used to generate a list of reviewers for each of these changelists;
p4 describe
changelist description to each reviewer;.
p4 reviews
and p4 describe
, are straightforward reporting commands. The p4 review
command used in step 1 is rather unusual. All these commands are described below.
p4 review
command exists to facilitate this process; it was written solely to support daemon creation and is not likely to be run by an end user.Every line of output produced by
p4 review
has the following form:
Change changenum user <email_addr> (Full_Name)For example:
Change 6 edk <[email protected]> (Ed Kuepper)
When used with no parameters, p4 review
will output one line for every changelist that has ever been submitted. With the addition of review marker arguments, p4 review
can limit its output to only those changelists not already reported. A review marker is simply a named counter; each review marker can separately track which changelists have and haven't yet been reviewed.Review markers are used in two variants of
p4 review
:
Review markers work by storing one counter per review marker in the Perforce database. The first variant of
p4 review
above sets a counter value for a particular review marker; the second variant gets the change information for all changelists numbered above that counter. The review daemon's review marker is called changerev
; the daemon uses p4 review -t changerev
to get a list of all unreviewed changelists, and uses p4 review -t changerev -c
lastchangenum to store the highest numbered reviewed change number in the database under the name changerev
.perfreview.perl
daemon's review marker is named changerev
; if you're using perfreview.perl
and are writing your own daemon, don't name the review marker changerev
.journal
, job
, and change
are used internally by Perforce; use of any of these three names as review markers could corrupt the Perforce database! A Protections Warning
The change review daemon runs at the access level of the user who invokes it (typically root
), not at the access level of the user receiving email. Thus, if the daemon is edited to perform additional functionality, it should not mail out the contents of files unless it is safe for all users to see those files, since a user needs only list
access in order to invoke the p4 user
command to subscribe to particular files. Creating Other Daemons
To create another daemon, use perfreview.perl
as a starting point and change it as needed. One such daemon might upload Perforce job information into an external bug tracking system after changelist submission. It would use the p4 review
command with a new review marker to list new changelists, and use p4 fixes
to get the list of jobs fixed by the newly submitted changelists. This information might then be fed to the external system, notifying it that certain jobs have been completed.[email protected]
. Change Review Reporting
p4 reviews
provides a list of all users who have subscribed to review any files. To see a list of reviewers for the files affected by a particular changelist, use p4 reviews -c
changenum. This command can also be used to report the reviewers of just those files that are provided as arguments on the command line.p4 users
provides a list of users current known to the p4d
server. The report includes user names, their email addresses, their full names, and the last time they logged in.