Skip to content
February 16, 2010 / Nandha kumar

Trac Installation with Mercurial in Ubuntu 9.10

Hi to all,

This blog is helpful in setting up Trac in a Ubuntu 9.10 system with Hg-Mercurial as the source control system.

First of all to begin with – What is a Trac ?

  • Trac is an open source project , a enhanced wiki and issue tracking system for software development projects.
  • Trac is mainly used to make the developer feel ease in developing the code even if he is away from the project area.
  • It provides an interface to several version control systems like Subversion, Mercurial, Git and more
  • It also provides interface to integrated Wiki and convenient reporting facilities.

Trac uses wiki-markup to

  • Issue descriptions and commit messages
  • create links
  • create references to bugs, tasks, changesets, files and wiki pages

Two terms are importantly used in Trac

  • Timeline – shows current and past project events in order
  • Roadmap – shows the upcoming milestones to be achieved in the project

Mercurial :

Mercurial is a free, distributed source contol management tool. Mercurial has a distributed architecture which creates a local copy of all the version history of the project at the client side , hence making the client independent of the traditional client-server architecture that is followed in other version control systems like Subversion.

Mercurial is truly platform independent , really fast due to its distributed architecture and simple to use due to its easy commands to use it.

Now we can see on how to install both mercurial and trac and the way to integrate them.

INSTALLATION :

MERCURIAL :

To install mercurial directly you can use the command

     apt-get install mercurial

To install mercurial from the source , visit the following site and download the tar file of the latest version of mercurial

http://mercurial.selenic.com/downloads/

The latest version is mercurial-1.4.3

Extract the downloaded mercurial using the command

          tar zxvf mercurial-1.4.3.tar.gz

You can also right-click on the tar file and give “extract to” or “extract here” command.

Now you will see a folder named “mercurial-1.4.3” in the specified location

give the following commands to install mercurial using a terminal

     cd mercurial-1.4.3
     sudo make install    # to make a global install

Now mercurial is installed on your system. To check whether mercurial is installed give the following command in a terminal

     hg version

You can see a output like below

    Mercurial Distributed SCM (version 1.4.3)
    Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE.

To gain more information regarding mercurial you can visit the site

http://mercurial.selenic.com/

TRAC :

To install Trac on the system there are several pre-requisites are

  • Python 2.4 or more

python can be installed as follows

     sudo apt-get install python

Or you can download the source package from the site

http://www.python.org/

and do as told in the README file in the extracted directory of source to install it.

The latest version of python is 2.6.4 .

  • setuptools 0.6 or more

setuptools is a Python module that helps to compile, distribute and install Python packages by wrapping them into “egg”s. Eggs contain additional information to process dependencies, etc.

setuptools can be installed as follows

    svn co http://svn.python.org/projects/sandbox/trunk/setuptools
    cd setuptools
    python setup.py install

The version of setuptools can be found by typing the following commands ina terminal

    $  python
    $  >>>  import setuptools
    $ >>>  setuptools.__version__

The output will be as follows

‘0.6c9’


  • genshi 0.5 or more

Genshi is a Python library that provides an integrated set of components for parsing, generating, and processing HTML, XML or other textual content for output generation on the web. Its main purpose is it is used as a template language

genshi can be installed as follows

    easy_install Genshi

or we can download the source from the site

http://genshi.edgewall.org/wiki/Download

latest version is 0.5.1

untar it ,

    cd Genshi-0.5.1
    python setup.py install

Trac supports three databases which can be used as back-end in our project . They are SQlite , POSTGreSQL and MySQL .

Usage of each databases requires separate instructions to be followed.

This blog will make use of MySQL since it is more popular in usage.

Initially mysql must be installed with the latest version.

The latest distribution is 5.1.37 .

We may also need to install some packages like

autoconf, libtool, docutils

The next thing we need to do is configure the web server . Trac supports the Apache web server and to integrate it with Trac we must install apr and apr-util packages.

apr is the acronym for Apache Portable Runtime utility library.

These packages can be downloaded as source from the link

http://apr.apache.org/download.cgi

the latest release is 1.3.9

Download both apr and apr-util and untar it

       cd apr-1.3.9 
       ./configure

       sudo make 
       sudo make install

After these steps the apr-util package can be installed along with the apr by the following commands

    cd apr-util-1.3.9 
    ./configure  --with-apr=[ Target of apr ]

    sudo make 
    sudo make install

Now we have installed the pre-requisites needed to install Trac.

Trac Installation:

To install Trac give the following command

      sudo easy_install Trac

Or you can checkout the latest version from the subversion using

    easy_install http://svn.edgewall.org/repos/trac/tags/trac-0.12
    cd trac-0.12
    python setup.py install

Trac is now installed on the system

Configuration :

We can combine the Trac and Mercurial using a Trac plugin named “Tracmercurial

This plugin source can be downloaded from the link

svn co http://svn.edgewall.com/repos/trac/plugins/0.12/mercurial-plugin

     cd mercurial-plugin
     python setup.py bdist_egg

This plugin can be installed either globally can can be included in our project by specifying its location during integration or it can be directed downloaded into our project’s plugin folder and installed.

The plugin folder will  be available when we set Trac in our project location folder.

Now we can integrate our project with Trac using Trac-admin command.

This command allows us to act as a administator of our project and control the project .

     trac-admin /project/path initenv

