Subversion Keywords

Die Versionsverwaltung Subversion bietet durch Keywords die Möglichkeit im SourceCode Metadaten von Subversion selbst einzufügen. Folgende Keywords sind möglich:
<DIV class=variablelist>

<FONT size=4><SPAN class=term><CODE class=literal>Date</CODE></SPAN></FONT>

This keyword describes the last time the file was known to have been changed in the repository, and looks something like <FONT size=4><CODE class=literal>$Date: 2002-07-22 21:42:37 -0700 (Mon, 22 Jul 2002) $</CODE></FONT>. It may also be specified as <FONT size=4><CODE class=literal>LastChangedDate</CODE>.</FONT>

<FONT size=4><SPAN class=term><CODE class=literal>Revision</CODE></SPAN></FONT>

This keyword describes the last known revision in which this file changed in the repository, and looks something like <FONT size=4><CODE class=literal>$Revision: 144 $</CODE></FONT>. It may also be specified as <FONT size=4><CODE class=literal>LastChangedRevision</CODE> </FONT>or <CODE class=literal>Rev</CODE>.

<FONT size=4><SPAN class=term><CODE class=literal>Author</CODE></SPAN></FONT>

This keyword describes the last known user to change this file in the repository, and looks something like <FONT size=4><CODE class=literal>$Author: harry $</CODE></FONT>. It may also be specified as <FONT size=4><CODE class=literal>LastChangedBy</CODE>.</FONT>

<FONT size=4><SPAN class=term><CODE class=literal>HeadURL</CODE></SPAN></FONT>

This keyword describes the full URL to the latest version of the file in the repository, and looks something like<FONT size=4> <CODE class=literal>$HeadURL: http://svn.collab.net/repos/trunk/README $</CODE></FONT>. It may be abbreviated as <CODE class=literal>URL</CODE>.

<FONT size=4><SPAN class=term><CODE class=literal>Id</CODE></SPAN></FONT>

This keyword is a compressed combination of the other keywords. Its substitution looks something like <FONT size=4><CODE class=literal>$Id: calc.c 148 2002-07-28 21:30:43Z sally $</CODE></FONT>, and is interpreted to mean that the file <CODE class=filename>calc.c</CODE> was last changed in revision 148 on the evening of July 28, 2002 by the user <CODE class=literal>sally</CODE>.

</DL></DIV>Das Setzen der Keywords erfolgt entweder mittels

svn propset svn:keywords "Date Author" weather.txt

oder über TortoiseSVN im Eigenschaftendialog des Explorers (siehe Bild).

Damit auch neue Dateien mit den korrekten Keywords versehen werden, muss die Konfigurationsdatei für Subversion (über TortoiseSVN Settings - Edit configuration file) angepasst werden. Zuerst ist dabei folgende Einstellung zu setzen:

enable-auto-props = yes

und anschliessend können default Eigenschaften für bestimmte Dateitypen definiert werden:

*.cs = svn:keywords=HeadURL LastChangedBy LastChangedRevision LastChangedDate
*.aspx = svn:keywords=HeadURL LastChangedBy LastChangedRevision LastChangedDate

Im Source Code selbst müssen an der gewünschten Stelle die entsprechenden Keywords mit $-Zeichen umgeben platziert werden:
$HeadURL$ $LastChangedDate$ $LastChangedRevision$ $LastChangedBy$



<DIV class=inlinedMailPictureBox><IMG class=inlinedMailPicture src="http://sven-s.de/blog/content/binary/SubversionEigenschaften-thumb.dasblog.JPG" border=0>
<A class=inlinedMailPictureLink href="http://sven-s.de/blog/content/binary/SubversionEigenschaften.jpg">SubversionEigenschaften.jpg</A></DIV>

Updated: