Question

Is it possible to apply subversion auto props on every commit on a certain file (even if it is not modified)?

The reason I'm asking is that I'm working on an application which contains a version string in one source file (a constant actually) which I'd like to be updated on each commit, such that revision and date are automatically updated.

That file is not changed most of the time as it contains only the Version information! I'm asking for a way to apply svn keywords on that certain file on every commit.

Thanks for the answers so far, but neither searching SE nor reading the manual did help me so far. The solution which I'm using currently is a custom commit-script which is contained in the repository and programmers should use this to commit (it simply wraps svn commit and changes a single bit in a comment in the file to be updated). Is there a better way to do so?

Was it helpful?

Solution

Here's the specific documentation on keywords.

Let's imagine we already have file a in version control:

test zacharyyoung$ ls -l
-rw-r--r--   1 zacharyyoung  staff    64 Feb  7 20:39 a

We're going to add the $Rev$ and $Date$ keywords to the file

test zacharyyoung$ echo '$Date$' > test/a
test zacharyyoung$ echo '$Rev$' >> test/a
test zacharyyoung$ cat test/a
$Date$
$Rev$

Tell SVN which keywords to be aware of to find and replace, and commit:

test zacharyyoung$ svn propset svn:keywords "Date Rev" a
property 'svn:keywords' set on 'a'
test zacharyyoung$ svn ci a -m "1. Added keywords."
Sending        a

Committed revision 2.

After a is committed, we check its contents:

test zacharyyoung$ cat a
$Date: 2012-02-07 20:39:42 -0800 (Tue, 07 Feb 2012) $
$Rev: 2 $

Now, we'll add another line to a, commit , and check its contents again:

test zacharyyoung$ echo Another line >> a
test zacharyyoung$ svn ci a -m "1. Added another line."
Sending        a
Transmitting file data .
Committed revision 3.
test zacharyyoung$ cat a
$Date: 2012-02-07 20:46:11 -0800 (Tue, 07 Feb 2012) $
$Rev: 3 $
Another line

OTHER TIPS

Read or search here about SVN Keywords

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top