Perforce 2000.2 Command Reference (2000.2.cr.1)
<< Previous Chapter
p4 triggers
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 unlock

p4 typemap


Synopsis

Modify the file name-to-type mapping table.

Syntax

p4 [g-opts] typemap
p4 [g-opts] typemap -i
p4 [g-opts] typemap -o

Description

The p4 typemap command allows s system administrators to set up a table linking Perforce file types to file name specifications. If a filename matches an entry in the typemap table, it will override the file type that would otherwise have been assigned by the Perforce client.

By default, Perforce automatically determines if a file is of type text or binary based on an analysis of the first 1024 bytes of a file. If the high bit is clear in each of the first 1024 bytes, Perforce assumes it to be text; otherwise, it's binary.

Although this default behavior can be overridden by the use of the -t filetype flag, it's easy to overlook this, particularly in cases where files' types were usually (but not always!) detected correctly. The most common examples of this are associated with PDF files (which sometimes begin with over 1024 bytes of ASCII comments) and RTF files, which usually contain embedded formatting codes.

The p4 typemap command provides a more complete solution, allowing administrators to bypass the default type detection mechanism, ensuring that certain files (e.g., those ending in .pdf or .rtf) will always be assigned the desired Perforce filetype upon addition to the depot.

Users can override any file type mapping defined in the typemap table by explicitly specifying the file type on the Perforce command line.

Form Fields

The p4 typemap form contains a single TypeMap: field, containing pairs of values linking file types to files specified in depot syntax:

Column
Description

filetype

Any valid Perforce file type.

For a list of valid file types, see the File Types section

pattern

A file pattern in depot syntax.

When a user adds a file matching this pattern, its default filetype will be the file type specified in the table.

Options

-i

Reads the typemap table from standard input without invoking the user's editor.

-o

Writes the typemap table to standard output without invoking the user's editor.

g_opts

See the Global Options section.

Usage Notes

Can File Arguments Use
Revision Specifier?

Can File Arguments Use
Revision Range?

Minimal Access Level Required

N/A

N/A

super

Examples

To tell the Perforce server to regard all PDF and RTF files as binary, set the typemap table as follows:

Typemap:
        binary //....pdf
        binary //....rtf

The first three periods ("...") in the specification are a Perforce wildcard specifying that all files beneath the root directory are included as part of the mapping. The fourth period and the file extension specify that the specification applies to files ending in ".pdf" (or ".rtf")

A more complicated situation might arise in a site where users in one area of the depot use the extension .doc for plain ASCII text files containing documentation, and users working in another area use .doc to refer to files in a binary file format used by a popular word processor. A useful typemap table in this situation might be:

Typemap:
        text //depot/dev_projects/....doc
        binary //depot/corporate/annual_reports/....doc

To enable keyword expansion for all .c and .h files, but disable it for your .txt files, do the following:

Typemap:
        text+k //depot/dev_projects/main/src/...*.c
        text+k //depot/dev_projects/main/src/...*.h
        text //depot/dev_projects/main/src/...*.txt

To ensure that files in a specific directory have their original file modification times preserved (regardless of submission date), use the following:

Typemap:
        binary //depot/dev_projects/main/bin/...
        binary+m //depot/dev_projects/main/bin/thirdpartydll/...

All files at or below the bin directory will be assigned type binary. Because later mappings override earlier mappings, files in the bin/thirdpartydll subdirectory will be assigned type binary+m instead.

For more information about the +m (modtime) file type modifier, see the File Types section.

Related Commands

To add a new file with a specific type, overriding the typemap table

p4 add -t type file

To change the filetype of an opened file, overriding any settings in the typemap table

p4 reopen -t type file


Perforce 2000.2 Command Reference (2000.2.cr.1)
<< Previous Chapter
p4 triggers
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 unlock
Please send comments and questions about this manual to [email protected].
Copyright 1997, 2000 Perforce Software. All rights reserved.
Last updated: 12/21/00