comparison tests/test_fetch_mappings.py @ 331:75f082b5897e

Switch to using url scheme wrappers instead of duplicating each command we wrap. The 'hg svn url' command has been killed; the replacement is '.hg/hgrc'. More stuff related to its disappearance has been stripped, including two tests. HgChangeReceiver now takes a UUID argument, which it uses to ensure that remote repositories remain unchanged. This is a temporary solution, and I'm not entirely satisfied with how it's done either. Access to the UUID file has been isolated in a HgChangeReceiver property. Some more tests have been updated to use ui.pushbuffer()/popbuffer(), and to pass through the Mercurial API. Moved the arguments to wrappers.pull() to the UI configuration. Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames' instance & configuration variable. The name is taken from the ConvertExtension.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 15 May 2009 19:18:43 +0200
parents ffccf0080e54
children 2c0649064455
comparison
equal deleted inserted replaced
330:5f8f2fd4fd54 331:75f082b5897e
1 """Tests for author maps and file maps. 1 """Tests for author maps and file maps.
2 """ 2 """
3 import os 3 import os
4 import unittest 4 import unittest
5 5
6 from mercurial import commands
6 from mercurial import ui 7 from mercurial import ui
7 from mercurial import node 8 from mercurial import node
8 9
9 import test_util 10 import test_util
10 import wrappers
11 11
12 class MapTests(test_util.TestBase): 12 class MapTests(test_util.TestBase):
13 @property 13 @property
14 def authors(self): 14 def authors(self):
15 return os.path.join(self.tmpdir, 'authormap') 15 return os.path.join(self.tmpdir, 'authormap')
21 def test_author_map(self, stupid=False): 21 def test_author_map(self, stupid=False):
22 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 22 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
23 authormap = open(self.authors, 'w') 23 authormap = open(self.authors, 'w')
24 authormap.write("Augie=Augie Fackler <durin42@gmail.com>\n") 24 authormap.write("Augie=Augie Fackler <durin42@gmail.com>\n")
25 authormap.close() 25 authormap.close()
26 wrappers.clone(None, ui.ui(), source=test_util.fileurl(self.repo_path), 26 _ui = ui.ui()
27 dest=self.wc_path, stupid=stupid, svn_authors=self.authors) 27 _ui.setconfig('hgsubversion', 'stupid', str(stupid))
28 _ui.setconfig('hgsubversion', 'authormap', self.authors)
29 commands.clone(_ui, test_util.fileurl(self.repo_path),
30 self.wc_path, authors=self.authors)
28 self.assertEqual(self.repo[0].user(), 31 self.assertEqual(self.repo[0].user(),
29 'Augie Fackler <durin42@gmail.com>') 32 'Augie Fackler <durin42@gmail.com>')
30 self.assertEqual(self.repo['tip'].user(), 33 self.assertEqual(self.repo['tip'].user(),
31 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') 34 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
32 35
36 def test_author_map_closing_author(self, stupid=False): 39 def test_author_map_closing_author(self, stupid=False):
37 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 40 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
38 authormap = open(self.authors, 'w') 41 authormap = open(self.authors, 'w')
39 authormap.write("evil=Testy <test@test>") 42 authormap.write("evil=Testy <test@test>")
40 authormap.close() 43 authormap.close()
41 wrappers.clone(None, ui.ui(), source=test_util.fileurl(self.repo_path), 44 _ui = ui.ui()
42 dest=self.wc_path, stupid=stupid, 45 _ui.setconfig('hgsubversion', 'stupid', str(stupid))
43 svn_authors=self.authors) 46 _ui.setconfig('hgsubversion', 'authormap', self.authors)
47 commands.clone(_ui, test_util.fileurl(self.repo_path),
48 self.wc_path, authors=self.authors)
44 self.assertEqual(self.repo[0].user(), 49 self.assertEqual(self.repo[0].user(),
45 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') 50 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
46 self.assertEqual(self.repo['tip'].user(), 51 self.assertEqual(self.repo['tip'].user(),
47 'Testy <test@test>') 52 'Testy <test@test>')
48 53
52 def test_file_map(self, stupid=False): 57 def test_file_map(self, stupid=False):
53 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 58 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
54 filemap = open(self.filemap, 'w') 59 filemap = open(self.filemap, 'w')
55 filemap.write("include alpha\n") 60 filemap.write("include alpha\n")
56 filemap.close() 61 filemap.close()
57 wrappers.clone(None, ui.ui(), source=test_util.fileurl(self.repo_path), 62 _ui = ui.ui()
58 dest=self.wc_path, stupid=stupid, 63 _ui.setconfig('hgsubversion', 'stupid', str(stupid))
59 svn_filemap=self.filemap) 64 _ui.setconfig('hgsubversion', 'filemap', self.filemap)
65 commands.clone(_ui, test_util.fileurl(self.repo_path),
66 self.wc_path, filemap=self.filemap)
60 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') 67 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
61 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') 68 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
62 69
63 def test_file_map_stupid(self): 70 def test_file_map_stupid(self):
64 self.test_file_map(True) 71 self.test_file_map(True)
66 def test_file_map_exclude(self, stupid=False): 73 def test_file_map_exclude(self, stupid=False):
67 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 74 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
68 filemap = open(self.filemap, 'w') 75 filemap = open(self.filemap, 'w')
69 filemap.write("exclude alpha\n") 76 filemap.write("exclude alpha\n")
70 filemap.close() 77 filemap.close()
71 wrappers.clone(None, ui.ui(), source=test_util.fileurl(self.repo_path), 78 _ui = ui.ui()
72 dest=self.wc_path, stupid=stupid, 79 _ui.setconfig('hgsubversion', 'stupid', str(stupid))
73 svn_filemap=self.filemap) 80 _ui.setconfig('hgsubversion', 'filemap', self.filemap)
81 commands.clone(_ui, test_util.fileurl(self.repo_path),
82 self.wc_path, filemap=self.filemap)
74 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') 83 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
75 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') 84 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
76 85
77 def test_file_map_exclude_stupid(self): 86 def test_file_map_exclude_stupid(self):
78 self.test_file_map_exclude(True) 87 self.test_file_map_exclude(True)