Files
SCM-Manager/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hghook.py

31 lines
721 B
Python
Raw Normal View History

#!/usr/bin/env ${python}
2011-07-21 20:37:12 +02:00
#
# registration .hg/hgrc:
#
# [hooks]
2011-07-21 21:24:27 +02:00
# changegroup.scm = python:scmhooks.callback
2011-07-21 20:37:12 +02:00
#
import os, sys, urllib
pythonPath = "${path}"
if len(pythonPath) > 0:
pathParts = pythonPath.split(os.pathsep)
for i in range(len(pathParts)):
sys.path.insert(i, pathParts[i])
baseUrl = "${url}"
2011-07-22 13:08:12 +02:00
challenge = "${challenge}"
2011-07-21 20:37:12 +02:00
def callback(ui, repo, hooktype, node=None, source=None, **kwargs):
2011-07-21 21:24:27 +02:00
if node != None:
2011-07-22 13:08:12 +02:00
url = baseUrl + os.path.basename(repo.root) + "/" + hooktype
data = urllib.urlencode({'node': node, 'challenge': challenge})
conn = urllib.urlopen(url, data);
if conn.code == 200:
print( "scm-hook executed successfully" )
else:
print( "scm-hook failed" )