Automatic Property Setting


Properties are a powerful feature of Subversion, acting as key components of many Subversion features discussed elsewhere in this and other chapters—textual diff and merge support, keyword substitution, newline translation, etc. But to get the full benefit of properties, they must be set on the right files and directories. Unfortunately, that can be a step easily forgotten in the routine of things, especially since failing to set a property doesn't usually result in an obvious error condition (at least compared to, say, failing to add a file to version control). To help your properties get applied to the places that need them, Subversion provides a couple of simple but useful features.

Whenever you introduce a file to version control using the svn add or svn import commands, Subversion runs a very basic heuristic to determine if that file consists of human-readable or non-human-readable content. If the latter is the decision made, Subversion will automatically set the svn:mime-type property on that file to application/octet-stream (the generic «this is a collection of bytes» MIME type). Of course, if Subversion guesses incorrectly, or if you wish to set the svn:mime-type property to something more precise—perhaps image/png or application/x-shockwave-flash—you can always remove or edit that property.

Subversion also provides the auto-props feature, which allows you to create mappings of filename patterns to property names and values. These mappings are made in your runtime configuration area. They again affect adds and imports, and not only can override any default MIME type decision made by Subversion during those operations, they can also set additional Subversion or custom properties, too. For example, you might create a mapping that says that any time you add JPEG files—ones that match the pattern *.jpg—Subversion should automatically set the svn:mime-type property on those files to image/jpeg. Or perhaps any files that match *.cpp should have svn:eol-style set to native, and svn:keywords set to Id. Auto-prop support is perhaps the handiest property related tool in the Subversion toolbox. See «Config» for more about configuring that support.


[36] Если вы знакомы с XML, то синтаксис XML "Name" использует практически тот же ASCII набор.

[37] Исправление в лог сообщениях орфографических, грамматических ошибок, «просто ошибочных» записей, наверно, самые распространенные случаи использования параметра --revprop.

[38] Для определения исполняемых файлов, файловая система Windows использует расширения файлов (такие, как .EXE, .BAT и .COM).

[39] The patterns are strictly for that directory—they do not carry recursively into subdirectories.

[40] Isn't that the whole point of a build system?

[41] … or maybe even a section of a book …

Пред. Уровень выше След.
Глава 7. Профессиональное использование Subversion Содержание Locking


Содержание раздела