comparison tests/test_push_command.py @ 1229:46523cdfd3b0 stable 1.6.3

pushmod: prepend "link " to base text for links http://svn.apache.org/viewvc?view=revision&revision=1223036 exposes what is arguably a bug in hgsubversion push code. Specifically, when we are receiving text from the server in an editor, we prepend a "link " to the text of symlinks when opening a file and strip it when closing a file. We don't, however, prepend "link " to the base we use when sending text changes to the server. This was working before because prior to that revision, the first thing subversion did was to check whether the entirety of the before text or the entirety of the after text was less than 64 bytes. In that case, it just sent the entirety of the after text as a single insert operation. I'd expect most, but not all symlinks to fit under the 64 byte limit, including the leading "link " text on the subversion end. After the change, the first thing subversion does is check for a leading match that is more than 4 bytes long, or that is the full length of the after text. In this case, it sends a copy operation for the leading match, and then goes into the if < 64 bytes remaining send the whole thing behavior. It also looks for trailing matches of more than 4 bytes even in the <64 byte case, but that's not what breaks the tests. Incidentally, changing the destination of long symlinks was broken even before this subversion change. This diff includes test additions that cover that breakage.
author David Schleimer <dschleimer@gmail.com>
date Thu, 07 Aug 2014 19:30:26 -0700
parents afd047a7df45
children 5c2917375961
comparison
equal deleted inserted replaced
1227:9819b4d6451e 1229:46523cdfd3b0
443 '2008-10-29 21:26:00 -0500', 443 '2008-10-29 21:26:00 -0500',
444 {'branch': 'default', }) 444 {'branch': 'default', })
445 new_hash = repo.commitctx(ctx) 445 new_hash = repo.commitctx(ctx)
446 hg.update(repo, repo['tip'].node()) 446 hg.update(repo, repo['tip'].node())
447 self.pushrevisions() 447 self.pushrevisions()
448 tip = self.repo['tip'] 448 # grab a new repo instance (self.repo is an @property functions)
449 repo = self.repo
450 tip = repo['tip']
449 self.assertNotEqual(tip.node(), new_hash) 451 self.assertNotEqual(tip.node(), new_hash)
450 self.assertEqual(tip['gamma'].flags(), 'l') 452 self.assertEqual(tip['gamma'].flags(), 'l')
451 self.assertEqual(tip['gamma'].data(), 'foo') 453 self.assertEqual(tip['gamma'].data(), 'foo')
452 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in 454 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in
453 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) 455 tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
456
457 def file_callback2(repo, memctx, path):
458 if path == 'gamma':
459 return compathacks.makememfilectx(repo,
460 path=path,
461 data='a' * 129,
462 islink=True,
463 isexec=False,
464 copied=False)
465 raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
466
467 ctx = context.memctx(repo,
468 (repo['tip'].node(), node.nullid),
469 'message',
470 ['gamma', ],
471 file_callback2,
472 'author',
473 '2014-08-08 20:11:41 -0700',
474 {'branch': 'default', })
475 repo.commitctx(ctx)
476 hg.update(repo, repo['tip'].node())
477 self.pushrevisions()
478 # grab a new repo instance (self.repo is an @property functions)
479 repo = self.repo
480 tip = repo['tip']
481 self.assertEqual(tip['gamma'].flags(), 'l')
482 self.assertEqual(tip['gamma'].data(), 'a'*129)
483
484 def file_callback3(repo, memctx, path):
485 if path == 'gamma':
486 return compathacks.makememfilectx(repo,
487 path=path,
488 data='a' * 64 + 'b' * 65,
489 islink=True,
490 isexec=False,
491 copied=False)
492 raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
493
494 ctx = context.memctx(repo,
495 (repo['tip'].node(), node.nullid),
496 'message',
497 ['gamma', ],
498 file_callback3,
499 'author',
500 '2014-08-08 20:16:25 -0700',
501 {'branch': 'default', })
502 repo.commitctx(ctx)
503 hg.update(repo, repo['tip'].node())
504 self.pushrevisions()
505 repo = self.repo
506 tip = repo['tip']
507 self.assertEqual(tip['gamma'].flags(), 'l')
508 self.assertEqual(tip['gamma'].data(), 'a' * 64 + 'b' * 65)
509
454 510
455 def test_push_existing_file_newly_symlink(self): 511 def test_push_existing_file_newly_symlink(self):
456 self.test_push_existing_file_newly_execute(execute=False, 512 self.test_push_existing_file_newly_execute(execute=False,
457 link=True, 513 link=True,
458 expected_flags='l') 514 expected_flags='l')