Jump to content


trigger on revert files?

trigger

  • Please log in to reply
1 reply to this topic

#1 bsabiston

bsabiston

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 March 2020 - 06:31 PM

Is it possible to set a trigger when a user reverts files?  I've looked at the documentation, but it's unclear if this is possible.  

If not, is there any other way to have a script hook into the revert function?

Thanks!

#2 Dave Foglesong

Dave Foglesong

    Member

  • Members
  • PipPip
  • 17 posts

Posted 17 March 2020 - 10:18 PM

Yes, you should be able to make a pre- or post-command trigger that runs on the revert command.

See: https://www.perforce...gers.order.html




However, most likely you'll want the trigger to do something based on what files are being reverted, and that gets a bit harder. The trigger can access the command args, but if the user runs a command with a wildcard (such as "p4 revert ..." or "p4 revert *") the trigger won't know what the wildcard maps to in the context (user/client/working dir) where the command was run. You'd have to create a pre-command trigger that mimics the context and runs "p4 revert -n" with that wildcard to get the file list. (You can't do this in a post-command trigger, because by that point the files have been reverted, and "p4 revert -n" will return no files.)

If you're using a broker, you can also do something similar with a broker filter program that runs on the "revert" command. But the same issue with determining what files are in a command that uses a wildcard also exists with the broker.

It may be possible to do something with the new Perforce server extensions. I haven't experimented with those yet, so I don't know what's possible with them.





Also tagged with one or more of these keywords: trigger

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users