Long story short, my team recently discovered the existence of “attributes” in Perforce. This is a currently-undocumented feature allowing you to attach arbitrary metadata (name/value pairs) to a revision of a file.
We had been developing a system for attaching metadata to version-controlled files via SQL, but faced a lot of complications when handling failure cases. Like when the P4 submit works, but the SQL update fails, or vice versa. It’s solvable stuff, but keeping those actions truly atomic and reliable was making the system quite complex.
The Perforce attribute feature renders that SQL layer and failure handling unnecessary, letting us stick the metadata right into the P4 revisions.
Although it’s undocumented, we’ve been told several “big customers” are using attributes, and Perforce plans to keep them.
You can get the basic info on using attributes with the “p4 -help undoc” command (which is itself undocumented :):).
I’m a bit scary of the attributes being unsupported, but as long as they work… Beats any “keep SQL in sync” crap you’d need to do otherwise. I wish I had known about them a while back.
We’ve added most metadata etc in xml files which follow the same naming convention as the real asset.
Nope, well sorta. It’s a real command with help now, but still says “unsupported” in that help. Here’s what “p4 help attribute” says, using Server 2011.1/397313…
attribute -- Set per-revision attributes on revisions (unsupported)
p4 attribute [-e -f -p] -n name [-v value] files...
p4 attribute [-e -f -p] -i -n name file
Sets a user-managed attribute 'name' to 'value' on opened files.
If -v is omitted, the attribute is cleared (if set).
To display attributes use 'p4 fstat'.
The -e flag indicates that the 'value' is specified in hex.
The -f flag sets the attribute on submitted files.
The -p flag creates an attribute with a value that is propagated
when the file is opened with 'p4 add', 'p4 edit', or 'p4 delete'.
The -i flag causes the attribute value to be read from the standard
input. Only one file argument is allowed when using this option.
Multiple attributes can be set or cleared by specifying multiple
'-n name' flags and an equal number of corresponding '-v value'
flags (to set) or no '-v' flags (to clear).