For me there are three packages which make up "Subversion":
This is about integrating Subversion with Trac to maximise traceability.
If you have read my previous posts you will know that our repository is quite large and contains code for a large number of products which are made up by pulling in various bits of code, many of which are shared.
We are in the industrial control business and a typical industrial controller will be made up of hardware specific code, code for that particular line of devices and function blocks. Each of these is in a separate part of the repository and has its own Trac instance. This means that fixing a problem in a device may mean fixing problems in function blocks (which are switched into the working copy) and thus updating a function blocks Trac ticket instead of or as well as a ticket for the product code.
The problem I faced was that the post-commit hook which has been contributed to the Trac project assumes a single Trac instance per repository.
Due to excellent forward planning (more often known as good fortune) the names of our Trac instances match (in the Windows case insensitive meaning of match) the names of the top level directories of the repository. Also, we are insisting on people using InterTrac link syntax for their ticket numbers in commit messages. Therefore I can work out which Trac instance the ticket is in. Our hierarchy looks a bit like this:
There a lots more and they all have the trunk, tags and branches directories in them.
Our Trac InterTrac link names for the above would be product, boardsupport and functionblocks.
I also need to find all of the Trac changesets although they are a single commit they may cross several Trac instances. By using svnadmin dirs-changed in the post-commit hook I can extract all of the top level directory names and use them to find all of the Trac instances which refer to the changset.
This makes the system very easy for the user. In their commit message they add references to all of the tickets that commit affects. The post-commit script finds all of those ticket references, then it works out which of the Trac instances will contain changset information and adds a link to that changeset to each ticket. This maintains a complete cross reference between tickets and Subversion commits.
The post-commit script is attached. Drupal decided to make it a .txt file, so save and rename it. If you use it you will need to change the values in the _instance_names variable.
| Attachment | Size |
|---|---|
| post-commit.txt | 751 bytes |
| post-commit-hook-py.txt | 6.16 KB |
I cannot download the script
I don't see the attachments (as logged user) or I can't download the first one because authorization fails.
Could you help me, please? Thank you
That was weird.
I couldn't get it to work so I have re-uploaded the file with another name and now it is ok.
Problems with the scripts....
Hi,
Firstly thank you very much for making these scripts available, was just what I was looking for!! Although I'm having a few problems trying to run your scripts and I wonder if you would be so kind as to help me (not sure if it's my ignorance of python, trac or svn here!) is there anyway of piping the output from the python file into a log file or such to be able to debug my errors?
I copied and pasted your scripts, changing the instance names and the paths as appropriate, however I'm running into problems.
Using the following command in linux:
$ python trac_post_commit_hook.py -p '/trac/' -r 22 -u "gemma" -m "uavipt:#1"
I get the following error:
Traceback (most recent call last):
File "trac_post_commit_hook.py", line 153, in
CommitHook()
File "trac_post_commit_hook.py", line 100, in __init__
for s in options.dirlist.splitlines():
AttributeError: 'NoneType' object has no attribute 'splitlines'
Any help would be most appreciated!!!!
Gem
You need a -d option
You have to give the script a -d option which is a list of all directories which have changes made in them. See the post-commit.txt file, it calls the script like this:
Attachments?
Would also love to see your post-commit script, but I don't see the aforementioned attachments box either.
Which browser?
Which browser are you using?
There is a table under the article and above these comments with 'Attachment' at the top of the left column and two rows which link to the files.
Fixed!
Please accept my apologies, anonymous users (and most logged in users) didn't have permission to view uploaded files.
Post Commit Script
I think you forgot to attach the post commit script file.
I have posted one now
I had to post it as a .txt file, it is an example which you will need to adapt to your requirements.
.txt file
Hi Martin,
I wasn't able to find the .txt file that you referred to within this post. Can you please tell me where you've posted it.
Thanks!
post-commit.txt
There is a box at the end of the article marked 'attachments' which has post-commit.txt in it.