mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
fixed PreReceiveRepositoryHooks for newer versions of mercurial
This commit is contained in:
@@ -46,8 +46,8 @@ u.setconfig('web', 'push_ssl', 'false')
|
||||
u.setconfig('web', 'allow_read', '*')
|
||||
u.setconfig('web', 'allow_push', '*')
|
||||
|
||||
u.setconfig('hooks', 'changegroup.scm', 'python:scmhooks.callback')
|
||||
u.setconfig('hooks', 'pretxnchangegroup.scm', 'python:scmhooks.callback')
|
||||
u.setconfig('hooks', 'changegroup.scm', 'python:scmhooks.postHook')
|
||||
u.setconfig('hooks', 'pretxnchangegroup.scm', 'python:scmhooks.preHook')
|
||||
|
||||
# pass SCM_HTTP_POST_ARGS to enable experimental httppostargs protocol of mercurial
|
||||
# SCM_HTTP_POST_ARGS is set by HgCGIServlet
|
||||
|
||||
@@ -85,9 +85,7 @@ def callHookUrl(ui, repo, hooktype, node):
|
||||
ui.traceback()
|
||||
return abort
|
||||
|
||||
def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
||||
if pending != None:
|
||||
pending()
|
||||
def callback(ui, repo, hooktype, node=None):
|
||||
abort = True
|
||||
if node != None:
|
||||
if len(baseUrl) > 0:
|
||||
@@ -98,3 +96,32 @@ def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs)
|
||||
else:
|
||||
ui.warn("changeset node is not available")
|
||||
return abort
|
||||
|
||||
def preHook(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
||||
log_file = open("/tmp/hg_callback.log", "a")
|
||||
log_file.write("in callHookUrl\n")
|
||||
log_file.close()
|
||||
|
||||
# older mercurial versions
|
||||
if pending != None:
|
||||
pending()
|
||||
|
||||
# newer mercurial version
|
||||
# we have to make in-memory changes visible to external process
|
||||
# this does not happen automatically, because mercurial treat our hooks as internal hooks
|
||||
# see hook.py at mercurial sources _exthook
|
||||
try:
|
||||
if repo is not None:
|
||||
tr = repo.currenttransaction()
|
||||
repo.dirstate.write(tr)
|
||||
if tr and not tr.writepending():
|
||||
ui.warn("no pending write transaction found")
|
||||
except AttributeError:
|
||||
ui.debug("mercurial does not support currenttransation")
|
||||
# do nothing
|
||||
|
||||
return callback(ui, repo, hooktype, node)
|
||||
|
||||
def postHook(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
||||
return callback(ui, repo, hooktype, node)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user