diff 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
line wrap: on
line diff
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -551,6 +551,35 @@ class PushTests(test_util.TestBase):
         self.assertEqual(commit1.files(), ['gamma', ])
         self.assertFalse(commit1.mutable())
 
+    def test_push_two_that_modify_same_file(self):
+        '''
+        Push performs a rebase if two commits touch the same file.
+        This test verifies that code path works.
+        '''
+
+        oldlen = len(self.repo)
+        oldtiphash = self.repo['default'].node()
+
+        changes = [('gamma', 'gamma', 'sometext')]
+        newhash = self.commitchanges(changes)
+        changes = [('gamma', 'gamma', 'sometext\n moretext'),
+                   ('delta', 'delta', 'sometext\n moretext'),
+                  ]
+        newhash = self.commitchanges(changes)
+
+        repo = self.repo
+        hg.update(repo, newhash)
+        commands.push(repo.ui, repo)
+        self.assertEqual(len(self.repo), oldlen + 2)
+
+        # verify that both commits are pushed
+        commit1 = self.repo['tip']
+        self.assertEqual(commit1.files(), ['delta', 'gamma'])
+        self.assertFalse(commit1.mutable())
+        commit2 = commit1.parents()[0]
+        self.assertEqual(commit2.files(), ['gamma'])
+        self.assertFalse(commit2.mutable())
+
 
 def suite():
     test_classes = [PushTests, ]