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_read', '*')
|
||||||
u.setconfig('web', 'allow_push', '*')
|
u.setconfig('web', 'allow_push', '*')
|
||||||
|
|
||||||
u.setconfig('hooks', 'changegroup.scm', 'python:scmhooks.callback')
|
u.setconfig('hooks', 'changegroup.scm', 'python:scmhooks.postHook')
|
||||||
u.setconfig('hooks', 'pretxnchangegroup.scm', 'python:scmhooks.callback')
|
u.setconfig('hooks', 'pretxnchangegroup.scm', 'python:scmhooks.preHook')
|
||||||
|
|
||||||
# pass SCM_HTTP_POST_ARGS to enable experimental httppostargs protocol of mercurial
|
# pass SCM_HTTP_POST_ARGS to enable experimental httppostargs protocol of mercurial
|
||||||
# SCM_HTTP_POST_ARGS is set by HgCGIServlet
|
# SCM_HTTP_POST_ARGS is set by HgCGIServlet
|
||||||
|
|||||||
@@ -85,9 +85,7 @@ def callHookUrl(ui, repo, hooktype, node):
|
|||||||
ui.traceback()
|
ui.traceback()
|
||||||
return abort
|
return abort
|
||||||
|
|
||||||
def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
def callback(ui, repo, hooktype, node=None):
|
||||||
if pending != None:
|
|
||||||
pending()
|
|
||||||
abort = True
|
abort = True
|
||||||
if node != None:
|
if node != None:
|
||||||
if len(baseUrl) > 0:
|
if len(baseUrl) > 0:
|
||||||
@@ -98,3 +96,32 @@ def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs)
|
|||||||
else:
|
else:
|
||||||
ui.warn("changeset node is not available")
|
ui.warn("changeset node is not available")
|
||||||
return abort
|
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