tags:

views:

248

answers:

5

I'm working on a project in which we're actively using the $Id$ string generated by subversion to write the version number in the documentation. For example, we parse this string

$Id: filename 999 2009-02-23 22:51:29Z author $

and print "999" in the documentation titlepage.

But every now and then, after a commit, the information is removed and we're left with just

$Id$

This obviously breaks things a little. Does anyone know why it might be happening?


Okay, the obvious answer was correct; svn:keywords weren't set for that file any more. But I swear they used to be! Any idea how/why svn:keywords would have been cleared from a file without anyone noticing/doing anything on purpose?

+4  A: 

The svn:keywords property may not be properly set on that file. You need to set it to (at least) 'Id':

svn ps svn:keywords 'Id' filename.txt
Sean Bright
Thanks, I should have checked that first off; the keywords weren't set for this file like you suspect — but I swear they used to be!
Will Robertson
If you are running the command line SVN client, you can set defaults for this stuff in your ~/.subversion/config file. That _may_ apply to TortoiseSVN as well, but don't quote me on that.
Sean Bright
A: 

Keywords are expanded on checkout only, if the 'svn:keywords' property is defined. When using repository browsing tools like ViewSVN, they should not be expanded, ie. they are displayed as $Id$.

Ferdinand Beyer
So if I've "lost" the SVN keywords (the keywords are set but they haven't been expanded), is there a way I can force a "checkout" that expands them?
Will Robertson
+2  A: 

The answer you have selected is correct. You could additionally look at setting your auto-props to enable the keyword property automatically. See http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.4

When you've done that you could occasionally run svn_apply_autoprops.py from http://subversion.tigris.org/tools_contrib.html

svn_apply_autoprops.py will check your autoprops settings and go through your repository setting it all up.

Stewart Robinson
A: 

Okay, the obvious answer was correct; svn:keywords weren't set for that file any more. But I swear they used to be! Any idea how/why svn:keywords would have been cleared from a file without anyone noticing/doing anything on purpose?

The first reason I can think of would be: If the file was svn-added and then moved/renamed before the first commit the auto properties weren't applied.

The bug that makes a file lose its properties in this case will be resolved in Subversion 1.5.6 and 1.6.0.

Bert Huijben
+1  A: 

Make sure your file is in UTF-8 and NOT in Unicode. Unicode ones does not get expanded as SVN thinks these are not text files... I used Notepad Save As UTF-8 to solve the problem

I've spent 6 hours today trying to figure out why an existing text file in SVN could not get svn:keyword expansion working. The encoding of the text file was the problem. You have saved me from going crazy!
tyriker