SVN Log History By User to HTML

August 14th, 2008 | by jeff |

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

Post a Comment