improve mercurial hooks

This commit is contained in:
Sebastian Sdorra
2011-10-06 17:51:25 +02:00
parent d486c21bea
commit 9e9db969c5

View File

@@ -42,10 +42,18 @@ baseUrl = "${url}"
challenge = "${challenge}" challenge = "${challenge}"
def callback(ui, repo, hooktype, node=None, source=None, **kwargs): def callback(ui, repo, hooktype, node=None, source=None, **kwargs):
failure = True
if node != None: if node != None:
try:
url = baseUrl + os.path.basename(repo.root) + "/" + hooktype url = baseUrl + os.path.basename(repo.root) + "/" + hooktype
ui.debug( "send scm-hook to " + url + " and " + node + "\n" )
data = urllib.urlencode({'node': node, 'challenge': challenge}) data = urllib.urlencode({'node': node, 'challenge': challenge})
conn = urllib.urlopen(url, data); conn = urllib.urlopen(url, data);
if conn.code >= 400: if conn.code >= 200 and conn.code < 300:
print( "scm-hook failed with error code " + str(conn.code) ) ui.debug( "scm-hook " + hooktype + " success with status code " + str(conn.code) + "\n" )
sys.exit(1) failure = False
else:
ui.warn( "scm-hook failed with error code " + str(conn.code) + "\n" )
except ValueError:
ui.warn( "scm-hook failed with an exception\n" )
return failure