diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -496,6 +496,12 @@
         repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
                        'for %s\n') % (tool, fcd.path()))
         return False, 1, None
+
+    # Must flush any deferred contents if running a merge tool.
+    from . import context
+    if isinstance(wctx, context.overlayworkingctx):
+        wctx.flushall()
+
     unused, unused, unused, back = files
     a = _workingpath(repo, fcd)
     b, c = _maketempfiles(repo, fco, fca)