If you are using SVN (Subversion) for configuration management then you might already be aware that some SVN has properties. A property is kind of a meta-data/attribute applied to your files and folders. These properties change the behaviour of your subversion client and the way you work with the files.
Important Properties
Some of the important properties are as under.
-
svn:eol-style
Using this property you make file using line ending of your files when you check it out.
LF
- Line Feed. Linux as in LinuxCRLF
- Carriage Return / Line Feed. As in Windowsnative
- If you check out on Linux, this will be
LF
- If you check out on Windows, this will be
CRLF
- If you check out on Linux, this will be
-
svn:executable
This property helps so that when you checkout a file, it will have executable permissions.
-
svn:needs-lock
This property helps so that when you checkout a file, it will read only by default. And if you want to modify it, you need to acquire lock.
-
…
For more proprities, and their description, see the SVN Book
Setting the properties
There are multiple ways to set the properties.
Via svn propset command.
e.g.
1
2# Needs lock on just one file
3svn propset "svn:needs-lock" "*" my-file.docx
4
5# Needs lock on just one many files
6svn propset "svn:needs-lock" "*" *.docx *.xlsx
7
8# Svn executable
9svn propset "svn:executable" "*" myAwesomeScript.sh
This approaches a limitation. You need to do it every time when you add a new file. Let’s move on to another approach.
Via SVN configuration file
In the file ~/.subversion/config
or
%APPDATA%\Subversion\config
, there is a section called [auto-props]
Just extend the [auto-props]
section with the properties that you
want to set automatically.
1
2[auto-props]
3*.sh = svn:eol-style=LF;svn:executable
So now when you add and commit a new shell script, the new file will
have executable properties, and the file will always end with LF
.
This approach has one limitation. If you work on multiple computers then you have to do it on all to computer said you work on. If you collaborate in a team then your colleagues may also have to follow the same process.
Set Auto properties
Subversion 1.8 and later adds this picture. You just said the property at the directory level.
1$ svn propset svn:auto-props '
2### src
3*.css = svn:eol-style=LF
4*.html = svn:eol-style=LF
5*.js = svn:eol-style=LF
6*.json = svn:eol-style=LF
7*.svg = svn:eol-style=LF
8*.xml = svn:eol-style=LF
9*LICENSE* = svn:eol-style=LF
10' . -R
11
12svn commit -m "Added auto props"
With this trick, if anyone adds a new file with the listed extensions
they will get the properties that we have listed. auto-props
is a
property that we apply to a directory. Any files are we add to this
directory would inherit these properties.
Comments