# HG changeset patch # User Augie Fackler # Date 1240623077 18000 # Node ID 3848a7f9b9837107bad047c55f41f53a83a8c2c1 # Parent b45bae16be32b829ae2d07dbd24fb48ba7a6bca9 push: Add a test that demonstrates base-text detection works diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -8,6 +8,7 @@ from mercurial import hg from mercurial import node from mercurial import ui from mercurial import revlog +from mercurial import util as hgutil import wrappers import test_util @@ -404,6 +405,23 @@ class PushTests(test_util.TestBase): self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) self.assertEqual(tip['alpha'].flags(), '') + def test_push_outdated_base_text(self): + self.test_push_two_revs() + changes = [('adding_file', 'adding_file', 'different_content', ), + ] + self.commitchanges(changes, parent='tip') + self.pushrevisions() + changes = [('adding_file', 'adding_file', + 'even_more different_content', ), + ] + self.commitchanges(changes, parent=3) + try: + self.pushrevisions() + assert False, 'This should have aborted!' + except hgutil.Abort, e: + self.assertEqual(e.args[0], + 'Base text was out of date, maybe rebase?') + def suite(): test_classes = [PushTests, PushOverSvnserveTests] diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -140,7 +140,7 @@ class TestBase(unittest.TestCase): entries.sort() return entries - def commitchanges(self, changes): + def commitchanges(self, changes, parent='tip'): """Commit changes to mercurial directory 'changes' is a sequence of tuples (source, dest, data). It can look @@ -153,7 +153,7 @@ class TestBase(unittest.TestCase): - (source, None, None) to remove source. """ repo = self.repo - parentctx = repo['tip'] + parentctx = repo[parent] changed, removed = [], [] for source, dest, newdata in changes: @@ -187,7 +187,7 @@ class TestBase(unittest.TestCase): '2008-10-07 20:59:48 -0500') nodeid = repo.commitctx(ctx) repo = self.repo - hg.update(repo, nodeid) + hg.clean(repo, nodeid) return nodeid def assertchanges(self, changes, ctx):