@@ -1,5 +1,5 @@
1#!/usr/bin/python
1#!/usr/bin/python
2−# Copyright 2013 Canonical Ltd.
2+# Copyright 2013, 2014 Canonical Ltd.
4# This program is free software; you can redistribute it and/or modify
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License as published by
5# it under the terms of the GNU Lesser General Public License as published by
@@ -13,11 +13,15 @@
13# You should have received a copy of the GNU Lesser General Public License
13# You should have received a copy of the GNU Lesser General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
16−import os, subprocess
16+import os
17−from bzrlib import branch, errors
18+from bzrlib import branch
18−from bzrlib.urlutils import dirname, local_path_from_url
19+from bzrlib.urlutils import local_path_from_url
22+def execute_makecheck(
23+ local_branch, master_branch, old_revision_number, old_revision_id,
20−def execute_makecheck(local_branch, master_branch, old_revision_number, old_revision_id, future_revision_number, future_revision_id, tree_delta, future_tree):
24+ future_revision_number, future_revision_id, tree_delta, future_tree):
21 if not master_branch.basis_tree().has_filename("qml/Shell.qml"):
25 if not master_branch.basis_tree().has_filename("qml/Shell.qml"):
@@ -27,7 +31,9 @@ def execute_makecheck(local_branch, master_branch, old_revision_number, old_revi
27 os.environ['CTEST_OUTPUT_ON_FAILURE'] = "1"
31 os.environ['CTEST_OUTPUT_ON_FAILURE'] = "1"
28 if (subprocess.call("make -C builddir test", shell=True) != 0):
32 if (subprocess.call("make -C builddir test", shell=True) != 0):
34+ print("\n\n*** Warning ***\n\n"
30− print("\n\n*** Warning ***\n\nBasic tests failed. This commit will not pass continuous integration.")
35+ "Basic tests failed. This commit will not pass continuous "
32 branch = local_branch or master_branch
38 branch = local_branch or master_branch
33 revision = branch.repository.get_revision(future_revision_id)
39 revision = branch.repository.get_revision(future_revision_id)
@@ -36,8 +42,10 @@ def execute_makecheck(local_branch, master_branch, old_revision_number, old_revi
36 msg_file.close()
42 msg_file.close()
38 print("\n\nSaved commit message to $SRC_DIR/message.txt.")
44 print("\n\nSaved commit message to $SRC_DIR/message.txt.")
39− print("You can uncommit this revision, fix the tests and reuse your message running:\n\nbzr commit -F message.txt\n\n")
45+ print("You can uncommit this revision, fix the tests and reuse your "
46+ "message running:\n\nbzr commit -F message.txt\n\n")
40 elif os.path.isfile("message.txt"):
47 elif os.path.isfile("message.txt"):
41 os.remove("message.txt")
48 os.remove("message.txt")
50+branch.Branch.hooks.install_named_hook(
43−branch.Branch.hooks.install_named_hook('pre_commit', execute_makecheck, 'make check pre-commit')
51+ 'pre_commit', execute_makecheck, 'make check pre-commit')