diff tests/test_svn_pre_commit_hooks.py @ 987:cf53cfaaa050

Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
author Anton Agafonov <equeny@fb.com>
date Mon, 26 Nov 2012 11:38:34 -0800
parents
children d741f536f23a
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/tests/test_svn_pre_commit_hooks.py
@@ -0,0 +1,34 @@
+import os
+import sys
+import test_util
+import unittest
+
+from mercurial import hg
+from mercurial import commands
+from mercurial import util
+
+
+class TestSvnPreCommitHooks(test_util.TestBase):
+    def setUp(self):
+        super(TestSvnPreCommitHooks, self).setUp()
+        self.repo_path = self.load_and_fetch('single_rev.svndump')[1]
+        # creating pre-commit hook that doesn't allow any commit
+        hook_file_name = os.path.join(
+			self.repo_path, 'hooks', 'pre-commit'
+        )
+        hook_file = open(hook_file_name, 'w')
+        hook_file.write(
+        	'#!/bin/sh\n'
+        	'echo "Commits are not allowed" >&2; exit 1;\n'
+        )
+        hook_file.close()
+        os.chmod(hook_file_name, 0755)
+
+    def test_push_with_pre_commit_hooks(self):
+        changes = [('narf/a', 'narf/a', 'ohai',),
+                   ]
+        self.commitchanges(changes)
+        self.assertRaises(util.Abort, self.pushrevisions)
+
+def suite():
+    return unittest.findTestCases(sys.modules[__name__])