Trigger Form Output Changes in 2007.3 and Later

Output on trigger success can interfere with saving forms

SUMMARY

Beginning with the 2007.3 version of the Perforce Server, output for triggers that succeed is passed to standard output. In previous server versions, only trigger output from failure was propagated to the client; output was ignored on trigger success.

Trigger output messages can interfere with the parsing and saving of Perforce forms, such as client or label specs. If there are problems saving forms due to trigger output, the trigger must be modified to not output success messages, or, alternatively, the output can be logged to a log file.

DETAIL

In the absence of form triggers, you can create a new clientspec, or update the timestamp on an existing clientspec, by using the output of one p4 client command as input to another. For example:

$ p4 client -o TestClient | p4 client -i
Client TestClient saved.

$ p4 client -o | p4 client -i
Client MyWork not changed.

However, if a form trigger is scheduled to fire on client forms, any output that the trigger sends on success is prepended to the form. For example, below is a simple trigger that prints a message on success:

#!/usr/bin/env python
print "Test-out trigger a success!"
#EOF

To enable this trigger, you add an entry to the Perforce triggers table similar to the following:

test-out form-out client ./test-out.py

When you run the p4 client -o command using a 2007.3 or greater Perforce Server, the trigger executes and you see that the first line of the client form has the trigger output. For example:

 $ p4 client -o | head
Test-out trigger a success! 
# A Perforce Client Specification.
#
#  Client:      The client name.
#  Update:      The date this specification was last modified.
#  Access:      The date this client was last used in any way.
#  Owner:       The user who created this client.
#  Host:        If set, restricts access to the named host.
#  Description: A short description of the client (optional).
#  Root:        The base directory of the client workspace.

When attempting to save this form using p4 client -i, the form save operation fails and generates an error. For example:

$ p4 client -o | p4 client -i
Error in client specification.
Error detected at line 1.
Syntax error in 'Test-out'.
The problem here is that the trigger output alters the form so that it can not be parsed by the Perforce server. The simple solution is to alter the trigger so that it does not generate output messages on success, or directs those output messages to a file.

Users of the Perforce C++ API should note the following change in the release notes:
New functionality in 2007.3

	#137472
	    Trigger standard output is now passed to the client on
	    success (via OutputMsg()).  Clients may override the 
	    ClientUser::Message() method to handle this output 
	    by testing for this informational message (E_INFO)
	    using Error::CheckId( MsgServer::TriggerOutput ).
	    Note that '# include "msgserver.h"' is needed in the
	    source file that references this server message.
	    Clients may force the old behavior by setting the
	    'api' protocol level to 61 or less.
	    (Bug #7546, 26830)

The restrictions on output messages detailed in this article only apply to form-type triggers. Other triggers that do not manipulate Perforce forms can generate output on trigger success without causing an error with form save operations.