Edgewall Software

Changes between Version 44 and Version 45 of TracRepositoryAdmin


Ignore:
Timestamp:
Apr 16, 2017, 2:19:49 AM (5 years ago)
Author:
Ryan J Ollos
Comment:

Document easier option first, and describe how to use hook script environment configuration.

Legend:

Unmodified
Added
Removed
Modified
  • TracRepositoryAdmin

    v44 v45  
    125125==== Subversion
    126126
     127===== Using `trac-svn-hook`
     128
     129In a Unix environment, the simplest way to configure explicit synchronization is by using the [trac:source:trunk/contrib/trac-svn-hook contrib/trac-svn-hook] script. `trac-svn-hook` starts `trac-admin` asynchronously to avoid slowing the commit and log editing operations. The script also comes with a number of safety checks and usage advice which should make it easier to set up and test. Log messages are written to a log file with prefix `svn-hooks-` in the environment `log` directory, which can make configuration issues easier to debug.
     130
     131There's no equivalent `trac-svn-hook.bat` for Windows yet, but the script can be run by Cygwin's bash.
     132
     133To configure `trac-svn-hook`, follow the help in the documentation header of the script. Configuring the hook environment variables is made easier in Subversion 1.8 by using the [http://svnbook.red-bean.com/en/1.8/svn.reposadmin.create.html#svn.reposadmin.hooks.configuration hook script environment] configuration. Rather than directly editing `trac-svn-hook` to set the environment variables, they can be configured through the repository `conf/hooks-env` file. Replace the [trac:source:trunk/contrib/trac-svn-hook@:65-67#L61 configuration section] with:
     134{{{#!bash
     135export TRAC_ENV
     136export PATH=$PYTHON_BIN:$PATH
     137export LD_LIBRARY_PATH=$PYTHON_LIB:$LD_LIBRARY_PATH
     138}}}
     139and set the variables `TRAC_ENV`, `PYTHON_BIN` and `PYTHON_LIB` in the `hooks-env` file. Here is an example, using a Python virtual environment at `/usr/local/venv`:
     140{{{#!ini
     141[default]
     142TRAC_ENV=/var/trac/project-1
     143PYTHON_BIN=/usr/local/venv/bin
     144PYTHON_LIB=/usr/local/venv/lib
     145}}}
     146
     147===== Writing Your Own Hook Script
     148
    127149The following examples are complete post-commit and post-revprop-change scripts for Subversion. They should be edited for the specific environment, marked executable (where applicable) and placed in the `hooks` directory of each repository. On Unix (`post-commit`):
    128150{{{#!sh
     
    150172The Unix variants above assume that the user running the Subversion commit has write access to the Trac environment, which is the case in the standard configuration where both the repository and Trac are served by the web server. If you access the repository through another means, for example `svn+ssh://`, you may have to run `trac-admin` with different privileges, for example by using `sudo`.
    151173
    152 Note that calling `trac-admin` in your Subversion hooks can slow down the commit and log editing operations on the client side. You might want to use the [trac:source:trunk/contrib/trac-svn-hook contrib/trac-svn-hook] script which starts `trac-admin` in an asynchronous way. The script also comes with a number of safety checks and usage advices which should make it easier to set up and test your hooks. There's no equivalent `trac-svn-hook.bat` for Windows yet, but the script can be run by Cygwin's bash.
    153 
    154 See the [http://svnbook.red-bean.com/en/1.5/svn.reposadmin.create.html#svn.reposadmin.create.hooks section about hooks] in the Subversion book for more information. Other repository types will require different hook setups.
     174See the [http://svnbook.red-bean.com/en/1.7/svn.reposadmin.create.html#svn.reposadmin.create.hooks section about hooks] in the Subversion book for more information. Other repository types will require different hook setups.
    155175
    156176==== Git