Is there any way to automate rename detecting when using perforce?
I know that, if you rename the file in the filesystem and run reconcile command, perforce will automatically detect that a file has been renamed.
Other than that, you have to explicitly tell perforce that a file has been renamed renaming it with the move command. The problem is, I work with people who won't do this.
Is there a way to trigger whatever the reconcile command does as some kind of "pre-submit" hook so that the file history remains unbroken?
You could, technically, do the exact check that
reconciledoes in achange-contenttrigger, by doing something like:which will give you a result like this:
and then you can compared what's in the shelf vs what reconcile did:
In this case your trigger would probably want to fail the submit and tell the user "hey, it looks like ola2 is actually a rename of ola1, please revert and do the rename using the 'p4 rename' command".
Note that you can also use
p4 reconcile -nand capture the output, rather than running an actualreconcileand then inspectingp4 opened. You might also optimize it by usingreconcile -adso that you aren't doing a bunch of extra digest computations to re-detect edited files.However, I'm not sure that I'd recommend implementing a trigger like this on every submit, since it's going to be a noticeable amount of extra overhead to catch what might be a relatively rare problem, and even once it's caught, it's actually kind of hard to "fix" it (you more or less have to start over and do the rename over again the right way). In the real world I'd want to take a closer look at how this is happening and see if there's a way to change the workflow at the point where the file is actually getting renamed.