changeset 1539:0ebcc5bbf692

tests: when making a `memctx`, make sure to use a single repo instance The way self.repo is dynamic produces bad lock behavior because the `context.memctx` ends up with a different instance than self in `localrepo.commitctx`, which means the callbacks in the `memctx` get an unlocked repo instance. This causes lock warning failures. When it's not a code freeze for core, we should probably: * Make lock failures hard, not just warnings * Stop holding a repo reference in memctx, or otherwise check it's the same instance as `self` during `localrepo.commitctx` That's my best guess based on the (very hard to debug) test failures here.
author Augie Fackler <raf@durin42.com>
date Sat, 28 Oct 2017 21:34:52 -0400
parents b0eca4d96a53
children c0fc42713ecb
files tests/test_push_command.py tests/test_single_dir_push.py tests/test_utility_commands.py
diffstat 3 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -277,16 +277,17 @@ class PushTests(test_util.TestBase):
                                               isexec=False,
                                               copied=False)
         oldtiphash = self.repo['default'].node()
-        ctx = context.memctx(self.repo,
-                             (self.repo[0].node(), revlog.nullid,),
+        lr = self.repo
+        ctx = context.memctx(lr,
+                             (lr[0].node(), revlog.nullid,),
                              'automated test',
                              ['gamma', ],
                              filectxfn,
                              'testy',
                              '2008-12-21 16:32:00 -0500',
                              {'branch': 'localbranch', })
-        newhash = self.repo.commitctx(ctx)
-        ctx = context.memctx(self.repo,
+        newhash = lr.commitctx(ctx)
+        ctx = context.memctx(lr,
                              (newhash, revlog.nullid),
                              'automated test2',
                              ['delta', ],
@@ -294,7 +295,7 @@ class PushTests(test_util.TestBase):
                              'testy',
                              '2008-12-21 16:32:00 -0500',
                              {'branch': 'localbranch', })
-        newhash = self.repo.commitctx(ctx)
+        newhash = lr.commitctx(ctx)
         repo = self.repo
         hg.update(repo, newhash)
         commands.push(repo.ui, repo)
--- a/tests/test_single_dir_push.py
+++ b/tests/test_single_dir_push.py
@@ -186,15 +186,16 @@ class TestSingleDirPush(test_util.TestBa
                                                   isexec=False,
                                                   copied=False)
             raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
-        ctx = context.memctx(self.repo,
-                             (self.repo['tip'].node(), node.nullid),
+        lr = self.repo
+        ctx = context.memctx(lr,
+                             (lr['tip'].node(), node.nullid),
                              'automated test',
                              ['adding_file'],
                              file_callback,
                              'an_author',
                              '2009-10-19 18:49:30 -0500',
                              {'branch': 'default', })
-        self.repo.commitctx(ctx)
+        lr.commitctx(ctx)
         hg.update(self.repo, self.repo['tip'].node())
         self.pushrevisions()
         self.assertTrue('adding_file' in test_util.svnls(repo_path, ''))
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -167,7 +167,8 @@ class UtilityTests(test_util.TestBase):
                                               islink=False,
                                               isexec=False,
                                               copied=False)
-        ctx = context.memctx(self.repo,
+        lr = self.repo
+        ctx = context.memctx(lr,
                              parents,
                              'automated test',
                              ['added_bogus_file', 'other_added_file', ],
@@ -175,7 +176,7 @@ class UtilityTests(test_util.TestBase):
                              'testy',
                              '2008-12-21 16:32:00 -0500',
                              {'branch': 'localbranch', })
-        new = self.repo.commitctx(ctx)
+        new = lr.commitctx(ctx)
         hg.update(self.repo, new)
         wrappers.parents(lambda x, y: None, u, self.repo, svn=True)
         actual = u.popbuffer()
@@ -211,7 +212,8 @@ class UtilityTests(test_util.TestBase):
                                               islink=False,
                                               isexec=False,
                                               copied=False)
-        ctx = context.memctx(self.repo,
+        lr = self.repo
+        ctx = context.memctx(lr,
                              parents,
                              'automated test',
                              ['added_bogus_file', 'other_added_file', ],
@@ -219,7 +221,7 @@ class UtilityTests(test_util.TestBase):
                              'testy',
                              '2008-12-21 16:32:00 -0500',
                              {'branch': 'localbranch', })
-        new = self.repo.commitctx(ctx)
+        new = lr.commitctx(ctx)
         hg.update(self.repo, new)
         u.pushbuffer()
         commands.outgoing(u, self.repo, repourl(repo_path))
@@ -242,7 +244,8 @@ class UtilityTests(test_util.TestBase):
                                               islink=False,
                                               isexec=False,
                                               copied=False)
-        ctx = context.memctx(self.repo,
+        lr = self.repo
+        ctx = context.memctx(lr,
                              parents,
                              'automated test',
                              ['added_bogus_file', 'other_added_file', ],
@@ -250,7 +253,7 @@ class UtilityTests(test_util.TestBase):
                              'testy',
                              '2008-12-21 16:32:00 -0500',
                              {'branch': 'localbranch', })
-        self.repo.commitctx(ctx)
+        lr.commitctx(ctx)
         self.assertEqual(self.repo['tip'].branch(), 'localbranch')
         beforerebasehash = self.repo['tip'].node()
         hg.update(self.repo, 'tip')