comparison tests/test_utility_commands.py @ 899:7f90bb48c9de

svn verify: use a custom editor and get_revision() Previously, we would fetch each file in the revision/changeset individually. With this change, we fetch the entire revision in one request, and use a custom editor to verify its contents. This is quite a lot faster than the previous means when verifying over the internet. By an order of magnitude or two, in fact. As data is transfered in a single operation, verifying a revision from PyPy took 30 seconds rather than 30 minutes, and saturated my 10Mbps connection. Please note that the output ordering isn't stable between the two; output will appear in reverse order when using the fast verifier.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 14 Dec 2011 00:07:58 +0100
parents 6bc8046e3d0a
children 761a87134501
comparison
equal deleted inserted replaced
898:6524260be543 899:7f90bb48c9de
244 svncommands.listauthors(self.ui(), 244 svncommands.listauthors(self.ui(),
245 args=[test_util.fileurl(repo_path)], 245 args=[test_util.fileurl(repo_path)],
246 authors=author_path) 246 authors=author_path)
247 self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n') 247 self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n')
248 248
249 def test_svnverify(self): 249 def test_svnverify(self, stupid=False):
250 repo, repo_path = self.load_and_fetch('binaryfiles.svndump', 250 repo, repo_path = self.load_and_fetch('binaryfiles.svndump',
251 noupdate=False) 251 noupdate=False, stupid=stupid)
252 ret = verify.verify(self.ui(), repo, [], rev=1) 252 ret = verify.verify(self.ui(), repo, [], rev=1, stupid=stupid)
253 self.assertEqual(0, ret) 253 self.assertEqual(0, ret)
254 repo_path = self.load_svndump('binaryfiles-broken.svndump') 254 repo_path = self.load_svndump('binaryfiles-broken.svndump')
255 u = self.ui() 255 u = self.ui()
256 u.pushbuffer() 256 u.pushbuffer()
257 ret = verify.verify(u, repo, [test_util.fileurl(repo_path)], rev=1) 257 ret = verify.verify(u, repo, [test_util.fileurl(repo_path)],
258 rev=1, stupid=stupid)
258 output = u.popbuffer() 259 output = u.popbuffer()
259 self.assertEqual(1, ret) 260 self.assertEqual(1, ret)
260 output = re.sub(r'file://\S+', 'file://', output) 261 output = re.sub(r'file://\S+', 'file://', output)
261 self.assertMultiLineEqual("""\ 262 self.assertMultiLineEqual("""\
262 verifying d51f46a715a1 against file:// 263 verifying d51f46a715a1 against file://
263 difference in: binary2 264 difference in: binary2
264 unexpected file: binary1 265 unexpected file: binary1
265 missing file: binary3 266 missing file: binary3
266 """, output) 267 """, output)
267 268
268 def test_svnverify_corruption(self): 269 def test_svnverify_stupid(self):
270 self.test_svnverify(True)
271
272 def test_corruption(self, stupid=False):
269 SUCCESS = 0 273 SUCCESS = 0
270 FAILURE = 1 274 FAILURE = 1
271 275
272 repo, repo_path = self.load_and_fetch('correct.svndump', layout='single', 276 repo, repo_path = self.load_and_fetch('correct.svndump', layout='single',
273 subdir='') 277 subdir='', stupid=stupid)
274 278
275 ui = self.ui() 279 ui = self.ui()
276 280
277 self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip')) 281 self.assertEqual(SUCCESS, verify.verify(ui, self.repo, rev='tip',
282 stupid=stupid))
278 283
279 corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump')) 284 corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump'))
280 285
281 repo.ui.setconfig('paths', 'default', corrupt_source) 286 repo.ui.setconfig('paths', 'default', corrupt_source)
282 287
298 'unexpected file: empty-file', 303 'unexpected file: empty-file',
299 ]) 304 ])
300 305
301 self.assertEqual((FAILURE, expected), (code, actual)) 306 self.assertEqual((FAILURE, expected), (code, actual))
302 307
308 def test_corruption_stupid(self):
309 self.test_corruption(True)
310
303 def suite(): 311 def suite():
304 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), 312 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests),
305 ] 313 ]
306 return unittest.TestSuite(all_tests) 314 return unittest.TestSuite(all_tests)