skip to Main Content

I am trying to set up an auto-versioning update on TortoiseSVN for a project I’m working on. It’s very straightforward; the code is supposed to pull the SVN revision and display the date & location whenever anyone does a checkout/update from the repo.

Below I have a template class

    public static class SvnRevision
    {
        /// <summary>
        /// SVN repo revision
        /// </summary>
        public const string REVISION = "$WCREV$";

        /// <summary>
        /// SVN repo location
        /// </summary>
        public const string REPOSITORY_URL = @"$WCURL$";

        /// <summary>
        /// SVN repo date
        /// </summary>
        public const string REPOSITORY_DATE = "$WCDATE$";
    }

I want to know the background steps necessary to get this program to work. Appreciate if anyone could provide a walk through or tutorial. I am trying to do this on Visual Studio 2022.

I made commits using this class to SVN without any luck, a search indicates that I need to set up versioning and provide some kind of source/destination files that I don’t know how to do. Below is a link I’ve referenced.

https://docs.huihoo.com/tortoisesvn/1.5.7-en/tsvn-subwcrev-keywords.html

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for all the help everyone. Likely my line of questioning was not clear or I worked it wrong, but the problem was that I needed to set a command line as a prebuild event so that the SVN keywords would update.

    Prebuild event command line: "C:Program FilesTortoiseSVNbinSubWCRev.exe" "$(ProjectDir)." "$(ProjectDir)SvnRevision_Template.cs" "$(ProjectDir)SvnRevision.cs"


  2. Before selecting The Right Thing ™ for your task and|or using SubWCRev (which you try to use, according to used subwcrev-specific keywords) you have to know some things

    1. Best (and, really, single correct place) for reading updated, relevant to latest release docs about SubWCRev is TortoiseSVN website (SubWCRev is part of TortoiseSVN distribution and is not of pure SVN per se)
    2. "…whenever anyone does a checkout/update from the repo" such person with WC of your repo have more natural way to know, which revision he|she got and whence: ordinary svn info tells it, instead of reading your code or compiling it in order to see message-box with collected data
    3. Contrary to SVN-keywords, which work from a box (when inserted into files) and updated automagically on the fly, subwcrev’s keywords have to have "release" stage (read docs): you insert keywords in template-file, which, after processing by SubWCRev, will produce new file, in which template-placeholders are replaced by data, actual only for this moment and not updated automatically after WC-changes (you must to refresh files from templates again)

    In your case you can

    • move public static class SvnRevision into somename.cs.tpl with all needed keywords
    • Before all other steps in your compile-chain add call of SubWCRev, smth.like SubWCRev.exe pathtoWC somename.cs.tpl somename.cs
    • In you code use references to somename.cs, which also have to be in svn-ignore and not versioned, while template have to be versioned

    HTH

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search