Subversion logfile overviewΒΆ

Tags: work

My administration was a bit of a mess last month and I didn't get around to writing down my hours. Now, that's not necessarily a problem cause most of my work is in subversion, so I can always look at the logfile. But filtering out my commits from the other busy bees at the company takes some time. Time to automate things!

You can use svn --verbose --xml log http://yourserver.org/yourrepository to give you an xml log of all the changes in your projects. If you add a -r{"2006-01-01"}:HEAD you restrict it to last 1 Januari till now. Redirect the output to an xml file and process that (with saxon or xsltproc for instance) with the following xslt file:

  <?xml version="1.0"?>
  <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xml="http://www.w3.org/XML/1998/namespace"
      xmlns:date="http://exslt.org/dates-and-times"
      version="1.0">
    <xsl:output
      method="html"
      encoding="UTF-8"
      indent="no"/>

    <xsl:template match="/">
      <html>
        <head>
          <title>Uren</title>
          <style>
            .discreet { font-size: 80%; }
            @media print {
            .noprint {display:none}
            td {
            font-size: 80%;
            }
            }
          </style>
        </head>
        <body>
          <xsl:apply-templates select="/log"/>
        </body>
      </html>
    </xsl:template>

    <xsl:template match="log">
      <table border="1">
        <tr>
          <th>Date</th>
          <th>Message</th>
          <th class="noprint">Changed files</th>
        </tr>
      <xsl:apply-templates
          select="logentry[author='reinout']"/>
      <!-- ##################################### -->
      <!-- Change this author name to yours -->
      <!-- ##################################### -->
      </table>
    </xsl:template>

    <xsl:template match="logentry">
      <tr>
        <td>
          <xsl:value-of select="date:date(date)"/>
        </td>
        <td>
          <xsl:value-of select="msg"/>
        </td>
        <td class="discreet noprint">
          <xsl:apply-templates select="paths/path"/>
        </td>
      </tr>
    </xsl:template>

    <xsl:template match="path">
      <div>
        <xsl:value-of select="."/>
      </div>
    </xsl:template>

  </xsl:stylesheet>

That gives you a handy html overview. It sure saves me at least 15 minutes right now, so it already paid for about half the time it took to make the template :-)

blog comments powered by Disqus
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):