p4 attribute
Set per-revision attributes on revisions: name-value pairs that associate metadata with the file revision.
Syntax
p4 [g-opts] attribute [-e -f -p] -n name [-v value [-T0 | -T1]] files ...
p4 [g-opts] attribute [-e -f -p [-T0 | -T1]] -i -n name file p4 attribute [-f -p [-T0 | -T1]] -I filename -n name file p4 [g-opts] attribute -c change# [-e -f] -n name [-v value | -i | -I filename [-T0 | -T1]]
Description
The p4 attribute command sets per-revision
attributes on file revisions. An attribute is special metadata that a user or an application associates with a file revision that is separate from the metadata Information that P4 Server maintains, such as who created file revisions in the depot, whether the file is a 'lazy copy,, the current state of client workspaces, protections, groups, users, labels, streams, and branches. Metadata is stored in the server database and is separate from the 'archive files' that users submit from their client workspace into the depot. that P4 generates. For example:
-
statusof a file, such aswork-in-progress,completed, orapproved -
thumbnailpreview image that is associated with an image file,descriptionof an image,sizeof the thumbnail metadata -
typeof a gif file, such asstaticoranimated,colororblack-and-white,drawingorphoto
You can set any number of attributes on a file, and any number of files can have zero, one, or more of the attributes.
Use the -c change# option to set or clear attributes on a pending or submitted changelist instead of on a file revision. In change mode, the command takes no file arguments, and the -p option is rejected because attributes on a changelist do not propagate to file revisions. The -n, -v, -e, -i, -I, and -T0 or -T1 options work the same as they do when setting attributes on a file: use -n to name the attribute, use -v to supply its value or omit -v to clear it, and use -i or -I filename to read the value from standard input or from a file.
Without the -f option, only the owner of a pending changelist can set or clear attributes on it. With the -f option, a user with admin access, including super, can set or clear attributes on any changelist, including a submitted changelist or another user's pending changelist.
Attributes set on a change persist with the change: they follow the change through submit and renumbering, through an edge-to-commit submit, and through a reshelve to a new change. As with file attributes, a large attribute value on a change can be stored in the trait depot instead of the db.traits table.
On an edge server, setting an attribute on a pending changelist pushes the attribute to the commit server immediately, on a best-effort basis. If the push fails, the command reports a non-fatal warning, and the attribute is still set locally on the edge server.
To read back attributes set on a changelist, use p4 describe with the -A option, or use p4 print -T name -c change#.
Attribute values and the trait depot
Attribute values are stored in the db.traits table by default. If the attributes are huge, the growth of the db.traits table can affect the performance of checkpoints. An alternative is to store new attribute values in the depot of type trait instead. To do so, set the trait.storagedepot.min configurable to a number greater than 0. When the size in bytes of the file's attribute value matches or exceeds the minimum set by this configurable, the file's attribute value is stored in the trait depot instead of the db.traits table.
For optimal performance, new traits with small values should be stored in the db.traits table, and new traits with large values should be stored in the trait depot. The value of trait.storagedepot.min should be chosen carefully because retrieval from the trait depot involves costly fetching from depot storage. It is recommended that the minimum size of huge data, such as thumbnails, should be chosen for this value.
Options
| Option | Description |
|---|---|
|
|
Set or clear attributes on the pending or submitted changelist change# instead of on a file revision. No file arguments are allowed with this option, and the |
|
|
Indicates that the value is specified in hex. |
|
|
Set the attribute on submitted files. If a propagating trait is set on a submitted file, a revision specifier cannot be used, and the file must not be currently open in any workspace. |
|
|
Read an attribute value from the standard input. Only one file argument is allowed when using this option. This option supports both textual and binary content. |
|
|
Read the attribute value from a file. The file can have textual or binary content. Use this when the attribute data exceeds 250 megabytes, which might cause the command to fail with the
To display attributes set with this option,
use the |
|
|
The name of the attribute to set. |
|
|
Create a propagating attribute: an attribute whose value is
passed on to subsequent revisions whenever the file is opened. Relevant commands include |
|
|
The value of the attribute to set. To clear an attribute, omit
the |
-T0 | - T1
|
|
|
|
See Global options. |
Usage notes
| Can file arguments use revision specifier? | Can file arguments use revision range? | Minimal access level required |
|---|---|---|
|
Yes |
Yes |
write, |
- Multiple attributes can be set or cleared by specifying multiple
-n nameoptions and an equal number of corresponding-v valueoptions (to set) or no-voptions ( to clear).
Examples
To assign an attribute of a file
Use the -n option to set the name the attribute, and use -v option to set the value of the attribute. Here, for revision 4 of the file named kitten.gif, the attribute black-and-white is set to the value of true.
This attribute value is small and indicates that the image is black-and-white instead of color.
p4 attribute -f -n black-and-white -v true //depot/main/rel1/perl_proj/kitten.gif
//depot/main/release1/perl_proj/kitten.gif#4 - black-and-white set
Searching for attributes
See the Examples for attributes in the p4 fstat topic.
To remove an attribute from a file
The omission of the -v option removes the attribute value from the file.
p4 attribute -f black-and-white //depot/main/rel1/perl_proj/kitten.gif
//depot/main/release1/perl_proj/kitten.gif#4 - black-and-white cleared
To set and clear an attribute on a pending changelist
Use the -c change# option to set an attribute on a pending changelist instead of on a file. Here, the attribute reviewed is set to true on pending changelist 1234, then cleared.
p4 attribute -c 1234 -n reviewed -v true
Change 1234 - reviewed set p4 attribute -c 1234 -n reviewed
Change 1234 - reviewed cleared