mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
This commit is contained in:
parent
17069bf4ee
commit
a55ee7944c
@ -210,6 +210,9 @@ def commit(ui, repo, rev_ctx, meta, base_revision, svn):
|
||||
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
|
||||
|
||||
|
@ -58,6 +58,7 @@ ERR_FS_TXN_OUT_OF_DATE = subvertpy.ERR_FS_TXN_OUT_OF_DATE
|
||||
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
|
||||
|
@ -42,6 +42,7 @@ ERR_FS_NOT_FOUND = core.SVN_ERR_FS_NOT_FOUND
|
||||
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
|
||||
|
@ -19,6 +19,7 @@ def tests():
|
||||
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
|
||||
|
34
tests/test_svn_pre_commit_hooks.py
Normal file
34
tests/test_svn_pre_commit_hooks.py
Normal file
@ -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__])
|
Loading…
Reference in New Issue
Block a user