If you forgot to set your svn:keywords…

Somehow the Subversion auto-props didn’t cause my svn:keywords to automatically be set in my classes, and now I had 32 classes that, if I set the properties through Eclipse, I’d have to fix manually.

Me no like 32 repetitions of same thing.

So I looked for a way to do it from the command line.

Here’s a way that worked for me:

(I ran the following once from the project’s src/main/java, and once from src/test/java)

svn propset -R svn:keywords "Author Id Revision Date" .

Part of why this works so easily is that, guided by the Maven defaults, we’re set up with our Java source code split out from the other files into src/{main,test}/java.  If the XML configuration files were in the same directory with Java source code, it would take more work to set the property on just the Java files, I think.

Update 10/10/2008: Ben (“New Ben”, I mean) helped me find two good things!

Why auto-props weren’t working

Even though I had the line

*.java = svn:keywords=Author Id Revision Date

in the [auto-props] section of my Subversion config (C:\Documents and Settings\myUserName\Application Data\Subversion\config), it wasn’t adding those keywords on commit.

It turns out there was one additional thing to do: in the [miscellany] section of the same config file, I needed to uncomment the line that reads:

enable-auto-props = yes

Ha!

Mass Keyword-Adding Using Eclipse

The other thing Ben showed me was how to recursively set the keywords from within Eclipse.

  1. Right-click on the source folder (src/main/java, for instance) and choose Team -> Set Property…
  2. For Property name, enter svn:keywords (a warning appears at this point, but we will satisfy it soon)
  3. In the “Enter a text property” box, enter (in my case) Author Id Revision Date
  4. Check the Set property recursively box
  5. Click OK.

I then repeated this procedure on the src/test/java folder.

Thanks, Ben!

Advertisements

, ,

  1. #1 by T. Brandt on August 25, 2009 - 9:05 am

    Thanks a lot!
    Your article saved me a lot of time ;)

  2. #2 by danielmeyer on August 25, 2009 - 11:49 am

    Glad to hear it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s