fixed PreReceiveRepositoryHooks for newer versions of mercurial

This commit is contained in:
Sebastian Sdorra
2019-02-20 11:56:10 +01:00
parent deedb573a6
commit 13adf4b234
2 changed files with 32 additions and 5 deletions

View File

@@ -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)