diff tests/test_push_command.py @ 1236:f367a4462191

push: update to branch tip instead of tip We previously updated to the repository tip after pushing a revision, presumably on the assumption that tip would be the last revision we just pushed. This assumption is flawed for high traffic repositories. In particular, you previsouly would sometimes end up on a completley unrelated commit if someone else commits to a different branch in between the time we push a revision and pull it back from the server. This changes to instead update to the branch tip of the branch we were on at the beginning of the push. This should be either the revision we just pushed or a linear descendent of the revision we just pushed, with a fair degree of reliability.
author David Schleimer <dschleimer@fb.com>
date Sat, 30 Aug 2014 09:23:31 -0700
parents 5c2917375961
children f96e2495de39
line wrap: on
line diff
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -754,3 +754,20 @@ class PushTests(test_util.TestBase):
         self.assertEqual(tip['adding_file'].data(), 'fooFirstFile')
         self.assertEqual(tip['newdir/new_file'].data(), 'fooNewFile')
         self.assertEqual(tip.branch(), 'default')
+
+    def test_update_after_push(self):
+        repo = self.repo
+        ui = repo.ui
+
+        ui.setconfig('hooks',
+                     'debug-hgsubversion-between-push-and-pull-for-tests',
+                     lambda ui, repo, hooktype: self.add_svn_rev(
+                         self.repo_path,
+                         {'trunk/racey_file': 'race conditions suck'}))
+
+        self.test_push_to_branch(push=False)
+        commands.push(ui, repo)
+        newctx = self.repo['.']
+        self.assertNotEqual(newctx.node(), self.repo['tip'].node())
+        self.assertEqual(newctx['adding_file'].data(), 'foo')
+        self.assertEqual(newctx.branch(), 'the_branch')