[p4] Scripting with perforce, pitafalls ...

ilde.web ilde.web at gmail.com
Mon Mar 3 10:02:39 PST 2008


Thank you all for your answers.

 

I have been using the "-s -ztag" for months now, I find it the best way to
go with scripting.  

 

<snip>

(You can, for example, say "I'll look at the exception and decide that 'all
files in sync' is an information message and not a fatal error and return
control to the script, but other ones will be fatal.")  

 

Getting status / success-fail is slightly easier. Still, sometimes an error
or warning will appear as a single formatted string to pass to the user, and
you cannot decide without parsing the string, if it was a warning or an
error

</snip>

My point exactly, using p4perl, p4ruby, p4python or p4com would not solve my
issues.  My issues are not actually the parsing itself but the bunch of
"false-positives" I get when parsing the results of the commands, look at
this output of "p4 -ztag fstat *" for example:

 

src - no such file(s).

Thumbs.db - no such file(s).

... depotFile //xp/i2/main/ui/UI_Alles.i2p

... clientFile O:\iar\i2entw\i2\ui\UI_Alles.i2p

... isMapped

... headAction edit

... headType text

... headTime 1195201311

... headRev 2

... headChange 18142

... headModTime 1161248953

... haveRev 2

 

Note that, "src" is a directory and "Thumbs.db" is on the protection list.

 

If I would need to process this output, I should consider any line that
matches "^. .*", anything that matches "^.* - no such file(s)." should be
ignored, anything else should "potentially" be considered as an error?
Adding the -s parameter enhances the output, but I still have the same issue
with the error handling.  I hope this makes my point clear.  

 

Lately, I have been doing what Nittin suggests: Testing for success
patterns, as a programmer you can imagine how I feel about this idea, also I
hope Perforce never decides to change the text if the output.  

 

It would be much easier if each output (error/warning) would be tagged with
a number (like W-0001 or E-0001, as an example).

 

There is one minor nuisance about the -ztag parameter and that is it is an
undocumented future, which for me implies: not existant, don't use and
unsupported (I found an inconsistency with p4 -s -ztag integrated already
and got the "undocumented future, don't use" reply)

 

Thanks again,

Ildefonzo




More information about the perforce-user mailing list