2

I've setup redmine and have working mercurial repositories.

The hg repos are located in /home/hg/repos so I've set hg as owner to be able to push.

Is it possible to make redmine automatically setup repos when "creating" them in the web UI? There's only one person I can trust with su access on our linux machine but several users should be able to create projects and associated repos. It would be ideal to set this up so redmine automatically creates those repos.

Is this possible? Am I clear enough in my question?

Martin Geisler
  • 1,271
  • 9
  • 23
Phil
  • 183
  • 11

2 Answers2

1

Yes. The reposman.rb script is explicitly meant for this purpose.

Usually it is done calling the above script on a cronjob i.e:

10 * * * * root ruby /root/redmine-1.0.0/extra/svn/reposman.rb --redmine-host http://my.redmine./ --svn-dir /data/svn/ --url my.svn.server --key=mykey --owner apache --verbose >> /var/log/reposman.log 

However, mercurial does not have an equivelent implementation as the above is for SVN (http://www.redmine.org/boards/1/topics/575). It is possible to write your own hooks to accomplish this. If you don't mind modifying the Redmine core you can use the information here as very minimal source of approach on the issue: http://joshua-enfield.blogspot.com/2010/09/adding-your-own-hooks-into-redmine.html

With above method you could call a shell script containing the commands you would normally use to create a repository. This is fully customizable. (A shell script is just a file with execute permissions containing commands as you would type them on the command line). Basically using that guide for creating a repository you would call a script which created a directory by the name of the project identifier cd into that directory and then run hg init You could then use mysql to add the repository automatically to the project identified by the project identifier.

A more elegant solution would be to use the above with native Redmine hooks in a plugin or creating copies of the modified pages in a plugin which would automatically override the Redmine core - http://www.redmine.org/wiki/1/Hooks

If you need to do anything with the database the below is helpful: https://stackoverflow.com/questions/3215902/3284099#3284099

Joshua Enfield
  • 3,404
  • 8
  • 41
  • 58
1

Check out the Repositories page on the Redmine Wiki and scroll down to the Mercurial repositories section to make sure that your setup correctly.

You can then check out the Apache Configuration for Mercurial Repositories on the Redmine Wiki to make sure you have the right setup to gain access control from within Redmine.

Apache configuration for Mercurial repositories

Create a file caled "hgweb.config" in the same folder as "hgwebdir.cgi". This foder will be the root repository folder. Then edit the "hgweb.config" with something like this:

[paths]
/=/path/to/root/repository/**

[web]
allow_push = *
allowbz2 = yes
allowgz = yes
allowzip = yes

Follows the instructions to install Redmine.pm as described and configure your apache like this.

RewriteEngine on
PerlLoadModule Apache2::Redmine
PerlLoadModule Authen::Simple::LDAP
ScriptAliasMatch ^/hg(.*)  /path/to/the/hgwebdir.cgi/$1
<Location /hg>
    AuthType Basic
    AuthName "Mercurial" 
    Require valid-user

    #Redmine auth
    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler
    RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
    RedmineDbUser "DB_USER" 
    RedmineDbPass "DB_PASSWD" 
</Location>
runlevelsix
  • 2,609
  • 21
  • 19