2011-07-06

Connecting Mantis with Rhodecode

This how-to describes how I have setup Mantis and Rhodecode to communicate with each other.
Update (16-7-2011):
Version 0.3 of the Mantis plugin supports repository groups, introduced in RhodeCode 1.2
Update (03-09-2011): Adjusted hook in rhodecode from changegroup to incoming.
Adjustment (02-09-2012):
Version 0.3.1 support api-keys (more info)
Update (29-12-2012):
Version 1.5.0 of Rhodecode changes the Raw-Changeset page. For interaction with Rhodecode 1.5.x you need version 0.4.0 of the Mantis RhodeCode connector

Mantis

Mantis Bug Tracker is a FOS (Free and Open Source) issue tracker widely used in the Open Source community running on PHP. John Reese has added a plugin category called Source Integration (source). This offers several integration advantages between your preferred Source Control solution (Git(hub), SVN) and Mantis.
With this integration you can connect a commit/checkin/push to a specific issue (bug, feature, task) so you can track those. Using special commit messages it’s possible to change the status of issues to resolved.

Rhodecode

Rhodecode is a python-based local webservice for a set of Mercurial repositories built by Marcin Kuzminski. It has some nice features not found in the default Mercurial web-server:
  • Authentication based on LDAP
  • Private repositories
  • User-levels (admin, write, read, none)
  • Gravatar integration
Looking at the roadmap, Rhodecode wants to offer Git-hosting as well.
You can look at Rhodecode as a private/local Bitbucket version

Connecting Mantis with Rhodecode

The connection between Mantis and Rhodecode consist of two parts:

Mantis Source integration plugin

Prerequisite: Installed Source Integration plugins.
First part is an extension of the Source Integration plugin, you can download that from Bitbucket (version 0.2.1), extract this plugin and copy the SourceRcWeb directory into the Mantis BT plugins directory and log-in to Mantis.
When you open the Manage Plugins page (http://%yourmantisURL%/manage_plugin_page.php) you’ll see a Rhodecode plugin in the available plugins list:
RhodeCodeAvailable
Now click the Install link, and the plugins is installed.
Proceed by going to the RhodeCode plugin configuration page (http://%yourmantisURL%/plugin.php?page=SourceRcWeb/config):
RCWeb_configuration
This dialog allows you to set a default URL for your repositories, this can be overwritten per repository.

Installing Rhodecode hook

Prerequisite: Installed and working Rhodecode setup.
Rhodecode supports the same hooks as Mercurial, however there is currently (version 1.1.8) not an integrated Web-UI way to setup hooks.
To install the hook script (located in the root of the download) you’ll need to edit the SQLite database file used by Rhodecode (rhodecode.db by default).
I used SQLite Database browser, and edited the rhodecode_ui table and added a record with the following contents:
  • ui section: hooks
  • ui key: incoming.mantis
  • ui value: path of the changegroup file
The used incoming file is the hook script. Make sure the script is executable by the user running Rhodecode (eg: www-data).

Adjusting Rhodecode hook

The Rhodecode hook uses curl to call the webinterface of Mantis, you’ll need to adjust it to math your situation.
#!/bin/sh
# Replace mantis with the URL of your actual mantis install
URL="http://mantis/plugin.php?page=Source/checkin.php"
PROJECT=${PWD##*/}
echo "Mercurial project: "$PROJECT
echo "Mercurial node: "${HG_NODE}
CURL=/usr/bin/curl
echo "Updating Changeset to Mantis Bug Tracker"
${CURL} -s -S -d "repo_name=${PROJECT}" -d "data=${HG_NODE}" ${URL}
Line 3 contains the URL of you the checkin php script, make sure this is adjusted and accessible from the Rhodecode server. If you are running version 0.16.3 of the Mantis plugin you’ll need to add an API-key to the curl command (info):
API_KEY="xxxxxxxxxx"
${CURL} -s -S -d "repo_name=${PROJECT}" -d "data=${HG_NODE}" -d "api_key=${API_KEY}" ${URL}
This hook is triggered every moment something is added to the repository and sends the information about the commit (project and commit-id) to Mantis.

Adding a repository to Mantis

Now everything is setup we’ll need to add the repository to Mantis.
There is one prerequisite to read the Rhodecode information, the repository needs to be readable by an anonymous user in Rhodecode, so you’ll need to configure Rhodecode to allow anonymous read for the given repository.
On the repositories page (http://%yourmantisURL%/plugin.php?page=Source/index), there is an option to add a Rhodecode repository.
CreateRepo
Make sure the Name is exactly the name of your repository, after ‘Create Repository’ the following dialog opens.
UpdateRepository
The details from the generic configuration as well as the repository name are used to configure the repository. Per default there is no additional configuration necessary.
After this action you can use the Import Latest Data function to get all the information from Rhodecode:
Import-Latest
After these actions you have all the information connected, you can browse in Mantis all your commits, their parents and connected issues.

Connecting a commit to an issue

Mantis filters the commit message to connect a commit to a specific issue.
Per default the following patterns are recognized:
  • issue #ddd
  • issues #ddd
  • bug #ddd
  • bugs #ddd
  • report #ddd
  • reports #ddd
To fix an issue the following patterns are accepted:
  • fixes #ddd
  • fixed #ddd
  • fix #ddd
  • resolved #ddd
  • resolves #ddd
ddd is the number of the issue, the hash (#) is mandatory. Look in the configuration of the Source Plugin to alter these patterns if you need that.

Result

What happens if you push something into Rhodecode, the hook will be triggered and you’ll see in the feedback from Rhodecode what Mantis is doing:
remote: Mercurial project: test
remote: Mercurial node: fe7fbe7c8644a6ff20f0ddf773c6e19eee6bc7dd
remote: Updating Changeset to Mantis Bug Tracker
remote: <pre>Retrieving test from ... </pre>Retrieving fe7fbe7c8644a6ff20f0ddf7
73c6e19eee6bc7dd ... Processing fe7fbe7c8644a6ff20f0ddf773c6e19eee6bc7dd ... sav
ed.

2011-05-19

LabVIEW Idea Exchange introduction

National Instruments has a feature request feature website called Idea Exchange (IE). For several of their products (DIAdem and DAQ hardware amongst others) there is a place where you can post your ideas of improvement of that specific product. However the most popular version of that Exchange is the LabVIEW Idea Exchange. There are numerous ideas (currently more than 100) and recently the 50.000th vote (kudo) was given on that site. There's a blog about the Idea Exchange from a development and marketing point of view.
With the release of LabVIEW 2010, NI made a video with the authors of some of the ideas implemented in 2010:
Personally I think NI only picked 'easy' ideas for LV2010, but if you look at the items labelled 'in beta' it gives you a good idea of what's to come in LV2011. And those are promising!
In a series of blog-posts I would like to discuss some of (my) ideas that I think should deserve more kudos because they are valid for the LabVIEW programming language, so stay posted!
If you want a sneak peak of what I like to plug, have a look at this query on the site. If you'd like to vote, you'll need a NI forums account, which is free and allows you to add your own ideas or questions directly to NI.