Browse files

Fighting markdown a little bit.

  • Loading branch information...
1 parent 24b490c commit becb0af1dba5d32bfd5b5bda75201437ff9afa3f @maraujop committed Aug 12, 2011
Showing with 56 additions and 24 deletions.
  1. +56 −24 README.md
View
80 README.md
@@ -1,7 +1,5 @@
# Trac Mercurial Changeset Plugin
-## About this software
-
Trac plugin that inserts Mercurial repository information into Trac's database, thus integrating Mercurial and Trac to a fuller extend than the default Trac support. It enables ticket search, ticket changelogs, etc. 100% compatible with TracMercurial plugin. It actually solves TracMercurial <a href="http://trac.edgewall.org/ticket/8417">issue #8417</a>. TracMercurial is using this code to solve the issue, till they integrate it, you can use this.
## Prerequisites
@@ -17,82 +15,114 @@ You can install this software as a normal Trac plugin.
2. Change directory to Trac's plugin's directory containing ``setup.py``.
3. Clone this repository:
- git clone git://github.com/maraujop/TracMercurialChangesetPlugin.git
+<code>
+git clone git://github.com/maraujop/TracMercurialChangesetPlugin.git
+</code>
4. Install it:
- python setup.py install
+<code>
+python setup.py install
+</code>
5. If you want to install this plugin to your trac instance only, create the egg from the repo running:
- python setup.py bdist_egg
+<code>
+python setup.py bdist_egg
+</code>
Then, copy the generated egg file to the trac instance's plugin directory:
- cp dist/*.egg /srv/trac/env/plugins
+<code>
+cp dist/*.egg /srv/trac/env/plugins
+</code>
## Setup
1. Enable plugin in config trac.ini:
- [components]
- mercurialchangeset.* = enabled
+<code>
+[components]
+mercurialchangeset.* = enabled
+</code>
2. Then sync your repository into Trac by running:
- trac-admin /srv/trac/env/ mercurial sync repository_name
+</code>
+trac-admin /srv/trac/env/ mercurial sync repository_name
+</code>
``repository_name`` can be default or a repository defined in Trac's repository table
3. Now you can keep your repository permanently synchronized in Trac by configuring a post-commit hook. If you are not familiar with Mercurial hooks, you can read <a href="http://www.selenic.com/mercurial/hgrc.5.html#hooks">official docs</a> about them.
In the server running Trac and the Mercurial repository, you should add the following to the hooks section of your global or personal hgrc:
- [hooks]
- changegroup.TracMercurialChangeset = /path/to/hook_script.sh
+<code>
+[hooks]
+changegroup.TracMercurialChangeset = /path/to/hook_script.sh
+</code>
Your hook_script.sh should at least have something like this (example uses ``default`` repository):
- trac-admin /srv/trac/env/ mercurial afterRevision $HG_NODE `pwd`
+<code>
+trac-admin /srv/trac/env/ mercurial afterRevision $HG_NODE `pwd`
+</code>
If you rather have a commit hook, you can set it like this:
- [hooks]
- commit.TracMercurialChangeset = /path/to/hook_script.sh
+<code>
+[hooks]
+commit.TracMercurialChangeset = /path/to/hook_script.sh
+</code>
Your ``hook_script.sh`` should then look like this:
- trac-admin /srv/trac/env/ mercurial revision $HG_NODE `pwd`
+<code>
+trac-admin /srv/trac/env/ mercurial revision $HG_NODE `pwd`
+</code>
This will keep synced with Trac every Mercurial's repository that you have configured within Trac. Thanks to the way the path is checked, if the repository is NOT controlled by Trac, it will let you commit or push withouth failing. This way you can keep all your Trac's repositories synced with only one hook_script.
## How-To use it
-This plugin adds five trac-admin commands that will let you synchronize your Mercurial repository with Trac. These are: ``lastRevision``, ``sync``, ``afterRevision`` and ``revision``.
+This plugin adds five trac-admin commands that will let you synchronize your Mercurial repository with Trac. These are: ``lastRevision``, ``sync``, ``afterRevision``, ``revision`` and ``syncAll``
You can access the help for each command by doing:
- trac-admin /srv/trac/env/ help mercurial <command> (e.g. lastRevision)
+<code>
+trac-admin /srv/trac/env/ help mercurial <command> (e.g. lastRevision)
+</code>
* **lastRevision**: Synchronize the last changeset in Mercurial repository into Trac's DB revision table.
- trac-admin /srv/trac/env/ mercurial lastRevision <repository>
+<code>
+trac-admin /srv/trac/env/ mercurial lastRevision <repository>
+</code>
* **sync**: Synchronize the whole Mercurial repository changelog into Trac's DB revision table.
- trac-admin /srv/trac/env/ mercurial sync <repository>
+<code>
+trac-admin /srv/trac/env/ mercurial sync <repository>
+</code>
* **afterRevision**: Synchronize all changesets in Mercurial repository greater than the given revision into Trac's DB revision table.
- trac-admin /srv/trac/env/ mercurial afterRevision <revision> <repository>
+<code>
+trac-admin /srv/trac/env/ mercurial afterRevision <revision> <repository>
+</code>
* **revision**: Synchronize the given revision from Mercurial's repository into Trac's DB revision table.
- trac-admin /srv/trac/env/ mercurial revision <revision> <repository>
+<code>
+trac-admin /srv/trac/env/ mercurial revision <revision> <repository>
+</code>
* **syncAll**: Synchronize all hg repositories under Trac's control into Trac's DB revision table.
- trac-admin /srv/trac/env/ mercurial syncAll
+<code>
+trac-admin /srv/trac/env/ mercurial syncAll
+</code>
* ``<revision>`` can be a revision number or a revision hash
* ``<repository>`` can be a repository name within Trac or the path to the root of the repository controlled by Trac
@@ -101,8 +131,10 @@ You can access the help for each command by doing:
## Troubleshooting
1. If the hook is giving you an ``Error: Command not found`` that's because you don't have the right privileges. The user or role that executes the script should have read and write privileges in you Trac ENV. If this is not the case, you can fix it running trac-admin inside the hook script as sudo:
-
- echo "yourpassword" | sudo -S trac-admin /srv/trac/env/ mercurial afterRevision $HG_NODE default
+
+<code>
+echo "yourpassword" | sudo -S trac-admin /srv/trac/env/ mercurial afterRevision $HG_NODE default
+</code>
Of course this is neither an elegant fix, nor a very secure, but it certainly is a very easy one :)

0 comments on commit becb0af

Please sign in to comment.