I want to add svn properties (like svn:keyword=Id Date Rev Author) to files upon commits of new files.
For this to work there may be two main options:
The client side is not always desirable, as control over the client set up is needed. I want to solve this on the server. How can this be done.
The Subversion docs say it's a bad idea to modify a commit on the server side.
Instead, you could do something like a customized version of the svn_apply_autoprops script periodically through cron (or even on the server triggered by a commit). The svn_apply_autoprops script is a little more general than what you need, but it should be straighforward to set up the appropriate config file.
As of this post, the subversion web site is migrating under apache.org, and I couldn't find the docs for the contrib tools.
Since version 1.8 one can use a feature repository dictated configuration to automatically set properties on server side.
From Automatic Property Setting:
[...] a set of property definitions which all connecting clients automatically consider when operating on working copies checked out from a given server. Subversion 1.8 and newer clients support such functionality through the
svn:auto-props
inheritable property.
Note that you only need new enough client. Below you'll find a complete example where I used svn command line client 1.8.8. with svn server 1.6.11.
svn client version 1.8+ required
jani@dev:/tmp/testrepo/text-files$ svn --version --quiet
1.8.8
Files created before auto-props property setting
jani@dev:/tmp/testrepo/text-files$ file f?.txt
f1.txt: UTF-8 Unicode text
f2.txt: UTF-8 Unicode text, with CRLF line terminators
f3.txt: ASCII text, with CRLF line terminators
jani@dev:/tmp/testrepo/text-files$
Set auto-props
jani@dev:/tmp/testrepo/text-files$ svn propset svn:auto-props "*.txt = svn:eol-style=LF" .
property 'svn:auto-props' set on '.'
jani@dev:/tmp/testrepo/text-files$ svn proplist -v --recursive
Properties on '.':
svn:auto-props
*.txt = svn:eol-style=LF
jani@dev:/tmp/testrepo/text-files$
Create new file f4.txt with CRLF line terminators
jani@dev:/tmp/testrepo/text-files$ file f?.txt
f1.txt: UTF-8 Unicode text
f2.txt: UTF-8 Unicode text, with CRLF line terminators
f3.txt: ASCII text, with CRLF line terminators
f4.txt: UTF-8 Unicode text, with CRLF line terminators
jani@dev:/tmp/testrepo/text-files$
The line terminators of f4.txt changes after commit
jani@dev:/tmp/testrepo/text-files$ svn add f4.txt
A f4.txt
jani@dev:/tmp/testrepo/text-files$ svn commit -m 'just another test' .
Adding f4.txt
Transmitting file data .
Committed revision 5.
jani@dev:/tmp/testrepo/text-files$ file f?.txt
f1.txt: UTF-8 Unicode text
f2.txt: UTF-8 Unicode text, with CRLF line terminators
f3.txt: ASCII text, with CRLF line terminators
f4.txt: UTF-8 Unicode text
jani@dev:/tmp/testrepo/text-files$ svn proplist -v --recursive
Properties on '.':
svn:auto-props
*.txt = svn:eol-style=LF
Properties on 'text-files/f4.txt':
svn:eol-style
LF
jani@dev:/tmp/testrepo/text-files$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With