view tests/test_svn_pre_commit_hooks.py @ 1602:6a6ce9d9da35 default tip

compathacks: make memfilectx construction compatible with hg5.0 'copied' in memfilectx was renamed to 'copysource' in 550a172a603b9ed in core mercurial.
author Pulkit Goyal <pulkit@yandex-team.ru>
date Fri, 19 Apr 2019 16:28:39 +0300
parents cff81f35b31e
children
line wrap: on
line source

import os
import sys
import test_util
import unittest

from mercurial import commands
from mercurial import error
from mercurial import hg


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(error.Abort, self.pushrevisions)