: Blog

Tip: Keeping svnmerge quiet

Published on Thursday, March 8, 2007

Merges without the noise

If you use svnmerge and you have a CIA bot on your IRC channel, you may have noticed that the merge-related log messages are long. Really long. Also, kinda ugly.

CIA's filtering capabilities to the rescue. Open up your CIA account and head over to your bot's settings page. This example will assume you're using Basic Filtering. If you're already using advanced filtering, you can use that filter as a starting point.

Switching to Advanced Filtering

The web interface can't yet help you out if you're using Basic Filtering and you want to transition to Advanced, but it's pretty easy to do once you know the steps.

Let's say your bot is set to Filter by Project, and Prefix each commit with its project name is checked. Your project list might look something like:

python
navi-misc
asterisk.org

Click the "Advanced Filtering" tab, and write a filter like the following:

<or>
    <match path="project"> python </match>
    <match path="project"> navi-misc </match>
    <match path="project"> asterisk.org </match>
</or>
<formatter medium="irc"/>
<formatter name="IRCProjectName"/>

If you don't want the project name prefixes, you can omit that last line. Also, if you only have a single project you don't need the <or> and </or> tags.

Customizing the filter

For the final step, add a new <rule> section between the projects and the "irc" formatter. The final ruleset should look like the following:

<or>
    <match path="project"> python </match>
    <match path="project"> navi-misc </match>
    <match path="project"> asterisk.org </match>
</or>

Cut down on svnmerge spam...
<rule>
    <find path="log">svnmerge</find>
    <formatter medium="irc">
        <lineLimit>2</lineLimit>
    </formatter>
    <formatter name="IRCProjectName"/>
    <break/>
</rule>

<formatter medium="irc"/>
<formatter name="IRCProjectName"/>

Notice that you can write comments as plain text in most circumstances. This <rule> element is like a miniature sub-filter embedded in your larger filter. If it doesn't find the text "svnmerge" somewhere in your log message, it stops running the sub-filter. Otherwise, it will apply a tweaked version of the usual formatting: this time with at most two lines of the log message. After applying the new formatting, it uses <break/> to terminate execution of the entire ruleset, to avoid running the IRC formatter twice.

For more tips on using CIA's advanced filtering to customize your IRC bot, take a look at the filtering reference manual.