Completed the trigger for now, subject to unit tests
This trigger is supposed to prevent a submit of a new file (or a branch)
that would create a conflict between a filename and a directory name.
In Perforce, it is currently possible to submit a filename that exists already
as a directory name, because the server does not recognise directory names as
independent entities. When this happens, clients cannot sync files anymore from the path: files and directories cannot live in the same file system with the same name.
This trigger will analyse a submit (as a change-submit trigger *only*):
- extract all "add" and "branch" operations
- extract all unique directories out of the above list
- extract all file names out the above list
- check that there is no file already submitted that matches the directories
- check that there is no directory already submitted that matches the files
This trigger will run 3 Perforce queries: extract the change, list matching files and list matching directories.
This trigger should run as a user who has list permissions for all possible files under the path specified in the trigger table. The user needs to have a permanent ticket available on the server for the trigger to run.
Output is a list of all violating files:
Your submission has been rejected because the following files
or directories already exist as a directory or file.