Next: , Previous: Naming Conventions, Up: Advanced Uses



3.9 File Attributes

Monotone contains a mechanism for storing persistent file attributes. These differ from file certificates in an important way: attributes are associated with a path name in your working copy, rather than a particular version of a file. Otherwise they are similar: a file attribute associates a simple name/value pair with a file in your working copy.

The attribute mechanism is motivated by the fact that some people like to store executable programs in version control systems, and would like the programs to remain executable when they check out a working copy. For example, the configure shell script commonly shipped with many programs should be executable.

Similarly, some people would like to store devices, symbolic links, read-only files, and all manner of extra attributes of a file, not directly related to a file's data content.

Rather than try to extend the manifest file format to accommodate attributes, monotone requires that you place your attributes in a specially named file in the root of your working copy. The file is called .mt-attrs, and it has a simple stanza-based format, for example:

     file "analyze_coverage"
     execute "true"
     
     file "autogen.sh"
     execute "true"
     otherattr "bob"

Each stanze of the .mt-attrs file assigns attributes to a file in your working copy. The first line of each stanza is file followed by the quoted name of the file you want to assign attributes to. Each subsequent line is the name of an attribute, followed by a quoted value for that attribute. Stanzas are separated by blank lines.

As a convenience, you can use the monotone attr command to set and view the values of these attributes; see Working Copy.

You can tell monotone to automatically take actions based on these attributes by defining hooks; see the attr_functions entry in Hook Reference.

Every time your working copy is written to, monotone will look for the .mt-attrs file, and if it exists, run the corresponding hooks registered for each attribute found in the file. This way, you can extend the vocabulary of attributes understood by monotone simply by writing new hooks.

Aside from its special interpretation, the .mt-attrs file is a normal text file. If you want other people to see your attributes, you should add and commit the .mt-attrs file in your working copy. If you make changes to it which conflict with changes other people make, you will have to resolve those conflicts, as plain text, just as with any other text file in your working copy.