comparison tests/test_unaffected_core.py @ 713:69c0e7c4faf9

clone: call the wrapped function (fixes #181) This is a regression that was brought to my attention in #mercurial: hgsubversion breaks the --update flag. The cause is that we call hg.clone() directly rather than the original wrapped function. A comment in 'wrapper.py' noted that the call to hg.clone() should be kept in sync with 'mercurial/commands.py'. That didn't happen. The original reason for calling hg.clone() directly was that we needed its return values. Another wrapper is added (and cleared) within clone() to get them anyway.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 29 Sep 2010 18:04:26 +0200
parents
children f07bfd66db13
comparison
equal deleted inserted replaced
712:1041fb1bec8c 713:69c0e7c4faf9
1 import test_util
2
3 import os
4 import unittest
5
6 from mercurial import commands
7 from mercurial import dispatch
8 from mercurial import error
9 from mercurial import hg
10 from mercurial import node
11 from mercurial import ui
12
13 class TestMercurialCore(test_util.TestBase):
14 '''
15 Test that the core Mercurial operations aren't broken by hgsubversion.
16 '''
17
18 @test_util.requiresoption('updaterev')
19 def test_update(self):
20 ''' Test 'clone --updaterev' '''
21 ui = self.ui()
22 dispatch._dispatch(ui, ['init', self.wc_path])
23 repo = self.repo
24 repo.ui.setconfig('ui', 'username', 'anonymous')
25
26 fpath = os.path.join(self.wc_path, 'it')
27 f = file(fpath, 'w')
28 f.write('C1')
29 f.flush()
30 commands.add(ui, repo)
31 commands.commit(ui, repo, message="C1")
32 f.write('C2')
33 f.flush()
34 commands.commit(ui, repo, message="C2")
35 f.write('C3')
36 f.flush()
37 commands.commit(ui, repo, message="C3")
38
39 self.assertEqual(len(repo), 3)
40
41 updaterev = 1
42 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
43 '--updaterev=%s' % updaterev])
44
45 repo2 = hg.repository(ui, self.wc_path + '2')
46
47 self.assertEqual(str(repo[updaterev]), str(repo2['.']))
48
49 @test_util.requiresoption('branch')
50 def test_branch(self):
51 ''' Test 'clone --branch' '''
52 ui = self.ui()
53 dispatch._dispatch(ui, ['init', self.wc_path])
54 repo = self.repo
55 repo.ui.setconfig('ui', 'username', 'anonymous')
56
57 fpath = os.path.join(self.wc_path, 'it')
58 f = file(fpath, 'w')
59 f.write('C1')
60 f.flush()
61 commands.add(ui, repo)
62 commands.branch(ui, repo, label="B1")
63 commands.commit(ui, repo, message="C1")
64 f.write('C2')
65 f.flush()
66 commands.branch(ui, repo, label="default")
67 commands.commit(ui, repo, message="C2")
68 f.write('C3')
69 f.flush()
70 commands.branch(ui, repo, label="B2")
71 commands.commit(ui, repo, message="C3")
72
73 self.assertEqual(len(repo), 3)
74
75 branch = 'B1'
76 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
77 '--branch', branch])
78
79 repo2 = hg.repository(ui, self.wc_path + '2')
80
81 self.assertEqual(repo[branch].hex(), repo2['.'].hex())
82
83 def suite():
84 all = [unittest.TestLoader().loadTestsFromTestCase(TestMercurialCore)]
85 return unittest.TestSuite(all)