By giving the above command we can set the new environment variables to our project. This command will create several folders including the plugins folder in our project location.

I have created a sample project as follows :

     trac-admin /home/nandha/mywork initenv
     Creating a new Trac environment at /home/nandha/mywork

     Trac will first ask a few questions about your environment
     in order to initialize and prepare the project database.

     Please enter the name of your project.
     This name will be used in page titles and descriptions.

Now it will prompt for the project name

     Project Name [My Project]> arduino  

Now it will ask for the database to use and its connection string.By default Trac uses SQlite. I have MySQL and hence I have configured it with MySQL as follows

     Please specify the connection string for the database to use.
     By default, a local SQLite database is created in the environment
     directory. It is also possible to use an already existing
     PostgreSQL database (check the Trac documentation for the exact
     connection string syntax).
     Database connection string [sqlite:db/trac.db]> 

I couldnot find the way to set the conncetion string for MySQL and atlast I found the solution at the link

http://www.docunext.com/blog/2007/11/trac-with-mysql.html

I installed the package “python-mysqldb” as said in the above link using the command

      apt-get install python-mysqldb

I followed the connection string format from the same link.

      mysql://username:password@hostname:port/databasename

After giving this command I continued with Trac-admin command but it showed an error stating that the portnumber specifed for MySQL is wrong and hence DB connectivity was not established.

I found the portnumber for MySQL to be 3306 from the file “my.cnf” located at “/etc/mysql” in the filesystem.

Then I tried again to configure it using this port number in Trac-admin and this time it worked fine.

After the DB we need to specify the version control system to be used for our project.By default subversion is used. To use mercurial we can specify as follows

      Repository type [svn]> hg

Now it will ask for the path of version control system. If we know it we can specify here or we can simply skip it and specify it later in the Trac.ini file located in our project folder.

      Path to repository [/path/to/repos]>  [enter to skip ]

Now you can see the following in your screen

      Creating and Initializing Project
      Installing default wiki pages  
      ------
      ------
      ---------
      --------------------------------------------------------
      Project environment for 'arduino' created.

      You may now configure the environment by editing the file:
      /home/nandha/mywork/conf/trac.ini

      If you'd like to take this new project environment for a test drive,
      try running the Trac standalone web server `tracd`:

      tracd --port 8000 /home/nandha/mywork

      Then point your browser to http://localhost:8000/mywork.
      There you can also browse the documentation for your installed
      version of Trac, including information on further setup
      (such as deploying Trac to a real web server).

      The latest documentation can also always be found on the project
      website: http://trac.edgewall.org/

      Congratulations!

Now we have successfully set Trac in our project environment. To add the mercurial we can install the tracmercurial plugin in the plugins folder inside our project .

We can also edit our mercurial details like its path or if we need to change the version control system we can do it using the “trac.ini” file.

It is located at /project/path/conf/trac.ini

To specify the location of mercurial ,

       [Trac]
       repository_type = hg
       repository_dir  = /var/lib/hg # example

specify these commands in the trac.ini file and save it.

Now to view the trac information our project, give

       tracd --port 8000 /home/nandha/mywork

Now open a browser and type

       http://localhost:8000

It will list the project details available in our project folder as follows

Trac view in browser

Now we can practice several Trac commands in our project as needed and do the project successfully.

To get more information regarding Trac , visit

http://trac.edgewall.org/

To view Installation doubts , visit

http://trac.edgewall.org/wiki/TracInstall

Advertisements

6 Comments

Leave a Comment
  1. Joris / Mar 1 2010 10:20 pm

    hi, I followed all the steps, but I get an error concerning hg, trac runs, but when I surf to the url I get:

    Warning: Can’t synchronize with the repository (Unsupported version control system “hg”: Can’t find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.

    Any idea how to solve this??

    Thanks though for the clean explanation! I’ve been looking a while for it.

    • Nandha kumar / Mar 1 2010 11:15 pm

      Dear Joris

      I think the problem would be an improper installation of TracMercurial plugin

      Try to reinstall it . I hope that might solve the problem

      commands to install TracMercurial :

      $ Svn co http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin-0.11
      $ cd mercurial-plugin-0.11 $ Cd mercurial-plugin-0.11
      $ python setup.py bdist_egg $ Python setup.py bdist_egg
      # python setup.py install # Python setup.py install

      Also edit the Trac.ini located in your local repo as

      # Include hg —————–

      [components]
      tracext.hg.* = enabled tracext.hg .* = enabled

      [hg]
      # – Show revision number in addition to the changeset hash
      show_rev = yes
      node_format = short

      Regards

      N.Nandhakumar

  2. JoachimS / Aug 23 2010 2:05 pm

    Aloha!

    There is a small typo in one of the paths: “porject”.

    • Nandha kumar / Aug 26 2010 12:13 pm

      Hi

      Corrected the mistake.

      Thanks for the correction.

      Regards
      N.Nandhakumar

  3. James Selvakumar / Oct 29 2010 1:56 pm

    Try Redmine, a much more powerful and simple to use issue tracker when compared to Trac.

    I was an avid Trac fan until I found Redmine.

  4. Arun / Jan 18 2012 1:52 am

    I am trying to setup a similar environment and I succeeded in that. The problem I am having is that the HTML files in the Hg repository are displayed as text files and not as HTML files. Is there a way to fix this and make the files displayed as regular HTML files.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: