Skip to content

SVN Log History By User to HTML

Most SVN users who use the command line client understand how to create a log in XML format:

svn log --xml -v svn://some/url > svnlog.xml

But this dumps the whole log, and I really just want to see a specific user. Plus, I hate XML and definitely do not want to read it.

Here is a handy stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
        <h2>Header</h2>
        <table border="1">
                <xsl:for-each select="log/logentry">
                        <xsl:if test="author='YOUR_NAME_HERE'">
                                <tr>
                                        <td><xsl:value-of
select="@revision"/></td>
                                        <td><xsl:value-of
select="author"/></td>
                                        <td><xsl:value-of
select="date"/></td>
                                        <td><xsl:value-of
select="msg"/></td>
                                </tr>
                                <xsl:for-each select="paths/path">
                                        <tr>
                                                <td></td>
                                                <td><xsl:value-of
select="@action"/></td>
                                                <td><xsl:value-of
select="."/></td>
                                        </tr>
                                </xsl:for-each>
                        </xsl:if>
                </xsl:for-each>
        </table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

Simply add a header line to your output log, like this:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>
<log>
<logentry
   revision="6610">

Add the username you wish to filter on in the stylesheet (in place of YOUR_NAME_HERE), and open the log file in the browser.

Hat tip to:
Subversion Users mailing list
w3schools how to use xslt

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

8 Comments

  1. toc wrote:

    YOU ARE
    !!A W E S O M E!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    thanks for a cool style sheet!

    Thursday, December 17, 2009 at 1:29 pm | Permalink
  2. gedz wrote:

    Nice idea. But its not working for me. after generating the xml output and placed the line in the xml ‘. I did not get the desired out put.

    what I am doing wrong?

    Monday, February 22, 2010 at 8:18 pm | Permalink
  3. gedz wrote:

    Ok. Take that back. it works fine…!! thanks.

    Monday, February 22, 2010 at 8:25 pm | Permalink
  4. gedz wrote:

    Quick format upgrade:

    after

    Revision#
    Authortd>
    Change path
    Log Message

    Then……

    Set the td with for the respective values
    Example:

    and so on…..

    Monday, February 22, 2010 at 8:56 pm | Permalink
  5. gedz wrote:

    Quick format upgrade:

    after table border =1
    tr
    td width=”80″ bgcolor=”" bordercolor=”" bordercolorlight=”" bordercolordark=”"Revision#/td
    td width=”80″ bgcolor=”" bordercolor=”" bordercolorlight=”" bordercolordark=”"Author/td
    td width=”963″ bgcolor=”" bordercolor=”" bordercolorlight=”" bordercolordark=”"Change path/td
    td width=”200″ bgcolor=”" bordercolor=”" bordercolorlight=”" bordercolordark=”"Log Message/td
    /tr

    Then……

    Set the td with for the respective values
    Example:

    td width=”80″xsl:value-of select=@revision//td

    and so on…..

    Monday, February 22, 2010 at 8:57 pm | Permalink
  6. Jeff wrote:

    Glad that worked out for you GEDZ, thanks for the format upgrade tip.

    Tuesday, February 23, 2010 at 12:40 pm | Permalink
  7. Mr x wrote:

    How about generating some statistics on top, like total number of commits of specific user, commits per month by specific user and commits by specific user in comparison to total amount of commits made?

    Who can contribute?

    Friday, September 17, 2010 at 1:27 pm | Permalink
  8. Jeff wrote:

    Sounds like a good idea Mr X.
    I haven’t committed this to a repo anywhere. Feel free to take what I’ve posted and run with it.
    If you commit it to github or some other place, please consider posting a link via comment here.

    Friday, September 17, 2010 at 2:53 pm | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*