comparison tests/test_push_command.py @ 991:26e9fd21f3bf

push: avoid rebasing when we know there are no conflicts When pushing multiple commits, push would do one rebase per commit. This changes it track the files that have been changed as part of the push and only perform a rebase if the commit touches a file that has been changed previously. On our repo, push used to take 25 seconds per commit. With this change it takes closer to 10 seconds per commit (if there are no conflicts).
author Durham Goode <durham@fb.com>
date Wed, 02 Jan 2013 17:54:30 -0800
parents def2144c0a8c
children 110794582448
comparison
equal deleted inserted replaced
990:def2144c0a8c 991:26e9fd21f3bf
549 self.assertTrue(commit2.mutable()) 549 self.assertTrue(commit2.mutable())
550 commit1 = commit2.parents()[0] 550 commit1 = commit2.parents()[0]
551 self.assertEqual(commit1.files(), ['gamma', ]) 551 self.assertEqual(commit1.files(), ['gamma', ])
552 self.assertFalse(commit1.mutable()) 552 self.assertFalse(commit1.mutable())
553 553
554 def test_push_two_that_modify_same_file(self):
555 '''
556 Push performs a rebase if two commits touch the same file.
557 This test verifies that code path works.
558 '''
559
560 oldlen = len(self.repo)
561 oldtiphash = self.repo['default'].node()
562
563 changes = [('gamma', 'gamma', 'sometext')]
564 newhash = self.commitchanges(changes)
565 changes = [('gamma', 'gamma', 'sometext\n moretext'),
566 ('delta', 'delta', 'sometext\n moretext'),
567 ]
568 newhash = self.commitchanges(changes)
569
570 repo = self.repo
571 hg.update(repo, newhash)
572 commands.push(repo.ui, repo)
573 self.assertEqual(len(self.repo), oldlen + 2)
574
575 # verify that both commits are pushed
576 commit1 = self.repo['tip']
577 self.assertEqual(commit1.files(), ['delta', 'gamma'])
578 self.assertFalse(commit1.mutable())
579 commit2 = commit1.parents()[0]
580 self.assertEqual(commit2.files(), ['gamma'])
581 self.assertFalse(commit2.mutable())
582
554 583
555 def suite(): 584 def suite():
556 test_classes = [PushTests, ] 585 test_classes = [PushTests, ]
557 all_tests = [] 586 all_tests = []
558 # This is the quickest hack I could come up with to load all the tests from 587 # This is the quickest hack I could come up with to load all the tests from