comparison tests/test_fetch_mappings.py @ 866:20e73b5ab6f7

test_util: merge load_svndump_fixture() into TestBase
author Patrick Mezard <patrick@mezard.eu>
date Thu, 19 Apr 2012 18:29:28 +0200
parents 4e203a47102a
children 50c13e01c7e3
comparison
equal deleted inserted replaced
865:04729f3a3d17 866:20e73b5ab6f7
30 @property 30 @property
31 def tagmap(self): 31 def tagmap(self):
32 return os.path.join(self.tmpdir, 'tagmap') 32 return os.path.join(self.tmpdir, 'tagmap')
33 33
34 def test_author_map(self, stupid=False): 34 def test_author_map(self, stupid=False):
35 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 35 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
36 authormap = open(self.authors, 'w') 36 authormap = open(self.authors, 'w')
37 authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n') 37 authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n')
38 authormap.write("Augie Fackler <durin42@gmail.com>\n") 38 authormap.write("Augie Fackler <durin42@gmail.com>\n")
39 authormap.close() 39 authormap.close()
40 ui = self.ui(stupid) 40 ui = self.ui(stupid)
41 ui.setconfig('hgsubversion', 'authormap', self.authors) 41 ui.setconfig('hgsubversion', 'authormap', self.authors)
42 commands.clone(ui, test_util.fileurl(self.repo_path), 42 commands.clone(ui, test_util.fileurl(repo_path),
43 self.wc_path, authors=self.authors) 43 self.wc_path, authors=self.authors)
44 self.assertEqual(self.repo[0].user(), 44 self.assertEqual(self.repo[0].user(),
45 'Augie Fackler <durin42@gmail.com>') 45 'Augie Fackler <durin42@gmail.com>')
46 self.assertEqual(self.repo['tip'].user(), 46 self.assertEqual(self.repo['tip'].user(),
47 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') 47 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
48 48
49 def test_author_map_stupid(self): 49 def test_author_map_stupid(self):
50 self.test_author_map(True) 50 self.test_author_map(True)
51 51
52 def test_author_map_closing_author(self, stupid=False): 52 def test_author_map_closing_author(self, stupid=False):
53 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 53 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
54 authormap = open(self.authors, 'w') 54 authormap = open(self.authors, 'w')
55 authormap.write("evil=Testy <test@test>") 55 authormap.write("evil=Testy <test@test>")
56 authormap.close() 56 authormap.close()
57 ui = self.ui(stupid) 57 ui = self.ui(stupid)
58 ui.setconfig('hgsubversion', 'authormap', self.authors) 58 ui.setconfig('hgsubversion', 'authormap', self.authors)
59 commands.clone(ui, test_util.fileurl(self.repo_path), 59 commands.clone(ui, test_util.fileurl(repo_path),
60 self.wc_path, authors=self.authors) 60 self.wc_path, authors=self.authors)
61 self.assertEqual(self.repo[0].user(), 61 self.assertEqual(self.repo[0].user(),
62 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') 62 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
63 self.assertEqual(self.repo['tip'].user(), 63 self.assertEqual(self.repo['tip'].user(),
64 'Testy <test@test>') 64 'Testy <test@test>')
98 test.load(orig) 98 test.load(orig)
99 all_tests = set(test) 99 all_tests = set(test)
100 self.assertEqual(fromself.symmetric_difference(all_tests), set()) 100 self.assertEqual(fromself.symmetric_difference(all_tests), set())
101 101
102 def test_file_map(self, stupid=False): 102 def test_file_map(self, stupid=False):
103 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 103 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
104 filemap = open(self.filemap, 'w') 104 filemap = open(self.filemap, 'w')
105 filemap.write("include alpha\n") 105 filemap.write("include alpha\n")
106 filemap.close() 106 filemap.close()
107 ui = self.ui(stupid) 107 ui = self.ui(stupid)
108 ui.setconfig('hgsubversion', 'filemap', self.filemap) 108 ui.setconfig('hgsubversion', 'filemap', self.filemap)
109 commands.clone(ui, test_util.fileurl(self.repo_path), 109 commands.clone(ui, test_util.fileurl(repo_path),
110 self.wc_path, filemap=self.filemap) 110 self.wc_path, filemap=self.filemap)
111 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') 111 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
112 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') 112 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
113 113
114 def test_file_map_stupid(self): 114 def test_file_map_stupid(self):
115 # TODO: re-enable test if we ever reinstate this feature 115 # TODO: re-enable test if we ever reinstate this feature
116 self.assertRaises(hgutil.Abort, self.test_file_map, True) 116 self.assertRaises(hgutil.Abort, self.test_file_map, True)
117 117
118 def test_file_map_exclude(self, stupid=False): 118 def test_file_map_exclude(self, stupid=False):
119 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 119 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
120 filemap = open(self.filemap, 'w') 120 filemap = open(self.filemap, 'w')
121 filemap.write("exclude alpha\n") 121 filemap.write("exclude alpha\n")
122 filemap.close() 122 filemap.close()
123 ui = self.ui(stupid) 123 ui = self.ui(stupid)
124 ui.setconfig('hgsubversion', 'filemap', self.filemap) 124 ui.setconfig('hgsubversion', 'filemap', self.filemap)
125 commands.clone(ui, test_util.fileurl(self.repo_path), 125 commands.clone(ui, test_util.fileurl(repo_path),
126 self.wc_path, filemap=self.filemap) 126 self.wc_path, filemap=self.filemap)
127 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') 127 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
128 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') 128 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
129 129
130 def test_file_map_exclude_stupid(self): 130 def test_file_map_exclude_stupid(self):
131 # TODO: re-enable test if we ever reinstate this feature 131 # TODO: re-enable test if we ever reinstate this feature
132 self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True) 132 self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True)
133 133
134 def test_file_map_rule_order(self): 134 def test_file_map_rule_order(self):
135 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 135 repo_path = self.load_svndump('replace_trunk_with_branch.svndump')
136 filemap = open(self.filemap, 'w') 136 filemap = open(self.filemap, 'w')
137 filemap.write("exclude alpha\n") 137 filemap.write("exclude alpha\n")
138 filemap.write("include .\n") 138 filemap.write("include .\n")
139 filemap.write("exclude gamma\n") 139 filemap.write("exclude gamma\n")
140 filemap.close() 140 filemap.close()
141 ui = self.ui(False) 141 ui = self.ui(False)
142 ui.setconfig('hgsubversion', 'filemap', self.filemap) 142 ui.setconfig('hgsubversion', 'filemap', self.filemap)
143 commands.clone(ui, test_util.fileurl(self.repo_path), 143 commands.clone(ui, test_util.fileurl(repo_path),
144 self.wc_path, filemap=self.filemap) 144 self.wc_path, filemap=self.filemap)
145 # The exclusion of alpha is overridden by the later rule to 145 # The exclusion of alpha is overridden by the later rule to
146 # include all of '.', whereas gamma should remain excluded 146 # include all of '.', whereas gamma should remain excluded
147 # because it's excluded after the root directory. 147 # because it's excluded after the root directory.
148 self.assertEqual(self.repo[0].manifest().keys(), 148 self.assertEqual(self.repo[0].manifest().keys(),
149 ['alpha', 'beta']) 149 ['alpha', 'beta'])
150 self.assertEqual(self.repo['default'].manifest().keys(), 150 self.assertEqual(self.repo['default'].manifest().keys(),
151 ['alpha', 'beta']) 151 ['alpha', 'beta'])
152 152
153 def test_branchmap(self, stupid=False): 153 def test_branchmap(self, stupid=False):
154 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') 154 repo_path = self.load_svndump('branchmap.svndump')
155 branchmap = open(self.branchmap, 'w') 155 branchmap = open(self.branchmap, 'w')
156 branchmap.write("badname = good-name # stuffy\n") 156 branchmap.write("badname = good-name # stuffy\n")
157 branchmap.write("feature = default\n") 157 branchmap.write("feature = default\n")
158 branchmap.close() 158 branchmap.close()
159 ui = self.ui(stupid) 159 ui = self.ui(stupid)
160 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 160 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
161 commands.clone(ui, test_util.fileurl(self.repo_path), 161 commands.clone(ui, test_util.fileurl(repo_path),
162 self.wc_path, branchmap=self.branchmap) 162 self.wc_path, branchmap=self.branchmap)
163 branches = set(self.repo[i].branch() for i in self.repo) 163 branches = set(self.repo[i].branch() for i in self.repo)
164 self.assert_('badname' not in branches) 164 self.assert_('badname' not in branches)
165 self.assert_('good-name' in branches) 165 self.assert_('good-name' in branches)
166 self.assertEquals(self.repo[2].branch(), 'default') 166 self.assertEquals(self.repo[2].branch(), 'default')
168 def test_branchmap_stupid(self): 168 def test_branchmap_stupid(self):
169 self.test_branchmap(True) 169 self.test_branchmap(True)
170 170
171 def test_branchmap_tagging(self, stupid=False): 171 def test_branchmap_tagging(self, stupid=False):
172 '''test tagging a renamed branch, which used to raise an exception''' 172 '''test tagging a renamed branch, which used to raise an exception'''
173 test_util.load_svndump_fixture(self.repo_path, 'commit-to-tag.svndump') 173 repo_path = self.load_svndump('commit-to-tag.svndump')
174 branchmap = open(self.branchmap, 'w') 174 branchmap = open(self.branchmap, 'w')
175 branchmap.write("magic = art\n") 175 branchmap.write("magic = art\n")
176 branchmap.close() 176 branchmap.close()
177 ui = self.ui(stupid) 177 ui = self.ui(stupid)
178 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 178 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
179 commands.clone(ui, test_util.fileurl(self.repo_path), 179 commands.clone(ui, test_util.fileurl(repo_path),
180 self.wc_path, branchmap=self.branchmap) 180 self.wc_path, branchmap=self.branchmap)
181 branches = set(self.repo[i].branch() for i in self.repo) 181 branches = set(self.repo[i].branch() for i in self.repo)
182 self.assertEquals(sorted(branches), ['art', 'closeme']) 182 self.assertEquals(sorted(branches), ['art', 'closeme'])
183 183
184 def test_branchmap_tagging_stupid(self): 184 def test_branchmap_tagging_stupid(self):
185 self.test_branchmap_tagging(True) 185 self.test_branchmap_tagging(True)
186 186
187 def test_branchmap_empty_commit(self, stupid=False): 187 def test_branchmap_empty_commit(self, stupid=False):
188 '''test mapping an empty commit on a renamed branch''' 188 '''test mapping an empty commit on a renamed branch'''
189 test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') 189 repo_path = self.load_svndump('propset-branch.svndump')
190 branchmap = open(self.branchmap, 'w') 190 branchmap = open(self.branchmap, 'w')
191 branchmap.write("the-branch = bob\n") 191 branchmap.write("the-branch = bob\n")
192 branchmap.close() 192 branchmap.close()
193 ui = self.ui(stupid) 193 ui = self.ui(stupid)
194 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 194 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
195 commands.clone(ui, test_util.fileurl(self.repo_path), 195 commands.clone(ui, test_util.fileurl(repo_path),
196 self.wc_path, branchmap=self.branchmap) 196 self.wc_path, branchmap=self.branchmap)
197 branches = set(self.repo[i].branch() for i in self.repo) 197 branches = set(self.repo[i].branch() for i in self.repo)
198 self.assertEquals(sorted(branches), ['bob', 'default']) 198 self.assertEquals(sorted(branches), ['bob', 'default'])
199 199
200 def test_branchmap_empty_commit_stupid(self): 200 def test_branchmap_empty_commit_stupid(self):
201 '''test mapping an empty commit on a renamed branch (stupid)''' 201 '''test mapping an empty commit on a renamed branch (stupid)'''
202 self.test_branchmap_empty_commit(True) 202 self.test_branchmap_empty_commit(True)
203 203
204 def test_branchmap_combine(self, stupid=False): 204 def test_branchmap_combine(self, stupid=False):
205 '''test combining two branches, but retaining heads''' 205 '''test combining two branches, but retaining heads'''
206 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') 206 repo_path = self.load_svndump('branchmap.svndump')
207 branchmap = open(self.branchmap, 'w') 207 branchmap = open(self.branchmap, 'w')
208 branchmap.write("badname = default\n") 208 branchmap.write("badname = default\n")
209 branchmap.write("feature = default\n") 209 branchmap.write("feature = default\n")
210 branchmap.close() 210 branchmap.close()
211 ui = self.ui(stupid) 211 ui = self.ui(stupid)
212 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 212 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
213 commands.clone(ui, test_util.fileurl(self.repo_path), 213 commands.clone(ui, test_util.fileurl(repo_path),
214 self.wc_path, branchmap=self.branchmap) 214 self.wc_path, branchmap=self.branchmap)
215 branches = set(self.repo[i].branch() for i in self.repo) 215 branches = set(self.repo[i].branch() for i in self.repo)
216 self.assertEquals(sorted(branches), ['default']) 216 self.assertEquals(sorted(branches), ['default'])
217 self.assertEquals(len(self.repo.heads()), 2) 217 self.assertEquals(len(self.repo.heads()), 2)
218 self.assertEquals(len(self.repo.branchheads('default')), 2) 218 self.assertEquals(len(self.repo.branchheads('default')), 2)
226 '''test combining two branches, but retaining heads (stupid)''' 226 '''test combining two branches, but retaining heads (stupid)'''
227 self.test_branchmap_combine(True) 227 self.test_branchmap_combine(True)
228 228
229 def test_branchmap_rebuildmeta(self, stupid=False): 229 def test_branchmap_rebuildmeta(self, stupid=False):
230 '''test rebuildmeta on a branchmapped clone''' 230 '''test rebuildmeta on a branchmapped clone'''
231 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') 231 repo_path = self.load_svndump('branchmap.svndump')
232 branchmap = open(self.branchmap, 'w') 232 branchmap = open(self.branchmap, 'w')
233 branchmap.write("badname = dit\n") 233 branchmap.write("badname = dit\n")
234 branchmap.write("feature = dah\n") 234 branchmap.write("feature = dah\n")
235 branchmap.close() 235 branchmap.close()
236 ui = self.ui(stupid) 236 ui = self.ui(stupid)
237 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 237 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
238 commands.clone(ui, test_util.fileurl(self.repo_path), 238 commands.clone(ui, test_util.fileurl(repo_path),
239 self.wc_path, branchmap=self.branchmap) 239 self.wc_path, branchmap=self.branchmap)
240 originfo = self.repo.svnmeta().branches 240 originfo = self.repo.svnmeta().branches
241 241
242 # clone & rebuild 242 # clone & rebuild
243 ui = self.ui(stupid) 243 ui = self.ui(stupid)
244 src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone', 244 src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone',
245 update=False) 245 update=False)
246 svncommands.rebuildmeta(ui, dest, 246 svncommands.rebuildmeta(ui, dest,
247 args=[test_util.fileurl(self.repo_path)]) 247 args=[test_util.fileurl(repo_path)])
248 248
249 # just check the keys; assume the contents are unaffected by the branch 249 # just check the keys; assume the contents are unaffected by the branch
250 # map and thus properly tested by other tests 250 # map and thus properly tested by other tests
251 self.assertEquals(sorted(src.svnmeta().branches), 251 self.assertEquals(sorted(src.svnmeta().branches),
252 sorted(dest.svnmeta().branches)) 252 sorted(dest.svnmeta().branches))
255 '''test rebuildmeta on a branchmapped clone (stupid)''' 255 '''test rebuildmeta on a branchmapped clone (stupid)'''
256 self.test_branchmap_rebuildmeta(True) 256 self.test_branchmap_rebuildmeta(True)
257 257
258 def test_branchmap_verify(self, stupid=False): 258 def test_branchmap_verify(self, stupid=False):
259 '''test verify on a branchmapped clone''' 259 '''test verify on a branchmapped clone'''
260 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') 260 repo_path = self.load_svndump('branchmap.svndump')
261 branchmap = open(self.branchmap, 'w') 261 branchmap = open(self.branchmap, 'w')
262 branchmap.write("badname = dit\n") 262 branchmap.write("badname = dit\n")
263 branchmap.write("feature = dah\n") 263 branchmap.write("feature = dah\n")
264 branchmap.close() 264 branchmap.close()
265 ui = self.ui(stupid) 265 ui = self.ui(stupid)
266 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 266 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
267 commands.clone(ui, test_util.fileurl(self.repo_path), 267 commands.clone(ui, test_util.fileurl(repo_path),
268 self.wc_path, branchmap=self.branchmap) 268 self.wc_path, branchmap=self.branchmap)
269 repo = self.repo 269 repo = self.repo
270 270
271 for r in repo: 271 for r in repo:
272 self.assertEquals(svncommands.verify(ui, repo, rev=r), 0) 272 self.assertEquals(svncommands.verify(ui, repo, rev=r), 0)
281 281
282 Empty mappings are lines like 'this ='. The most sensible thing to do 282 Empty mappings are lines like 'this ='. The most sensible thing to do
283 is to not convert the 'this' branches. Until we can do that, we settle 283 is to not convert the 'this' branches. Until we can do that, we settle
284 with aborting. 284 with aborting.
285 ''' 285 '''
286 test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') 286 repo_path = self.load_svndump('propset-branch.svndump')
287 branchmap = open(self.branchmap, 'w') 287 branchmap = open(self.branchmap, 'w')
288 branchmap.write("closeme =\n") 288 branchmap.write("closeme =\n")
289 branchmap.close() 289 branchmap.close()
290 self.assertRaises(hgutil.Abort, 290 self.assertRaises(hgutil.Abort,
291 maps.BranchMap, self.ui(), self.branchmap) 291 maps.BranchMap, self.ui(), self.branchmap)
292 292
293 def test_tagmap(self, stupid=False): 293 def test_tagmap(self, stupid=False):
294 test_util.load_svndump_fixture(self.repo_path, 294 repo_path = self.load_svndump('basic_tag_tests.svndump')
295 'basic_tag_tests.svndump')
296 tagmap = open(self.tagmap, 'w') 295 tagmap = open(self.tagmap, 'w')
297 tagmap.write("tag_r3 = 3.x # stuffy\n") 296 tagmap.write("tag_r3 = 3.x # stuffy\n")
298 tagmap.write("copied_tag = \n") 297 tagmap.write("copied_tag = \n")
299 tagmap.close() 298 tagmap.close()
300 299
301 ui = self.ui(stupid) 300 ui = self.ui(stupid)
302 ui.setconfig('hgsubversion', 'tagmap', self.tagmap) 301 ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
303 commands.clone(ui, test_util.fileurl(self.repo_path), 302 commands.clone(ui, test_util.fileurl(repo_path),
304 self.wc_path, tagmap=self.tagmap) 303 self.wc_path, tagmap=self.tagmap)
305 tags = self.repo.tags() 304 tags = self.repo.tags()
306 assert 'tag_r3' not in tags 305 assert 'tag_r3' not in tags
307 assert '3.x' in tags 306 assert '3.x' in tags
308 assert 'copied_tag' not in tags 307 assert 'copied_tag' not in tags
309 308
310 def test_tagmap_stupid(self): 309 def test_tagmap_stupid(self):
311 self.test_tagmap(True) 310 self.test_tagmap(True)
312 311
313 def test_tagren_changed(self, stupid=False): 312 def test_tagren_changed(self, stupid=False):
314 test_util.load_svndump_fixture(self.repo_path, 313 repo_path = self.load_svndump('commit-to-tag.svndump')
315 'commit-to-tag.svndump')
316 tagmap = open(self.tagmap, 'w') 314 tagmap = open(self.tagmap, 'w')
317 tagmap.write("edit-at-create = edit-past\n") 315 tagmap.write("edit-at-create = edit-past\n")
318 tagmap.write("also-edit = \n") 316 tagmap.write("also-edit = \n")
319 tagmap.write("will-edit = edit-future\n") 317 tagmap.write("will-edit = edit-future\n")
320 tagmap.close() 318 tagmap.close()
321 319
322 ui = self.ui(stupid) 320 ui = self.ui(stupid)
323 ui.setconfig('hgsubversion', 'tagmap', self.tagmap) 321 ui.setconfig('hgsubversion', 'tagmap', self.tagmap)
324 commands.clone(ui, test_util.fileurl(self.repo_path), 322 commands.clone(ui, test_util.fileurl(repo_path),
325 self.wc_path, tagmap=self.tagmap) 323 self.wc_path, tagmap=self.tagmap)
326 tags = self.repo.tags() 324 tags = self.repo.tags()
327 325
328 def test_tagren_changed_stupid(self): 326 def test_tagren_changed_stupid(self):
329 self.test_tagren_changed(True) 327 self.test_tagren_changed(True)