From 9e9db969c579d6da704aaccf6f74810cb3732f14 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 6 Oct 2011 17:51:25 +0200 Subject: [PATCH] improve mercurial hooks --- .../src/main/resources/sonia/scm/hghook.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hghook.py b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hghook.py index 20b24ab658..4daef36aa7 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hghook.py +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hghook.py @@ -42,10 +42,18 @@ baseUrl = "${url}" challenge = "${challenge}" def callback(ui, repo, hooktype, node=None, source=None, **kwargs): + failure = True if node != None: - url = baseUrl + os.path.basename(repo.root) + "/" + hooktype - data = urllib.urlencode({'node': node, 'challenge': challenge}) - conn = urllib.urlopen(url, data); - if conn.code >= 400: - print( "scm-hook failed with error code " + str(conn.code) ) - sys.exit(1) + try: + 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}) + conn = urllib.urlopen(url, data); + if conn.code >= 200 and conn.code < 300: + ui.debug( "scm-hook " + hooktype + " success with status code " + str(conn.code) + "\n" ) + 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