Mercurial > hgsubversion
comparison tests/test_hooks.py @ 919:92bd7b3678ea
Add a changegroup hook to update svn metadata
author | Brad Hall <bhall@fb.com> |
---|---|
date | Thu, 07 Jun 2012 16:29:05 -0700 |
parents | |
children | d741f536f23a |
comparison
equal
deleted
inserted
replaced
918:761a87134501 | 919:92bd7b3678ea |
---|---|
1 import sys | |
2 import test_util | |
3 import unittest | |
4 | |
5 from mercurial import hg | |
6 from mercurial import commands | |
7 | |
8 class TestHooks(test_util.TestBase): | |
9 def setUp(self): | |
10 super(TestHooks, self).setUp() | |
11 | |
12 def _loadupdate(self, fixture_name, *args, **kwargs): | |
13 kwargs = kwargs.copy() | |
14 kwargs.update(stupid=False, noupdate=False) | |
15 repo, repo_path = self.load_and_fetch(fixture_name, *args, **kwargs) | |
16 return repo, repo_path | |
17 | |
18 def test_updatemetahook(self): | |
19 repo, repo_path = self._loadupdate('single_rev.svndump') | |
20 state = repo.parents() | |
21 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'}) | |
22 commands.pull(self.repo.ui, self.repo) | |
23 | |
24 # Clone to a new repository and add a hook | |
25 new_wc_path = "%s-2" % self.wc_path | |
26 commands.clone(self.repo.ui, self.wc_path, new_wc_path) | |
27 newrepo = hg.repository(test_util.testui(), new_wc_path) | |
28 newrepo.ui.setconfig('hooks', 'changegroup.meta', | |
29 'python:hgsubversion.hooks.updatemeta.hook') | |
30 | |
31 # Commit a rev that should trigger svn meta update | |
32 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed Again'}) | |
33 commands.pull(self.repo.ui, self.repo) | |
34 | |
35 self.called = False | |
36 import hgsubversion.svncommands | |
37 oldupdatemeta = hgsubversion.svncommands.updatemeta | |
38 def _updatemeta(ui, repo, args=[]): | |
39 self.called = True | |
40 hgsubversion.svncommands.updatemeta = _updatemeta | |
41 | |
42 # Pull and make sure our updatemeta function gets called | |
43 commands.pull(newrepo.ui, newrepo) | |
44 hgsubversion.svncommands.updatemeta = oldupdatemeta | |
45 self.assertTrue(self.called) | |
46 | |
47 def suite(): | |
48 return unittest.findTestCases(sys.modules[__name__]) |