Mercurial > hgsubversion
annotate tests/test_svn_pre_commit_hooks.py @ 1026:66395f232b7c
layouts: pull tag location list management into layout module
We keep a list of locations within subversion where we look for tags
that persists across runs. This pulls the logic for constructiong
that list from config on first clone, and for mainting the list
afterwards out of svnmeta and into layouts.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Tue, 21 May 2013 16:29:18 -0700 |
parents | cf53cfaaa050 |
children | d741f536f23a |
rev | line source |
---|---|
987
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
1 import os |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
2 import sys |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
3 import test_util |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
4 import unittest |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
5 |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
6 from mercurial import hg |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
7 from mercurial import commands |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
8 from mercurial import util |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
9 |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
10 |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
11 class TestSvnPreCommitHooks(test_util.TestBase): |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
12 def setUp(self): |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
13 super(TestSvnPreCommitHooks, self).setUp() |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
14 self.repo_path = self.load_and_fetch('single_rev.svndump')[1] |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
15 # creating pre-commit hook that doesn't allow any commit |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
16 hook_file_name = os.path.join( |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
17 self.repo_path, 'hooks', 'pre-commit' |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
18 ) |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
19 hook_file = open(hook_file_name, 'w') |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
20 hook_file.write( |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
21 '#!/bin/sh\n' |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
22 'echo "Commits are not allowed" >&2; exit 1;\n' |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
23 ) |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
24 hook_file.close() |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
25 os.chmod(hook_file_name, 0755) |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
26 |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
27 def test_push_with_pre_commit_hooks(self): |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
28 changes = [('narf/a', 'narf/a', 'ohai',), |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
29 ] |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
30 self.commitchanges(changes) |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
31 self.assertRaises(util.Abort, self.pushrevisions) |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
32 |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
33 def suite(): |
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
diff
changeset
|
34 return unittest.findTestCases(sys.modules[__name__]) |