Opened 13 years ago

Last modified 13 years ago

#8617 closed defect

SVN post-commit hook fails — at Version 9

Reported by: fredrik@… Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description (last modified by Ryan J Ollos)

I tried to use the SVN post-commit hook, but was unable to make it work. When I enabled logging (commithook.log) I got the following error:

ERROR while processing: Unable to get database connection within 0 seconds. (TracError(<babel.support.LazyProxy object at 0x898175c>,))

Change History (9)

comment:1 Changed 13 years ago by Russ Tyndall

  • The error implies that you are having trouble connecting to the database.
  • Was there anything else in the log?
  • What does your svn post commit look like?
  • Can you (in a python shell) open the trac environment you are passing in the -p flag?

comment:2 Changed 13 years ago by Russ Tyndall

Meant to include this snippet above

import trac.env
e = trac.env.Environment('/path/to/your/trac') 

comment:3 Changed 13 years ago by fredrik@…

Replying to bobbysmith007:

  • The error implies that you are having trouble connecting to the database.
  • Was there anything else in the log?
  • What does your svn post commit look like?
  • Can you (in a python shell) open the trac environment you are passing in the -p flag?

1) The database works, I think?

2) No, nothing more in the log

3) I used the post-commit from TimingAndEstimationSVNPostCommitHook

3a) Using the simplified post-commit-script resulted in this in the logs:

[14:01:09] 2011-03-18 in svn post commit : <path/to/repo> : 1634 
[14:01:09] TracEnv:</path/to/trac/env> Repo:<path/to/repo> Rev:1634 Auth:fredrik

But nothing shows up in Trac.

4) Could execute the two commands in comment:2 without errors

comment:4 in reply to:  3 ; Changed 13 years ago by Russ Tyndall

  • I assume you adjusted all the paths appropriately?
  • Did the trac post commit log have anything interesting in its log (like more instances of

ERROR while processing: Unable to get database connection within 0 seconds. (TracError?(<babel.support.LazyProxy? object at 0x898175c>,)) )

  • Can you execute /usr/bin/python /var/trac/trac-post-commit.py -p "$TRAC_ENV" -r "$REV" -u "$AUTHOR" -m "$MESSAGE" 2>&1 (filling in the appropriate variables?) Does it work at all?
  • Are you sure that the user these end up running as all have appropriate permissions?
    • The place where that error would be the only one in the log, is on opening the environment. If the user executing the script didnt have permission tot eh filesystem in that location or something, I could imagine it manifesting in this way.

Just shooting in the dark at various troubles I have had in the past and how I debugged them.

comment:5 in reply to:  4 Changed 13 years ago by anonymous

  • Yes
  • Now I get the error ERROR while processing: 'NoneType' object has no attribute 'sync'
  • When I executed the script (tried as myself, root and wwwrun), I got no errors on screen, but exit status was 1.

comment:6 Changed 13 years ago by Russ Tyndall

The new error is different, but seems somewhat related (environment is failing to load correctly). Previously it seemed like connecting to the database was broken, but now it is connecting to the source control repo.

self.env = open_environment(project)
repos = self.env.get_repository()
repos.sync()
  • Do you correctly have the repository you are trying to post from, setup in trac? (You can see it in the browser)
    • Is it the "default" repository?
    • Do you have more than one repo?

This version of the script has only been tested against a single "default" repository. If you only have a single trac with a single repo, this post-commit should be fine.

The post commit I use is more complex, but does handle multiple repositories. I have not included it because it contains code specific to my environment that is somewhat difficult to disentangle (about building links to gitweb for non trac git repositories and handling differences between git and svn repositories across our various trac instances). I can post that if you think that might meet your needs better, but it will definitely be a more complex setup and will require digging through the code to get it behaving exactly as you desire.

comment:7 Changed 13 years ago by fredrik@…

I do know it is not the "default" repository, but it is the only one present.

comment:8 Changed 13 years ago by Russ Tyndall

Not sure about the "default", as it seems unnecessary to specify that if there is only one. This is a working repository configuration for me.

[trac]
repository_dir = /var/svn/test-svn
repository_type = svn

With it I can execute the following in python shell and get a repository object back.

import trac.env
e = trac.env.Environment('/var/trac/test-svn/')
e.get_repository()

This is what the post commit is complaining about. Can you execute it and get a repository object?

Sorry this has been such a pain to get working. I am sure we will get it eventually though,

Russ

comment:9 Changed 13 years ago by Ryan J Ollos

Description: modified (diff)
Note: See TracTickets for help on using tickets.