Actions

Difference between revisions of "Subversion File Properties"

From Joomla! Documentation

(Configuration for Automatic Properties)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[http://easyeclipse.org/site/distributions/php.html EasyEclipse] is a great tool for developing Joomla!. It also supports SVN client to grab your code easily from [http://joomlacode.org/ Joomlacode]
+
All files in the SVN repository should have the Unix style (LF) line endings. This is controlled via the Subversion "eol-style=LF" property. In addition, most files (.php, .css, .js, .ini) should have the "keywords=Id" property set. This is what allows Subversion to record the "@version" tag in the Doc block at the beginning of each file. For example,
  
Here is [http://www.veoh.com/videos/v12316545ACFsJaJY video tutorial] how to use [http://easyeclipse.org/site/distributions/php.html EasyEclipse]
+
<code> * @version $Id: index.php 14276 2010-01-18 14:20:28Z louis $</code>.
  
==For those with commit access==
+
You only need to set these properties when you create new files and add them to version control. If you are editing existing files that are already under version control, the properties should already be set correctly.  
All files should have the Unix style (LF) line endings. Subversion should give an error if you try to commit a file with mixed line endings.
+
  
Please make the following change to your SVN config file (~/.subversion/config for Mac/Linux users). This will ensure that any new file with these extensions will automatically have the right line ending style set.
+
You can set file properties either manually or you can configure Subversion to do this automatically each time you add a file to version control.
 +
 
 +
=== Configuration for Automatic Properties ===
 +
 
 +
Subversion uses a configuration file to control automatic property settings. For Mac or Linux users, this file is called <code>~/.subversion/config</code>. For Windows users, this file is called <code>C:\Documents and Settings\<your user name>\Application Data\Subversion\config</code> or <code>C:\Users\<your user name>\AppData\Roaming\Subversion\config</code>. For TortoiseSVN, you can edit the configuration file right from the program. Right-click on a project, select TortoiseSVN&rarr;Settings and click on the "Edit" button next to "Subversion configuration file:".
 +
 
 +
Edit the configuration file as shown below. At the end of the file, you will see a section called <code>[auto-props]</code>. Be sure to set the <code>enable-auto-props = yes</code>. Also, note that "Id" is upper-case "I" and lower-case "d".
  
 
<pre>
 
<pre>
 +
### Section for configuring automatic properties.
 
enable-auto-props = yes
 
enable-auto-props = yes
 
[auto-props]
 
[auto-props]
*.ini = svn:eol-style=LF
+
...
*.php = svn:eol-style=LF
+
*.php = svn:eol-style=LF;svn:keywords=Id
*.css = svn:eol-style=LF
+
*.html = svn:eol-style=LF
*.js = svn:eol-style=LF
+
*.xml = svn:eol-style=LF
 +
*.ini = svn:eol-style=LF;svn:keywords=Id
 +
*.css = svn:eol-style=LF;svn:keywords=Id
 +
*.js = svn:eol-style=LF;svn:keywords=Id
 
</pre>
 
</pre>
  
All of this should exist in the file by default, so you might just need to uncomment the auto-props line and add the extra lines at the bottom of the auto-props entries.
+
You can test that the change was successful by creating a new file of the desired type and adding it to version control. Then examine the SVN properties for this file and you should see the new properties automatically. See below for instructions on examining the properties.
 +
 
 +
===Manually Setting File Properties===
 +
You can of course manually set or check the properties for any file that is under version control. Here is how you do this in Eclipse, command line, or TortoiseSVN.
 +
 
 +
* '''Eclipse''': Select the desired file in the PHP Explorer view and then select Team&rarr;Show Properties. The SVN Properties view will display. You can then right-click in the view and select Add a Property. Select the Property name from the list ("svn:eol-style" or "svn:keywords"). Then enter the property value in the Property content box ("LF" or "Id"). Press OK and the new property will show in the view. You can also delete or modify a property this way.
 +
* '''Command Line''': Enter the command <code>propset svn:keywords "Id" <file name></code> or <code>propset svn:keywords "Id" <file name></code>. You can also use the "propdel" command to remove properties.
 +
* '''TortoiseSVN''':Select the desired file in Windows File Explorer then right-click and select TortoiseSVN&rarr;Properties. This will open a Properties dialog that lets you add, remove, or edit properties. To add a property, select the desired property from the list and enter the value in the Property value box.
  
For TortoiseSVN, in the Settings dialog, General tab, Subversion section, there's an edit button for the config file.  The auto-props stuff is near the bottom.  You have to uncomment enable-auto-props and add the options to the auto-props section. Note that their parser doesn't seem to like leading spaces.
 
 
[[Category:Development]]
 
[[Category:Development]]

Latest revision as of 14:37, 3 May 2010

All files in the SVN repository should have the Unix style (LF) line endings. This is controlled via the Subversion "eol-style=LF" property. In addition, most files (.php, .css, .js, .ini) should have the "keywords=Id" property set. This is what allows Subversion to record the "@version" tag in the Doc block at the beginning of each file. For example,

* @version $Id: index.php 14276 2010-01-18 14:20:28Z louis $.

You only need to set these properties when you create new files and add them to version control. If you are editing existing files that are already under version control, the properties should already be set correctly.

You can set file properties either manually or you can configure Subversion to do this automatically each time you add a file to version control.

Configuration for Automatic Properties

Subversion uses a configuration file to control automatic property settings. For Mac or Linux users, this file is called ~/.subversion/config. For Windows users, this file is called C:\Documents and Settings\<your user name>\Application Data\Subversion\config or C:\Users\<your user name>\AppData\Roaming\Subversion\config. For TortoiseSVN, you can edit the configuration file right from the program. Right-click on a project, select TortoiseSVN→Settings and click on the "Edit" button next to "Subversion configuration file:".

Edit the configuration file as shown below. At the end of the file, you will see a section called [auto-props]. Be sure to set the enable-auto-props = yes. Also, note that "Id" is upper-case "I" and lower-case "d".

### Section for configuring automatic properties.
enable-auto-props = yes
[auto-props]
...
*.php = svn:eol-style=LF;svn:keywords=Id
*.html = svn:eol-style=LF
*.xml = svn:eol-style=LF
*.ini = svn:eol-style=LF;svn:keywords=Id
*.css = svn:eol-style=LF;svn:keywords=Id
*.js = svn:eol-style=LF;svn:keywords=Id

You can test that the change was successful by creating a new file of the desired type and adding it to version control. Then examine the SVN properties for this file and you should see the new properties automatically. See below for instructions on examining the properties.

Manually Setting File Properties

You can of course manually set or check the properties for any file that is under version control. Here is how you do this in Eclipse, command line, or TortoiseSVN.

  • Eclipse: Select the desired file in the PHP Explorer view and then select Team→Show Properties. The SVN Properties view will display. You can then right-click in the view and select Add a Property. Select the Property name from the list ("svn:eol-style" or "svn:keywords"). Then enter the property value in the Property content box ("LF" or "Id"). Press OK and the new property will show in the view. You can also delete or modify a property this way.
  • Command Line: Enter the command propset svn:keywords "Id" <file name> or propset svn:keywords "Id" <file name>. You can also use the "propdel" command to remove properties.
  • TortoiseSVN:Select the desired file in Windows File Explorer then right-click and select TortoiseSVN→Properties. This will open a Properties dialog that lets you add, remove, or edit properties. To add a property, select the desired property from the list and enter the value in the Property value box.