R – Modifying File Before Subversion Commit

svntortoisesvn

I am using TortoiseSVN for Windows and want to figure out if I can set up some sort of macro to modify one of the files in the repository on a commit.

In my subversion repository I have a XML File called "Web.Config". There are a few nodes with the tag name "add" set up in that XML document which represents the "Build Number", "Build Description" and "Last Build Date" under the XML Path /Configuration/appSettings. This XML file uses the "key" attribute on the "add" node to determine which of these settings are being set.

The above mentioned nodes are being changed by hand before each commit (supposedly, but I don't always do this).

My question is:
Is it possible to modify these settings in the file when I commit?

Best Answer

Maybe using svn pre-commit hooks?

The other option (the one I would prefer and use) is to place this data into your Web assembly during the build, and then you read it programmatically in your code. If you're using .NET, that is :)

  1. Add a step to your build to generate a common AssemblyInfo.cs. (see [http://blog.darrenstokes.com/2007/12/17/ease-versioning-multiple-assemblies-by-splitting-up-assemblyinfo/])1
  2. "Add as Link" this file to each of your projects
  3. When you need this information, you can get it from Reflection, example:

    System.Diagnostics.FileVersionInfo version = System.Diagnostics.FileVersionInfo.GetVersionInfo
    (System.Reflection.Assembly.GetExecutingAssembly ().Location);

    Console.Out.WriteLine ("MyApplication v{0} by Me", version.FileVersion);