p4 typemap
View or modify the file name-to-type mapping table.
Syntax
p4 [g-opts] typemap
p4 [g-opts] typemap -o
p4 [g-opts] typemap -i
Description
The p4 typemap
command allows
Helix Core Server
administrators to set up a table linking
Helix Core Server
file types to file name specifications. If a filename matches an entry in
the typemap table, it overrides the file type that would otherwise have
been assigned by
Helix Core Server.
This command:
-
only affects files that are added AFTER you create the mapping table
-
does NOT affect files that existed before you create the mapping table
Default behavior to determine file type
By default,
Helix Core Server
automatically determines if a file is of type text
or
binary
based on an analysis of the first 65,536 bytes of a
file:
-
If the high bit is clear in each of the first 65,536 bytes, Helix Core Server assumes it to be
text
. -
Otherwise, it’s
binary
. -
Files compressed in the
.zip
format (including.jar
files) are also automatically detected and assigned the typeubinary
.
Overriding the default behavior
The default behavior can be overridden by the use of the
-t filetype
option. See Overriding file type with the -t option.
However, it’s easy to overlook this, particularly in cases where files' types were usually (but not always) detected correctly. This situation occasionally appears with PDF files (which sometimes begin with over 65,536 bytes of ASCII comments) and RTF files, which usually contain embedded formatting codes.
The p4 typemap
command provides the most complete
solution, allowing administrators to bypass the default type detection
mechanism, and ensuring that certain files (for example, those ending in
.pdf
or .rtf
) are assigned the
desired Helix Core filetype when they are added to the depot. See p4 add.
Users can override any file type mapping defined in the typemap table by explicitly specifying the file type on the Helix Core Server command line.
Form Fields
The p4 typemap
form contains a single
TypeMap
field. Each indented line under the TypeMap: field consists of a pair of values linking file
types to file patterns specified in depot syntax:
Column | Description |
---|---|
|
Any of the Helix CoreFile types. |
|
A file pattern in depot syntax. When a user adds a file matching this pattern, its default file type is the file type specified in the table. To exclude files from the typemap, use exclusionary
( To match all files anywhere in the depot hierarchy, the pattern must begin with To match files with a specified suffix, use Later entries override earlier entries. |
Options
|
Reads the typemap table from standard input without invoking the editor. |
|
Writes the typemap table to standard output without invoking the editor. |
|
See Global options. |
Usage Notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
N/A |
N/A |
admin, |
- To specify all files with a given extension at or below a desired
subdirectory, use four periods after the directory name, followed by
the extension. (for instance,
//
) The first three periods specify "all files below this level". The fourth period and accompanying file extension are parsed as "ending in these characters".path
/....ext
- File type modifiers can be used in the typemap table. Useful
applications include forcing keyword expansion on or off across
directory trees, enforcing the preservation of original file
modification times (the
+m
file type modifier) in directories of third-party DLLs, or implementing pessimistic locking policies. - Specify multiple file type modifiers consecutively. For example,
binary+lFS10
refers to abinary
file with exclusive-open (l
), stored in full (F
) rather than compressed, and for which only the most recent ten revisions are stored (S10
). For more information on syntax, see File types. - If you use the
-t
option and file type modifiers to specify a file type on the command line, and the file to which you are referring falls under ap4 typemap
mapping, the file type specified on the command line overrides the file type specified by the typemap table.
Examples
To make Helix Core Server consider all PDF and RTF files as binary
, use
p4 typemap
to modify the typemap table as
follows:
Typemap: ## comment line binary //....pdf ## comment appended binary //....rtf
where:
-
The first three periods ("
...
") in the specification are a Helix Core Server 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
). -
Comments are preceded by
##
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 the legacy binary file format of Microsoft Word. 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:
Typemap: binary //depot/dev_projects/main/bin/... binary+m //depot/dev_projects/main/bin/thirdpartydll/...
All files at or below the bin
directory are assigned type
binary
. Because later mappings override earlier mappings,
files in the bin/thirdpartydll
subdirectory are assigned
type binary+m
instead. For more information about the
+m
(modtime) file type modifier, see
File types.
By default,
Helix Core Server
supports concurrent development, but environments in which only one
person is expected to have a file for edit at a time can implement
pessimistic locking by using the +l
(exclusive open)
modifier as a partial filetype. If you use the following typemap, the
+l
modifier is automatically applied to all newly-added
files in the depot:
Typemap: +l //depot/...
Indent each line under Typemap:
Related commands
To add a new file with a specific type, overriding the typemap table |
|
To change the filetype of an opened file, overriding any settings in the typemap table |
|