comparison tests/test_unaffected_core.py @ 813:f07bfd66db13

test_util: handle dispatch.dispatch() taking a request This was introduced in hg.08bfec2ef031
author Patrick Mezard <pmezard@gmail.com>
date Wed, 15 Jun 2011 14:44:14 +0200
parents 69c0e7c4faf9
children 312b37bc5e20
comparison
equal deleted inserted replaced
812:8c7447b4b004 813:f07bfd66db13
8 from mercurial import error 8 from mercurial import error
9 from mercurial import hg 9 from mercurial import hg
10 from mercurial import node 10 from mercurial import node
11 from mercurial import ui 11 from mercurial import ui
12 12
13 def _dispatch(ui, cmd):
14 try:
15 req = dispatch.request(cmd, ui=ui)
16 dispatch._dispatch(req)
17 except AttributeError:
18 dispatch._dispatch(ui, cmd)
19
13 class TestMercurialCore(test_util.TestBase): 20 class TestMercurialCore(test_util.TestBase):
14 ''' 21 '''
15 Test that the core Mercurial operations aren't broken by hgsubversion. 22 Test that the core Mercurial operations aren't broken by hgsubversion.
16 ''' 23 '''
17 24
18 @test_util.requiresoption('updaterev') 25 @test_util.requiresoption('updaterev')
19 def test_update(self): 26 def test_update(self):
20 ''' Test 'clone --updaterev' ''' 27 ''' Test 'clone --updaterev' '''
21 ui = self.ui() 28 ui = self.ui()
22 dispatch._dispatch(ui, ['init', self.wc_path]) 29 _dispatch(ui, ['init', self.wc_path])
23 repo = self.repo 30 repo = self.repo
24 repo.ui.setconfig('ui', 'username', 'anonymous') 31 repo.ui.setconfig('ui', 'username', 'anonymous')
25 32
26 fpath = os.path.join(self.wc_path, 'it') 33 fpath = os.path.join(self.wc_path, 'it')
27 f = file(fpath, 'w') 34 f = file(fpath, 'w')
37 commands.commit(ui, repo, message="C3") 44 commands.commit(ui, repo, message="C3")
38 45
39 self.assertEqual(len(repo), 3) 46 self.assertEqual(len(repo), 3)
40 47
41 updaterev = 1 48 updaterev = 1
42 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', 49 _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
43 '--updaterev=%s' % updaterev]) 50 '--updaterev=%s' % updaterev])
44 51
45 repo2 = hg.repository(ui, self.wc_path + '2') 52 repo2 = hg.repository(ui, self.wc_path + '2')
46 53
47 self.assertEqual(str(repo[updaterev]), str(repo2['.'])) 54 self.assertEqual(str(repo[updaterev]), str(repo2['.']))
48 55
49 @test_util.requiresoption('branch') 56 @test_util.requiresoption('branch')
50 def test_branch(self): 57 def test_branch(self):
51 ''' Test 'clone --branch' ''' 58 ''' Test 'clone --branch' '''
52 ui = self.ui() 59 ui = self.ui()
53 dispatch._dispatch(ui, ['init', self.wc_path]) 60 _dispatch(ui, ['init', self.wc_path])
54 repo = self.repo 61 repo = self.repo
55 repo.ui.setconfig('ui', 'username', 'anonymous') 62 repo.ui.setconfig('ui', 'username', 'anonymous')
56 63
57 fpath = os.path.join(self.wc_path, 'it') 64 fpath = os.path.join(self.wc_path, 'it')
58 f = file(fpath, 'w') 65 f = file(fpath, 'w')
71 commands.commit(ui, repo, message="C3") 78 commands.commit(ui, repo, message="C3")
72 79
73 self.assertEqual(len(repo), 3) 80 self.assertEqual(len(repo), 3)
74 81
75 branch = 'B1' 82 branch = 'B1'
76 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', 83 _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
77 '--branch', branch]) 84 '--branch', branch])
78 85
79 repo2 = hg.repository(ui, self.wc_path + '2') 86 repo2 = hg.repository(ui, self.wc_path + '2')
80 87
81 self.assertEqual(repo[branch].hex(), repo2['.'].hex()) 88 self.assertEqual(repo[branch].hex(), repo2['.'].hex())