Subversion Extended

From HaFrWiki
Jump to: navigation, search

Clever use of the properties of Subversion will ease your work with the CVS enormous. But the manual is not very clear how to set and get the properties well. Especially the property for ignoring files under VCS such as log-, temp- and backup-files.

svn:ignore propset

Users wish to ignore multiple files with distinct names in the same folder beware: you must use a file and batch-process. It’s not difficult to figure out that to tell SVN to ignore a file, you use:

 svn propset svn:ignore [filename] [folder]

Suppose a file config.php in folder config. Enter in this config folder the following:

 svn propset svn:ignore config.php .

What if however another file in the same folder, database.php, has to be ignored withour ignoring all other *.php files? The following will not work:

 svn propset svn:ignore “config.php database.php” .
 (incorrect syntax)
 svn propset svn:ignore “*.php” .
 (but we don’t want to ignore some .php files)

nor would the following, because svn for some odd reason seems to only take one propset assignment from the commandline - meaning only one of the files will be ignored:

 svn propset svn:ignore config.php .
 svn propset svn:ignore database.php .

It turns out you 'll have to make a file with the filenames on separate lines, then call with the -F parameter. For example in the above case: create a file with config.php and database.php on separate lines, then call

 svn propset svn:ignore -F .

Annoying. SVN should let you set the same property on multiple files with multiple command-line calls.


Normal we do not want to backup a lot files. So create a file called in the root of the CVS working directory.


Go to the command line and execute the statement:

 svn propset svn:ignore -F .
   results in:
 property 'svn:ignore' set on '.'


 svn propget svn:ignore
   results in:


 svn proplist .
   results in:
 Properties on .


 svn status --no-ignore
    results in
 I   xx.log
 I   xy.log
 I   yy.tmp
 I   zz.log


Using keyword substitution in Eclipse is easy to do, but not documented very well [1]. Here are the steps:

  • Create block to be placed into your code.
    Please note:
    • Do not make it a JavaDoc comment so use /*.
    • The spaces are needed for formatting, so do not forget them.
 SVN properties of the last commit will be skipped by Java Doc.
 $Rev::                                                 $:  Revision
 $Author::                                              $:  Author
 $Date::                                                $:  Date
  • Install Subclipse [2].Probably already done before reading this item.
  • Right-mouse-click on your project folder, and choose Team => Set Property from the pop-up menu.
  • Enter the property name: svn:keywords. Please note this can not be selected. Just type the sentence.
  • Enter the text property: Rev Author Date
  • Click the Set property recursively check-box.
  • OK

That's all.

Settings $Id$ Tag

Alternative for the above settings you can also set the $Id$. Below is how.

In CVS the $Id$ tag is set automatically. This looks like:

  $Id: test.php 110 2009-04-28 05:20:41Z dordal $

For more than one reason this is helpful:

  • The revision is shown immediate in your editor.
  • The revision is shown in exported code.

To do this also in Subversion:

  1. Update the file ~/.subversion/config.
  2. Set props on files
  3. Put the Id tag in your files.

Update subversion config file

This file is located in : ~/.subversion/config. Add or change the following items:

### Set enable-auto-props to 'yes' to enable automatic properties
### for 'svn add' and 'svn import', it defaults to 'no'.
### Automatic properties are defined in the section 'auto-props'.
enable-auto-props = yes

*.html = svn::keywords=Id
*.php = svn:keywords=Id
*.js = svn:keywords=Id

Set props

Now set the props to all existing files. Iuuse the command:

 find . \( -name "*.php" -o -name "*.js" \) -exec svn propset svn:keywords Id {} \;

Find will return a list of all .php and .js files and then run svn prop set on those files.

Id Tags

In every file put:

@author Harm Frielink <>
@version $Id$

Remove .svn directories

The following tip comes from Any Example [3].


  • Use a Windows find utility and search for the .svn directories.
  • Delete all .svn directories. Please note to repeat the search command to view the results.


Finding all .svn directories, use:

$ find . -type d -name .svn

To remove all these directories use: (Please not the ` character is left of the 1 on your keyboard

$ rm -rf `find . -type d -name .svn`

Warning: Always be aware in which directory you are (Use pwd)

Deleting Missing files

If you upgrade your mediawiki instance, a lot of files are no longer required.
But they are still in subversion's repository.
This command will erase those files from your repository [4]

If you're using Mac (Darwin) or Linux you can pipe the outputs of the following commands to svn rm for all missing files.
You can set the current working directory to the appropriate directory or subdirectory before running these - dependent on whether you want to run this your entire working copy, or only a subset.

  1. Run an svn status,
  2. Search for lines that begin with "!" (missing),
  3. Print the "--force" (svn argument) and the second column (the file name) of the output from #2 with respect of spaces in the name,
  4. Run svn rm using the output of #3 as arguments.
$ svn st | grep ^! | awk '{$1=""; print " --force \""substr($0,2)"@\"" }' | xargs svn rm"

After this command you'll need to do a svn -m "Deleting missing files" commit.

See also




  1. svn Red Bean, Version Control with Subversion for Subversion 1.4, Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato
  2. Subclipse, Plug-in for using Subversion within Eclipse
  3. Any Example, How to remove recursively svn-directories.
  4. Stack Overflow, Svn command to delete all locally missing files.