view tests/test_svn_pre_commit_hooks.py @ 1251:46cec117dda2

maps.RevMap: disable GC while loading the revmap The revmap load process creates lots of tiny objects. With just the bare minimum Mercurial runtime, loading a million-file revmap goes from 6.83 seconds to 6.28. For longer running processes (e.g. hg push a series of changes) the difference will probably be dramatic.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 02 Nov 2014 02:01:05 -0800
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)