Search code examples
pythontriggersperforcejetbrains-idep4v

How do I get the value of the 'Branch files on creation' value in the Stream creation form from a form-in trigger?


I am setting up a Perforce Trigger on a Helix Core Server which is triggered on stream creation forms when the user submits the form for the stream to be created. I want to validate the name of the stream the user has selected. I also want to warn the user if they decide to not select 'Branch files from parent on stream creation' setting.

Stream creation form example

So far I have setup the trigger which works and can currently verify the stream name. However I am unable to find a way to get the boolean value of the checkbox for the 'Branch files...' setting.

Trigger line:

check-stream-name form-save stream "python /p4/common/bin/triggers/check_stream_name_trigger.py %formfile%"

I get all the form fields by grabbing the 'formfile' variable when the trigger is hit which gives me a temporary file name which i can read and get values for most of the fields on the form. But the 'Branch files...' field value is not shown.

Stream: //TestDepot/devs/TestStream_dev

Update: 

Access: 

Owner:  me

Name:   TestStream_dev

Parent: //TestDepot/Mainlines/ShortStream

Type:   development

Description:
    Created by me.

Options:    allsubmit unlocked toparent fromparent mergedown

Paths:
    share ...

How do I get the value of the 'Branch files...' checkbox in the trigger?


Solution

  • You can't, because this value isn't part of the actual stream spec on the server. When you check that box in the P4V UI, it will run the p4 populate command immediately after saving the spec (after your form trigger runs). The server doesn't know anything about it until that command is executed.

    It's pretty difficult to trigger on something that doesn't happen, unfortunately, especially if you're trying to trigger on it not happening in the future. A somewhat complicated solution might be to have a form-commit trigger on streams that kicks off a delayed check to see if the stream creation is quickly followed by a populate (i.e. check the type of the stream and its paths, wait at least a few seconds to allow time for a p4 populate, and then see if there are depot files that should exist but don't yet), and then potentially sends the user a followup email letting them know they haven't populated the stream yet (and here's how to do it).

    Alternatively, you could just have that form-commit trigger run the populate (assuming you want to always populate a stream with the head revisions of its parent -- that might not actually be something you'd want to enforce across the board though, since it can be useful to create a stream that's based on earlier revisions).