Edgewall Software

Changes between Initial Version and Version 1 of TracWebSVNIntegration


Ignore:
Timestamp:
Oct 28, 2004, 6:52:25 PM (20 years ago)
Author:
anonymous
Comment:

HOWTO: Trac and WebSVN Integration

Legend:

Unmodified
Added
Removed
Modified
  • TracWebSVNIntegration

    v1 v1  
     1= How to Integrate Trac and WebSVN - Under Construction =
     2
     3
     4----
     5
     6
     7'''This is a rather ad-hoc guide and I take no responsibility if it does not work in your config'''
     8'''I'm sure that there are many improvements that I can make'''
     9
     10----
     11
     12[http://projects.edgewall.com/trac/ Trac] Is an integrated bug tracking system using Python, and [http://websvn.tigris.org/ WebSVN] is a web front end for multiple projects under SVN running under PHP.
     13
     14Trac works well for single repositories holding single projects, it can also be used to manage multiple projects using some tricks.
     15
     16The downside of these tricks are that they are statically configured, if a new project or repository is created, then apache has to be configured to show the change.
     17
     18WebSVN is completly dynamic, it imediately lists a new repository (as far as Trac is concerned a project) when it is created.
     19
     20Trac does have a solution to this, modPythonHandler, but I've had no success in getting this working.
     21
     22My solution works under Apache 2.0 under Windows 2000, but I can see no reason why it should not work under Linux/Unix with Apache 2.0.
     23
     24== Step 1 ==
     25First get Trac and WebSVN working in isolation, the section in my apache.conf looks like this:-
     26{{{
     27### SVN Config
     28LoadModule dav_fs_module        modules/mod_dav_fs.so
     29LoadModule dav_module           modules/mod_dav.so
     30LoadModule dav_svn_module       modules/mod_dav_svn.so
     31
     32#A single repository root with multiple repositories within
     33<Location  /svn>
     34  DAV svn
     35  SVNParentPath /SVN_ROOT
     36#  AuthType Basic
     37#  AuthName "Subversion repository"
     38#  AuthUserFile /svn/svn-auth-file
     39#  Satisfy Any
     40#  Require valid-user
     41</Location>
     42
     43
     44## If the user access /svn_root then send them to WebSVN
     45## index.php is added to the DirectoryIndex above
     46alias /svn_root "c:\svn_root\WebSVN"
     47
     48## If the user tries to access /svn then send them to WebSVN
     49## See the <Directory> section for the server root
     50
     51## Allow access to the SVN Root
     52<Directory "c:\svn_root">
     53    AllowOverride None
     54    Order allow,deny
     55    Allow from all
     56</Directory>
     57
     58## Generic permissions on the shared trac system
     59<Directory "C:\Program Files\Python23\share\trac\htdocs">
     60  Options Indexes MultiViews
     61  AllowOverride None
     62  Order allow,deny
     63  Allow from all
     64</Directory>
     65
     66
     67#Trac basic configuration used for testing calle TestTrac1
     68# use http://localhost/TestTrac1/... to access trac, trac is pointed at one single project
     69ScriptAlias /TestTrac1 "c:\program files\python23\share\trac\cgi-bin\trac.cgi"
     70<Location /TestTrac1>
     71  SetEnv TRAC_ENV "c:\svn_root\test\trac.db"
     72</Location>
     73
     74<Location "/TestTrac1/login">
     75  AuthType Basic
     76  AuthName "Welcome To Test Trac 1"
     77  AuthUserFile c:\svn_root\tracpassword
     78  Require valid-user
     79</Location>
     80}}}
     81
     82My WebSVN wsvn.php is modified thus:
     83{{{
     84// Note that wsvn.php need not be in the /websvn directory (and normally isn't).
     85$locwebsvnhttp = "/svn_root/WebSVN";
     86
     87// Physical location of websvn directory
     88$locwebsvnreal = "C:/svn_root/WebSVN";
     89}}}
     90
     91My WebSVN config.inc is modified thus:
     92{{{
     93$config->parentPath("c:\\SVN_ROOT");
     94}}}
     95
     96My setup has the following locations for Trac, Python, Apache, WebSVN and the SVN repository.
     97{{{
     98Trac:      C:\Program Files\Python23\share\trac                [common files]
     99Trac:      C:\Program Files\Python23\Scripts                   [install and CGI scripts]
     100Trac:      C:\Program Files\Python23\Lib\site-packages\trac    [Program] 
     101Python:    C:\Program Files\Python23
     102Apache:    C:\Program Files\Apache Group\Apache2.0
     103WebSVN:    C:\svn_root\WebSVN
     104Repository:c:\svn_root\RepProject1
     105Repository:c:\svn_root\RepProject2
     106Repository:c:\svn_root\Rep.....
     107}}}
     108
     109== Step 2 ==
     110Apply these changes to WebSVN index.php
     111{{{
     112//remove the ++ from
     113$listing[$i++]["projlink"] = "<a href=\"${url}sc=0\">".$project->name."</a>";
     114
     115//Then add these three lines
     116$listing[$i]["projlink"]=$listing[$i]["projlink"]."        ";
     117$listing[$i]["projlink"]=$listing[$i]["projlink"]."<a href=\\Wiki\\".$project->name."> Wiki</a>";
     118$i++;
     119}}}
     120
     121above there should be about 6 <ampersand>nbsp  in between the quotes, but Trac decides to remove them !!
     122
     123== Step 3 ==
     124Apply these settings to Apache '''(Needs a lot of cleaning up)'''
     125{{{
     126#### Integrate WebSVN With Trac
     127###  Rewrite access to projects in the wiki to the correct project handler
     128#Turn on Rewrite if its not already on here
     129RewriteEngine On
     130
     131# Rewrite access to http://localhost/Wiki/Project to http://localhost/Wiki/Project/trac.cgi setting TRAC_ENV & PATH_INFO, skipping next
     132RewriteRule /Wiki/([[:alnum:]]+)$       "/Wiki/$1/trac.cgi"   [PT,S,E=Trac_Env:c:\\svn_root\\$1\\trac.db,E=PATH_INFO:$2]
     133
     134
     135# For some reason, the virtual path, PATH_INFO is not set automatically by the CGI handler below, so it tries to find the file in the path info location
     136# L=don't execute any more rules, PT=pass through, don't actually forward, S=skip the next rule (should not be required)
     137# WebSVN is modified to access the repository using an automatically generated pane listing projects, this is modified with the Trac path and detected here
     138# Rewrite access to http://localhost/Wiki/Project/... to http://localhost/Wiki/Project/trac.cgi..., setting TRAC_ENV and PATH_INFO
     139RewriteRule /Wiki/([[:alnum:]]+)(/?.*)  "/Wiki/$1$2"   [PT,E=Trac_Env:c:\\svn_root\\$1\\trac.db,E=PATH_INFO:$2]
     140
     141## Tell apache that any access to the ...trac.cgi... should be treated as a script, regardless of path
     142ScriptAliasMatch /Wiki/(.+)/trac.cgi(/?.*) "c:\program files\python23\share\trac\cgi-bin\trac.cgi$2"
     143
     144###This line uses a script to debug the enviroment sent to Trac
     145#RewriteRule /Wiki/([[:alnum:]]+)(/?.*) "/cgi-bin/pythonenv.cgi"   [PT,E=Trac_Env:c:\\svn_root\\$1\\trac.db,E=TRAC_DEBUG_ENV1:$1,E=TRAC_DEBUG_ENV2:$2]
     146#NOTES:
     147#Failure to use PT here results in a file name mapping that does not exist.
     148#Using R results in no env passed
     149#using P results in no valid URL (needs an HTTP prefix??)
     150
     151
     152#Any access to the login virtual path even under a project path results in a login box
     153<LocationMatch "^.*Wiki.*trac.cgi/login">
     154  AuthType Basic
     155  AuthName "Welcome To CITEL Trac"
     156  AuthUserFile c:\svn_root\tracpassword
     157  Require valid-user
     158</LocationMatch>
     159
     160}}}
     161
     162These changes to apache will 'standardise' the URLs used to access the various systems '(Needs work)'
     163{{{
     164<Directory <where your htdocs live>
     165#
     166#Enable the re-write engine
     167#For some reason, re-write rules only work in this <directory> section
     168#
     169RewriteEngine On
     170
     171##  Re-write svn or svn/ to /svn_root
     172RewriteRule ^svn/?$ /svn_root  [R]
     173
     174##Rewrite access to /Wiki or /Wiki/ to /svn_root as no project is specified
     175RewriteRule ^Wiki/?$ /svn
     176RewriteRule ^wiki/?$ /svn
     177</Directory>
     178}}}
     179
     180== Step 4 ==
     181
     182Tortoise (or whatever) will use
     183http://server/svn/ProjectRepository/SubProject
     184
     185To access a Project Repository list use
     186http://server/svn
     187or
     188http://server/Wiki
     189
     190To directly access a Project Trac use
     191http://server/Wiki/ProjectRepository
     192
     193
     194
     195
     196== BUGS & LIMITATIONS ==
     197I've not understood if the following are due to Trac or my setup and changes:-
     198
     199 *  After logging in, a refresh is needed to show the correct user
     200 *  Log-ins are sticky, so if I'm managing one project and forget to log out, I'll be using the same user for the next project.  This would cause problems if multiple people have access to the same machines.
     201 *  Probably due more to a lack of forethought I've got my WebSVN installation in the same place as my repositories, so its listed as a repository, WebSVN should check that a folder is a repository anyway, but ideally it needs moving.  Initial attempts at this resulted in a mess.
     202
     203
     204