Question

I would like to write a script (a perforce trigger), that will validate the content of the files in the changelist before allowing commit. However my script processes the XML using Xsltproc and then validates using Jing. I need to save the intermittent output to a temp file - can that be done when writing a change-content trigger (server-side) for perforce? I have read loads of documentation but never seen any mention of creating temp files while running the trigger script. The only other workaround would be to pipe the output from Xsltproc into Jing (and I have no idea how to do that either).

Any advice form experienced XSLT or Perforce users welcome. Thanks.

BTW I am using perl - but I don't think that would make things any more difficult.

Was it helpful?

Solution

Sure, you can create temp files. Just make sure the trigger has permission to write where you want to put it, that there is enough space on the server drive, that you name the file in such a way as to avoid collisions (there is a Perl module for creating temp file names), and that you clean it up afterwards (IIRC, the right module will do that for you).

Keep in mind, though, that if your trigger takes a long time to process it is going to be disruptive, and maybe scary, to users. In that case it may be better to use a daemon to access the file out of the commit loop and have the user fix it rather than try to block it to begin with. (That works if bad files can be tolerated for as long as it takes to fix them. That's a call you need to make.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top