comparison tests/test_fetch_mappings.py @ 1570:d55c9d0ba350

tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
author Paul Morelle <paul.morelle@octobus.net>
date Fri, 25 May 2018 11:52:03 +0200
parents 9a6bb3657861
children e2d38f6b8afe
comparison
equal deleted inserted replaced
1569:4afe8d7e4602 1570:d55c9d0ba350
12 12
13 from hgsubversion import maps 13 from hgsubversion import maps
14 from hgsubversion import svncommands 14 from hgsubversion import svncommands
15 from hgsubversion import util 15 from hgsubversion import util
16 from hgsubversion import verify 16 from hgsubversion import verify
17
18 revsymbol = test_util.revsymbol
17 19
18 class MapTests(test_util.TestBase): 20 class MapTests(test_util.TestBase):
19 stupid_mode_tests = True 21 stupid_mode_tests = True
20 22
21 @property 23 @property
44 ui.setconfig('hgsubversion', 'authormap', self.authors) 46 ui.setconfig('hgsubversion', 'authormap', self.authors)
45 commands.clone(ui, test_util.fileurl(repo_path), 47 commands.clone(ui, test_util.fileurl(repo_path),
46 self.wc_path, authors=self.authors) 48 self.wc_path, authors=self.authors)
47 self.assertEqual(self.repo[0].user(), 49 self.assertEqual(self.repo[0].user(),
48 'Augie Fackler <durin42@gmail.com>') 50 'Augie Fackler <durin42@gmail.com>')
49 self.assertEqual(self.repo['tip'].user(), 51 self.assertEqual(revsymbol(self.repo, 'tip').user(),
50 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') 52 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
51 53
52 def test_author_map_closing_author(self): 54 def test_author_map_closing_author(self):
53 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 55 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
54 authormap = open(self.authors, 'w') 56 authormap = open(self.authors, 'w')
58 ui.setconfig('hgsubversion', 'authormap', self.authors) 60 ui.setconfig('hgsubversion', 'authormap', self.authors)
59 commands.clone(ui, test_util.fileurl(repo_path), 61 commands.clone(ui, test_util.fileurl(repo_path),
60 self.wc_path, authors=self.authors) 62 self.wc_path, authors=self.authors)
61 self.assertEqual(self.repo[0].user(), 63 self.assertEqual(self.repo[0].user(),
62 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') 64 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
63 self.assertEqual(self.repo['tip'].user(), 65 self.assertEqual(revsymbol(self.repo, 'tip').user(),
64 'Testy <test@test>') 66 'Testy <test@test>')
65 67
66 def test_author_map_no_author(self): 68 def test_author_map_no_author(self):
67 repo, repo_path = self.load_and_fetch('no-author.svndump') 69 repo, repo_path = self.load_and_fetch('no-author.svndump')
68 users = set(self.repo[r].user() for r in self.repo) 70 users = set(self.repo[r].user() for r in self.repo)
112 ui.setconfig('hgsubversion', 'caseignoreauthors', True) 114 ui.setconfig('hgsubversion', 'caseignoreauthors', True)
113 commands.clone(ui, test_util.fileurl(repo_path), 115 commands.clone(ui, test_util.fileurl(repo_path),
114 self.wc_path, authors=self.authors) 116 self.wc_path, authors=self.authors)
115 self.assertEqual(self.repo[0].user(), 117 self.assertEqual(self.repo[0].user(),
116 'Augie Fackler <durin42@gmail.com>') 118 'Augie Fackler <durin42@gmail.com>')
117 self.assertEqual(self.repo['tip'].user(), 119 self.assertEqual(revsymbol(self.repo, 'tip').user(),
118 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') 120 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
119 121
120 def test_author_map_mapauthorscmd(self): 122 def test_author_map_mapauthorscmd(self):
121 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 123 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
122 ui = self.ui() 124 ui = self.ui()
123 ui.setconfig('hgsubversion', 'mapauthorscmd', 'echo "svn: %s"') 125 ui.setconfig('hgsubversion', 'mapauthorscmd', 'echo "svn: %s"')
124 commands.clone(ui, test_util.fileurl(repo_path), 126 commands.clone(ui, test_util.fileurl(repo_path),
125 self.wc_path) 127 self.wc_path)
126 self.assertEqual(self.repo[0].user(), 'svn: Augie') 128 self.assertEqual(self.repo[0].user(), 'svn: Augie')
127 self.assertEqual(self.repo['tip'].user(), 'svn: evil') 129 self.assertEqual(revsymbol(self.repo, 'tip').user(), 'svn: evil')
128 130
129 def _loadwithfilemap(self, svndump, filemapcontent, 131 def _loadwithfilemap(self, svndump, filemapcontent,
130 failonmissing=True): 132 failonmissing=True):
131 repo_path = self.load_svndump(svndump) 133 repo_path = self.load_svndump(svndump)
132 filemap = open(self.filemap, 'w') 134 filemap = open(self.filemap, 'w')
143 @test_util.requiresreplay 145 @test_util.requiresreplay
144 def test_file_map(self): 146 def test_file_map(self):
145 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', 147 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
146 "include alpha\n") 148 "include alpha\n")
147 self.assertEqual(node.hex(repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') 149 self.assertEqual(node.hex(repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
148 self.assertEqual(node.hex(repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') 150 self.assertEqual(node.hex(revsymbol(repo, 'default').node()), 'e524296152246b3837fe9503c83b727075835155')
149 151
150 @test_util.requiresreplay 152 @test_util.requiresreplay
151 def test_file_map_exclude(self): 153 def test_file_map_exclude(self):
152 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', 154 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
153 "exclude alpha\n") 155 "exclude alpha\n")
154 self.assertEqual(node.hex(repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') 156 self.assertEqual(node.hex(repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
155 self.assertEqual(node.hex(repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') 157 self.assertEqual(node.hex(revsymbol(repo, 'default').node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
156 158
157 @test_util.requiresreplay 159 @test_util.requiresreplay
158 def test_file_map_rule_order(self): 160 def test_file_map_rule_order(self):
159 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump', 161 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
160 "exclude alpha\ninclude .\nexclude gamma\n") 162 "exclude alpha\ninclude .\nexclude gamma\n")
161 # The exclusion of alpha is overridden by the later rule to 163 # The exclusion of alpha is overridden by the later rule to
162 # include all of '.', whereas gamma should remain excluded 164 # include all of '.', whereas gamma should remain excluded
163 # because it's excluded after the root directory. 165 # because it's excluded after the root directory.
164 self.assertEqual(sorted(self.repo[0].manifest().keys()), 166 self.assertEqual(sorted(self.repo[0].manifest().keys()),
165 ['alpha', 'beta']) 167 ['alpha', 'beta'])
166 self.assertEqual(sorted(self.repo['default'].manifest().keys()), 168 self.assertEqual(sorted(revsymbol(self.repo, 'default').manifest().keys()),
167 ['alpha', 'beta']) 169 ['alpha', 'beta'])
168 170
169 @test_util.requiresreplay 171 @test_util.requiresreplay
170 def test_file_map_copy(self): 172 def test_file_map_copy(self):
171 # Exercise excluding files copied from a non-excluded directory. 173 # Exercise excluding files copied from a non-excluded directory.
366 tags = self.repo.tags() 368 tags = self.repo.tags()
367 369
368 def test_empty_log_message(self): 370 def test_empty_log_message(self):
369 repo, repo_path = self.load_and_fetch('empty-log-message.svndump') 371 repo, repo_path = self.load_and_fetch('empty-log-message.svndump')
370 372
371 self.assertEqual(repo['tip'].description(), '') 373 self.assertEqual(revsymbol(repo, 'tip').description(), '')
372 374
373 test_util.rmtree(self.wc_path) 375 test_util.rmtree(self.wc_path)
374 376
375 ui = self.ui() 377 ui = self.ui()
376 ui.setconfig('hgsubversion', 'defaultmessage', 'blyf') 378 ui.setconfig('hgsubversion', 'defaultmessage', 'blyf')
377 commands.clone(ui, test_util.fileurl(repo_path), self.wc_path) 379 commands.clone(ui, test_util.fileurl(repo_path), self.wc_path)
378 380
379 self.assertEqual(self.repo['tip'].description(), 'blyf') 381 self.assertEqual(revsymbol(self.repo, 'tip').description(), 'blyf')