# HG changeset patch # User Marcin Kuzminski # Date 1339014207 -7200 # Node ID 8a68e02922326d2ff7975e3b900829eeddb11931 # Parent 7be31af5bc783b80e293a346b582baece281c239 Change git & hg hooks to post. They shouldn't block as they are used just for logging actions. Futhermore post hooks have access to changesets, so it's much better flexible diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/lib/hooks.py --- a/rhodecode/lib/hooks.py Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/lib/hooks.py Wed Jun 06 22:23:27 2012 +0200 @@ -138,7 +138,7 @@ stop, start = get_revs(repo, [node + ':']) h = binascii.hexlify - revs = (h(repo[r].node()) for r in xrange(start, stop + 1)) + revs = [h(repo[r].node()) for r in xrange(start, stop + 1)] elif scm == 'git': revs = kwargs.get('_git_revs', []) if '_git_revs' in kwargs: @@ -198,7 +198,7 @@ def handle_git_post_receive(repo_path, revs, env): """ - A really hacky method that is runned by git pre-receive hook and logs + A really hacky method that is runned by git post-receive hook and logs an push action together with pushed revisions. It's runned by subprocess thus needs all info to be able to create a temp pylons enviroment, connect to database and run the logging code. Hacky as sh**t but works. ps. diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Wed Jun 06 22:23:27 2012 +0200 @@ -271,7 +271,7 @@ def _handle_githooks(self, repo_name, action, baseui, environ): """ - Handles pull action, push is handled by pre-receive hook + Handles pull action, push is handled by post-receive hook """ from rhodecode.lib.hooks import log_pull_action service = environ['QUERY_STRING'].split('=') diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/model/db.py --- a/rhodecode/model/db.py Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/model/db.py Wed Jun 06 22:23:27 2012 +0200 @@ -238,7 +238,7 @@ HOOK_UPDATE = 'changegroup.update' HOOK_REPO_SIZE = 'changegroup.repo_size' - HOOK_PUSH = 'pretxnchangegroup.push_logger' + HOOK_PUSH = 'changegroup.push_logger' HOOK_PULL = 'preoutgoing.pull_logger' ui_id = Column("ui_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/model/forms.py --- a/rhodecode/model/forms.py Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/model/forms.py Wed Jun 06 22:23:27 2012 +0200 @@ -731,7 +731,7 @@ paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True)) hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False) hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False) - hooks_pretxnchangegroup_push_logger = OneOf(['True', 'False'], if_missing=False) + hooks_changegroup_push_logger = OneOf(['True', 'False'], if_missing=False) hooks_preoutgoing_pull_logger = OneOf(['True', 'False'], if_missing=False) return _ApplicationUiSettingsForm diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/model/repo.py --- a/rhodecode/model/repo.py Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/model/repo.py Wed Jun 06 22:23:27 2012 +0200 @@ -476,7 +476,7 @@ tmpl = pkg_resources.resource_string( 'rhodecode', jn('config', 'pre_receive_tmpl.py') ) - _hook_file = jn(loc, 'pre-receive') + _hook_file = jn(loc, 'post-receive') with open(_hook_file, 'wb') as f: f.write(tmpl) os.chmod(_hook_file, 0555) diff -r 7be31af5bc78 -r 8a68e0292232 rhodecode/templates/admin/settings/settings.html --- a/rhodecode/templates/admin/settings/settings.html Wed Jun 06 21:48:53 2012 +0200 +++ b/rhodecode/templates/admin/settings/settings.html Wed Jun 06 22:23:27 2012 +0200 @@ -148,8 +148,8 @@
- ${h.checkbox('hooks_pretxnchangegroup_push_logger','True')} - + ${h.checkbox('hooks_changegroup_push_logger','True')} +
${h.checkbox('hooks_preoutgoing_pull_logger','True')}