view tests/test_svn_pre_commit_hooks.py @ 1506:332e803044e5

commands: fix registrar check 'util' in hgsubversion is a different type from hgutil, which is the one from core hg. This was hidden by the fallback logic, but I'm not sure why it didn't cause errors in the tests. Maybe I ran the original tests against an older hg. This time I've ensured the tests pass against the latest version of hg.
author Durham Goode <durham@fb.com>
date Tue, 23 May 2017 11:08:42 -0700
parents d741f536f23a
children cff81f35b31e
line wrap: on
line source

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)