Attempting to submit a changelist with no files is considered by Perforce to be an error (p4 submit ...
returns exit code 1). This causes a periodic integration build to fail on our build server (we're using Zutubi's Pulse system); in this case I would rather have the build succeed, possibly with a warning.
Pulse has exit code remapping functionality, but Perforce does not appear to disambiguate between a failure to submit an empty changelist and any other submit failure (such a validation trigger failure, which I do want to fail the build).
The immediately obvious (but, in my mind, inelegant) solution that comes to mind is to wrap execution of p4 submit
in a batch file that first checks to see if the target changelist is empty by counting lines of output from p4 opened
-- or just parsing the output of p4 submit
for the "no files" message and returning successfully from the batch file.
Are there better techniques for handling this that I'm not seeing?
There are probably no good techniques just with Perforce, if I am understanding your problem correctly. The issue, as you have seen, is that the return codes from perforce command line runs are, well, ambiguous. Is a submission of an empty changelist really an error? Maybe, maybe not - might depend on who you ask.
It's is not really that advisable to look at return codes from 'p4' commands. Your best bet as you have suggested is to parse the output of the command and then do what you need to from there.
Most commands now support the -ztag option (see 'p4 help usage'), which will could make parsing the output a bit easier, depending on what you want to do. If your case, it is probably sufficient enough to just look for the text in the output and then decide what to do from there.