view tests/test_svn_pre_commit_hooks.py @ 1485:6088597abd20 stable

test_fetch_renames: avoid hash randomization bug in test When hash randomization is enabled, the order in which revisions are committed to the Mercurial repository can vary for revisions which span branches. In order to work around this, we key the dictionary of golden values for copy data using the suffix of the convert_revision metadata rather than the Mercurial changelog index of the revision.
author Augie Fackler <raf@durin42.com>
date Sun, 26 Jun 2016 20:28:34 -0400
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)