Commits

Anton Agafonov  committed cf53cfa

Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push

  • Participants
  • Parent commits 1bdd075

Comments (0)

Files changed (5)

File hgsubversion/pushmod.py

             raise hgutil.Abort('Outgoing changesets parent is not at '
                                'subversion HEAD\n'
                                '(pull again and rebase on a newer revision)')
+        elif len(e.args) > 0 and e.args[1] == svnwrap.ERR_REPOS_HOOK_FAILURE:
+            # Special handling for svn hooks blocking error
+            raise hgutil.Abort(e.args[0])
         else:
             raise
 

File hgsubversion/svnwrap/subvertpy_wrapper.py

 ERR_INCOMPLETE_DATA = subvertpy.ERR_INCOMPLETE_DATA
 ERR_RA_DAV_PATH_NOT_FOUND = subvertpy.ERR_RA_DAV_PATH_NOT_FOUND
 ERR_RA_DAV_REQUEST_FAILED = subvertpy.ERR_RA_DAV_REQUEST_FAILED
+ERR_REPOS_HOOK_FAILURE = subvertpy.ERR_REPOS_HOOK_FAILURE
 SSL_UNKNOWNCA = subvertpy.SSL_UNKNOWNCA
 SSL_CNMISMATCH = subvertpy.SSL_CNMISMATCH
 SSL_NOTYETVALID = subvertpy.SSL_NOTYETVALID

File hgsubversion/svnwrap/svn_swig_wrapper.py

 ERR_FS_TXN_OUT_OF_DATE = core.SVN_ERR_FS_TXN_OUT_OF_DATE
 ERR_INCOMPLETE_DATA = core.SVN_ERR_INCOMPLETE_DATA
 ERR_RA_DAV_REQUEST_FAILED = core.SVN_ERR_RA_DAV_REQUEST_FAILED
+ERR_REPOS_HOOK_FAILURE = core.SVN_ERR_REPOS_HOOK_FAILURE
 SSL_UNKNOWNCA = core.SVN_AUTH_SSL_UNKNOWNCA
 SSL_CNMISMATCH = core.SVN_AUTH_SSL_CNMISMATCH
 SSL_NOTYETVALID = core.SVN_AUTH_SSL_NOTYETVALID

File tests/run.py

     import test_fetch_symlinks
     import test_fetch_truncated
     import test_hooks
+    import test_svn_pre_commit_hooks
     import test_pull
     import test_pull_fallback
     import test_push_command

File tests/test_svn_pre_commit_hooks.py

+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__])