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 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 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:
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):
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.
# Replace mantis with the URL of your actual mantis install
echo "Mercurial project: "$PROJECT
echo "Mercurial node: "${HG_NODE}
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):
${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.
Make sure the Name is exactly the name of your repository, after ‘Create Repository’ the following dialog opens.
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:
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.


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


  1. Hi Ton Plomp,

    This document is fantastic and it helped me a lot to configure my rhodecode with mantis.Now I'm facing an issue,

    My Rhodecode and Mantis both are private repositories.How can I import an private repository into mercurial.Please help me.

    1. Hello Thirumalai,

      that will be quite hard. You could try to access the Rhodecode API interface, but that would require to rewrite the connecter.

      The issue is on the Rhodecode side. I haven't seen URL filtering but you could request that.

    2. Hi Ton Plomp,

      I checked with Rhodecode and have a Idea of following,
      By of using API key,we will add a static user and consider it for all push/pull and just display author name in detail section.

      please have a look at this URL,
      (something like this)

      Will it work?If so,please guide me.I will try my level best to rewrite connector.

  2. Hi Ton Plomp,

    I'm very interested to know details about this thread too,Please help me to understand.

    I commented container_auth_enabled = false and proxypass_auth_enabled = false in production.ini.After that,I tried with restart but it was not working.Later I noticed I'm trying to list all repositories.So I tried with display changeset alone(API) and it worked fine.

    I tried the same with Mantis integration but it was not working.Fine,I did the following in Rhodecode.

    1.Removed private repository access
    2.Removed anonymous access
    3.Added read option for default.

    After this configuration I tried to pull repository from Mantis and it worked fine.I surprised and I don't know,How it was worked without any password.
    I tried to verify manually with default:default but it was not working..

    How mantis can able to connect rhodecode without any username/password??Now I'm breaking my hand to know the root cause.
    Can you help me?