Patchwork D628: merge: flush any deferred writes before, and after, running any workers

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2017, 4:32 p.m.
Message ID <e08bf9cb0dd4883fec9d26c0ff8611db@localhost.localdomain>
Download mbox | patch
Permalink /patch/23726/
State Not Applicable
Headers show

Comments

phabricator - Sept. 7, 2017, 4:32 p.m.
phillco updated this revision to Diff 1669.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D628?vs=1609&id=1669

REVISION DETAIL
  https://phab.mercurial-scm.org/D628

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1109,6 +1109,10 @@ 
 
     _warnifmissingcwd(repo, cwd)
 
+    # It's necessary to flush here in case we're inside a worker fork and will
+    # quit after this function.
+    _flushifdeferred(wctx)
+
 def batchget(repo, mctx, wctx, actions):
     """apply gets to the working directory
 
@@ -1144,6 +1148,10 @@ 
     if i > 0:
         yield i, f
 
+    # It's necessary to flush here in case we're inside a worker fork and will
+    # quit after this function.
+    _flushifdeferred(wctx)
+
 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
     """apply the merge action list to the working directory
 
@@ -1212,6 +1220,10 @@ 
         progress(_updating, z, item=item, total=numupdates, unit=_files)
     removed = len(actions['r'])
 
+    # We should flush before forking into worker processes, since those workers
+    # flush when they complete, and we don't want to duplicate work.
+    _flushifdeferred(wctx)
+
     # get in parallel
     prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx),
                          actions['g'])
@@ -1742,6 +1754,14 @@ 
         copies.duplicatecopies(repo, ctx.rev(), pctx.rev())
     return stats
 
+def _flushifdeferred(ctx):
+    """If ``ctx`` is an overlayworkingctx and queuing any writes, flushes those
+    to disk. Otherwise no-ops.
+    """
+    from . import context
+    if isinstance(ctx, context.overlayworkingctx):
+        ctx.flushall()
+
 def _getcwd():
     try:
         return pycompat.getcwd()