views:

321

answers:

4

Is there a way to tell Perforce to leave text files alone without setting the file-type as binary? Or barring that, is there a way to tell the Perforce client to diff binaries? Binary usually isn't desirable, because I lose the ability to diff.

To clarify: If I edit and make changes to a *.txt file on my window client, newlines will have CR+LF as per the DOS format. But if I P4 sync on a Unix client, it will have LF only. I need Perforce to keep the format as-is, regardless of where the Perforce client lives.

That said, I do have a work-around: Set file-type as binary; and/or create a branch with text files set as "text", and integrate periodically back into the mainline where text files are set as "binary". But this is an overly-complicated work-around for what should be a very simple problem.

Finally, I'm on Perforce Windows client 2006.2.

Thanks in advance.

A: 

Give the files a different extension.

Permaquid
Nope, as these are supposed to be production-quality files. One should be able to sync and copy into the environment seamlessly and hassle-free. In the same vein, unix2dos isn't an option either.
hythlodayr
+4  A: 

The Perforce client can handle line ending properly when syncing to different platforms provided you have LineEnd option set properly on your client. Perhaps you have yours set wrong? Open up your client specs and set the LineEnd option according to your needs.

Check out this KB article on their website for more info. Here's an excerpt:

On the server side, Perforce processes all text files using Unix-style LF line-endings. Although Perforce stores server archive files on disk in the operating system's native line termination convention (CR/LF on Windows, LF on Unix), all line-endings are normalized to Unix-style LF line-endings for internal Perforce Server operations such as p4 sync, p4 submit and p4 diff.

On the client workspace side, Perforce handling of line-endings is determined by a global option for each clientspec. When you sync text files to a client workspace with p4 sync, or submit them back to a Perforce Server with p4 submit, their line-endings are converted as specified in the clientspec LineEnd section.

raven
I was afraid of that, but thank you for the article. Simply put, our Unix perforce clients (and file server) must be able to hold a mix of Windows and Unix text files.Even worse: We have certain localization text files (akin to Java properties files) which the Perforce server mangles. Alas, the only solution there is to set things to binary.
hythlodayr
@hythlodayr: Do you currently have a support contract with Perforce? If so, you could give them a call. Perhaps they know some tricks that can get it to behave the way you want.
raven
+2  A: 

Set all of your client/workspace specs to 'unix' line-endings. Then no conversion will take place when you check in on Windows.

See http://kb.perforce.com/P4dServerReference/GeneralServe..nctionality/CrlfIssuesAn..LineEndings

Douglas Leeder
Ok. This is much better. While not ideal, it's far better than having to create a separate branch. Thanks!
hythlodayr
A: 

When adding text files that you want to be considered binary to Perforce, use the command p4 add with the -t option to override the type mapping table. See the documentation here. The example given there is p4 add -t binary file.pdf.

Permaquid