Introduction

Svn Notes is a small tool written in C# that consumes a piped xml output of an svn log command and outputs a change log / release notes file.

How it works

Svn Notes works on tags added to a line in an svn comment:-

SvnNotesLogMesage.jpg

Lines in a comment that have no tag will be ignored.

When your ready, you can generate a nice file by using the command from your projects root:

svn log --xml --revision 4365:HEAD | svnnotes log.txt

This will tell svn to pipe an xml log from revision 4365 to HEAD into svnnotes where svnnotes will generate the file, log.txt, which will look something like this:

ADDED

    - Great new feature

FIXED

    - [#1234] Horrible crippling bug

CHANGED

    - Big button to small button

Tags, Notes and Id's

Svn Notes uses tags such as FIXED, CHANGED and ADDED, these tags can actually be anything such as FOO, BAR or BAT. Internaly a regular expression is used to parse out the tag, note and id from each line in an svn log comment.

The Id is handy if you use a bug or issue tracking system.

Changing the format of tags, notes and id's
You might not be entirely happy with the format of tags, by default Svn Notes uses the following regular expression to parse out the tag, note and id from a single line in an svn log comment.

(?<tag>[A-Z]+)([\s]+)?(?<id>\[#[0-9]+\])?([\s]+)?:(?<note>.*)$

You can override this by changing the appSetting SvnNotesRegEx in the SvnNotes.exe.config file but you must make a regular expression that has the named groups <tag>, <id> and <note>.

Output Transformers

By default, Svn Notes uses a built-in DefaultOutputTransformer, if you want to format the output of Svn Notes in html or xml, you can write your own output tranformer by implementing the interface IOutputTransformer that is available when you reference svnnote.exe from a class library project.

When Svn Notes is done parsing the svn xml output, it creates an instance of an output transformer and hands the transformer a Dictionary<string, EntryCollection> where string is the Tag and EntryCollection is a list of Svn Log entries, each entry contains the author, date, revision and note.

Here is the CodeplexOutputTransformer that is bundled with Svn Notes, it transforms svn notes output into codeplex wiki format:

    public class CodeplexOutputTransformer : IOutputTransformer
    {
        #region IOutputTransformer Members

        public Dictionary<string, EntryCollection> Entries { get; set; }

        public object Transform()
        {
            StringBuilder output = new StringBuilder();
            foreach (string key in Entries.Keys)
            {
                output.AppendFormat("!! {0}", key);
                output.AppendLine();
                foreach (Entry entry in Entries[key])
                {
                    output.AppendFormat("* {0}{1}", entry.Id, entry.Note);
                    output.AppendLine();
                }
            }

            return output.ToString();
        }

        #endregion
    }
When implementing this interface, its just a matter of implementing the Transform() method, if the method returns a string, then the output will be written as text, if the method returns a byte array, then the output will be written as binary to the specified file passed to svnnotes.exe.

Here is an example of using an output transformer, the command has been broken onto two lines to preserve width.

svn log --xml --revision 0:HEAD | svnnotes log.txt 
/transformer "CodeplexOutputtransformer.CodeplexOutputTransformer, CodeplexOutputTransformer.dll"

Feedback

This project is very new, any feedback is very helpful!

Last edited Oct 11, 2008 at 9:46 PM by fluxtah, version 13