comparison mercurial/merge.py @ 34124:b90e5b2a9c82

merge: flush any deferred writes before, and after, running any workers Since we fork to create workers, any changes they queue up will be lost after the worker terminates, so the easiest solution is to have each worker flush the writes they accumulate--we are close to the end of the merge in any case. To prevent duplicated writes, we also have the master processs flush before forking. In an in-memory merge (M2), we'll instead disable the use of workers. Differential Revision: https://phab.mercurial-scm.org/D628
author Phil Cohen <phillco@fb.com>
date Mon, 11 Sep 2017 13:03:27 -0700
parents c0ce60459d84
children 57dc78d757ff
comparison
equal deleted inserted replaced
34123:9c07cff039bc 34124:b90e5b2a9c82
1124 # Print a warning if cwd was deleted 1124 # Print a warning if cwd was deleted
1125 repo.ui.warn(_("current directory was removed\n" 1125 repo.ui.warn(_("current directory was removed\n"
1126 "(consider changing to repo root: %s)\n") % 1126 "(consider changing to repo root: %s)\n") %
1127 repo.root) 1127 repo.root)
1128 1128
1129 # It's necessary to flush here in case we're inside a worker fork and will
1130 # quit after this function.
1131 wctx.flushall()
1132
1129 def batchget(repo, mctx, wctx, actions): 1133 def batchget(repo, mctx, wctx, actions):
1130 """apply gets to the working directory 1134 """apply gets to the working directory
1131 1135
1132 mctx is the context to get from 1136 mctx is the context to get from
1133 1137
1158 yield i, f 1162 yield i, f
1159 i = 0 1163 i = 0
1160 i += 1 1164 i += 1
1161 if i > 0: 1165 if i > 0:
1162 yield i, f 1166 yield i, f
1167
1168 # It's necessary to flush here in case we're inside a worker fork and will
1169 # quit after this function.
1170 wctx.flushall()
1163 1171
1164 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): 1172 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
1165 """apply the merge action list to the working directory 1173 """apply the merge action list to the working directory
1166 1174
1167 wctx is the working copy context 1175 wctx is the working copy context
1226 actions['r']) 1234 actions['r'])
1227 for i, item in prog: 1235 for i, item in prog:
1228 z += i 1236 z += i
1229 progress(_updating, z, item=item, total=numupdates, unit=_files) 1237 progress(_updating, z, item=item, total=numupdates, unit=_files)
1230 removed = len(actions['r']) 1238 removed = len(actions['r'])
1239
1240 # We should flush before forking into worker processes, since those workers
1241 # flush when they complete, and we don't want to duplicate work.
1242 wctx.flushall()
1231 1243
1232 # get in parallel 1244 # get in parallel
1233 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx), 1245 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx),
1234 actions['g']) 1246 actions['g'])
1235 for i, item in prog: 1247 for i, item in prog: