views:

289

answers:

1

When you add a file to Perforce, it attempts to determine what type of file it is (text, binary, utf16, etc.). It's does a good job of this, but apparently never checks the file type again after the initial submission to version control. A coworker recently made a change to a text file that converted it to Unicode (utf16). Perforce didn't recognize this and still considered it type text, so when others retrieved the file, it was corrupt.

We fixed the problem by resubmitting the file and explicitly changing the file type to utf16, but would prefer if this happened automatically. There are ways to force it to always use a certain encoding type, but I don't know if I like that idea. Has anyone dealt with, and found a solution to, this problem?

+3  A: 

Perforce tech support had this to say:

Perforce does not check the content of the file when you submit an edit.

Checking every single file edit for content is potentially very expensive. "text" and "utf16" are not the only file types to look out for, a file could potentially change type from "text" to "binary" for example.

Another problem is that sometimes a user wants to override the default behavior of how Perforce recognizes a file. How should the server react in this case if the actual file type does not match the file type the user provides?

For these reasons Perforce will only determine the file type when the file is added, and take the "typemap" and the command parameter "-t" into account.

On the other hand, you can prevent your situation from happening again by employing a "change-content" trigger. This trigger would check the content of the file and compare it to the specified file type, rejecting any submit that creates a mismatch.

raven