##// END OF EJS Templates
for the sake let's wrap the template joins with unicode mapping
for the sake let's wrap the template joins with unicode mapping

File last commit:

r2105:926f55b0 beta
r2108:9e377342 beta
Show More
hooks.py
174 lines | 4.6 KiB | text/x-python | PythonLexer
filled in some docs for hooks
r913 # -*- coding: utf-8 -*-
"""
rhodecode.lib.hooks
~~~~~~~~~~~~~~~~~~~
Hooks runned by rhodecode
source code cleanup: remove trailing white space, normalize file endings
r1203
filled in some docs for hooks
r913 :created_on: Aug 6, 2010
:author: marcink
2012 copyrights
r1824 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
filled in some docs for hooks
r913 :license: GPLv3, see COPYING for more details.
"""
fixed license issue #149
r1206 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # You should have received a copy of the GNU General Public License
fixed license issue #149
r1206 # along with this program. If not, see <http://www.gnu.org/licenses/>.
filled in some docs for hooks
r913 import os
import sys
renamed project to rhodecode
r547
fixed hooks for mercurial 1.9
r1415 from mercurial.scmutil import revrange
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 from mercurial.node import nullrev
added initial rc-extension module...
r2105 from rhodecode import EXTENSIONS
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 from rhodecode.lib import helpers as h
from rhodecode.lib.utils import action_logger
added initial rc-extension module...
r2105 from inspect import isfunction
renamed project to rhodecode
r547
pep8ify
r1307
renamed project to rhodecode
r547 def repo_size(ui, repo, hooktype=None, **kwargs):
#235 forking page repo group selection...
r1722 """
Presents size of repository after push
source code cleanup: remove trailing white space, normalize file endings
r1203
filled in some docs for hooks
r913 :param ui:
:param repo:
:param hooktype:
"""
renamed project to rhodecode
r547
size_hg, size_root = 0, 0
for path, dirs, files in os.walk(repo.root):
if path.find('.hg') != -1:
for f in files:
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675 try:
size_hg += os.path.getsize(os.path.join(path, f))
except OSError:
pass
renamed project to rhodecode
r547 else:
for f in files:
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675 try:
size_root += os.path.getsize(os.path.join(path, f))
except OSError:
pass
renamed project to rhodecode
r547 size_hg_f = h.format_byte_size(size_hg)
size_root_f = h.format_byte_size(size_root)
size_total_f = h.format_byte_size(size_root + size_hg)
small change for post update hook that displays repository size
r1814
last_cs = repo[len(repo) - 1]
msg = ('Repository size .hg:%s repo:%s total:%s\n'
'Last revision is now r%s:%s\n') % (
size_hg_f, size_root_f, size_total_f, last_cs.rev(), last_cs.hex()[:12]
)
sys.stdout.write(msg)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
pep8ify
r1307
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 def log_pull_action(ui, repo, **kwargs):
#235 forking page repo group selection...
r1722 """
Logs user last pull action
source code cleanup: remove trailing white space, normalize file endings
r1203
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 :param ui:
:param repo:
"""
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 extras = dict(repo.ui.configitems('rhodecode_extras'))
username = extras['username']
repository = extras['repository']
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 action = 'pull'
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 action_logger(username, action, repository, extras['ip'], commit=True)
# extension hook call
callback = getattr(EXTENSIONS, 'PULL_HOOK', None)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 if isfunction(callback):
kw = {}
kw.update(extras)
callback(**kw)
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 return 0
renamed project to rhodecode
r547
pep8ify
r1307
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 def log_push_action(ui, repo, **kwargs):
#235 forking page repo group selection...
r1722 """
Maps user last push action to new changeset id, from mercurial
source code cleanup: remove trailing white space, normalize file endings
r1203
fixed @repo into :repo for docs...
r604 :param ui:
:param repo:
renamed project to rhodecode
r547 """
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 extras = dict(repo.ui.configitems('rhodecode_extras'))
username = extras['username']
repository = extras['repository']
action = extras['action'] + ':%s'
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 node = kwargs['node']
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 def get_revs(repo, rev_opt):
if rev_opt:
revs = revrange(repo, rev_opt)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 if len(revs) == 0:
return (nullrev, nullrev)
return (max(revs), min(revs))
else:
return (len(repo) - 1, 0)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 stop, start = get_revs(repo, [node + ':'])
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 revs = (str(repo[r]) for r in xrange(start, stop + 1))
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 action = action % ','.join(revs)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 action_logger(username, action, repository, extras['ip'], commit=True)
bugfix, repo_size crashed when broken symlinks where inside a repository.
r675
added initial rc-extension module...
r2105 # extension hook call
callback = getattr(EXTENSIONS, 'PUSH_HOOK', None)
if isfunction(callback):
kw = {'pushed_revs': revs}
kw.update(extras)
callback(**kw)
#48 rewrite action loggers into hooks with all changesets that are inside a push
r654 return 0
#348 added post-create repository hook
r1972
def log_create_repository(repository_dict, created_by, **kwargs):
"""
Post create repository Hook. This is a dummy function for admins to re-use
added initial rc-extension module...
r2105 if needed. It's taken from rhodecode-extensions module and executed
if present
#348 added post-create repository hook
r1972
#227 Initial version of repository groups permissions system...
r1982 :param repository: dict dump of repository object
#348 added post-create repository hook
r1972 :param created_by: username who created repository
:param created_date: date of creation
available keys of repository_dict:
'repo_type',
'description',
'private',
'created_on',
'enable_downloads',
'repo_id',
'user_id',
'enable_statistics',
'clone_uri',
'fork_id',
'group_id',
'repo_name'
"""
added initial rc-extension module...
r2105 callback = getattr(EXTENSIONS, 'CREATE_REPO_HOOK', None)
if isfunction(callback):
kw = {}
kw.update(repository_dict)
kw.update({'created_by': created_by})
kw.update(kwargs)
return callback(**kw)
#348 added post-create repository hook
r1972
#227 Initial version of repository groups permissions system...
r1982 return 0