Patchwork [1,of,6] merge: pass wctx to batchremove and batchget

login
register
mail settings
Submitter Phillip Cohen
Date June 26, 2017, 5:36 a.m.
Message ID <4153ee913fcbcc4465c0.1498455361@phillco-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/21723/
State Accepted
Headers show

Comments

Phillip Cohen - June 26, 2017, 5:36 a.m.
# HG changeset patch
# User Phil Cohen <phillco@fb.com>
# Date 1498435009 25200
#      Sun Jun 25 16:56:49 2017 -0700
# Node ID 4153ee913fcbcc4465c09a7b39d0520252b3e0a7
# Parent  c6eb0d49ae8fa4ff00859bce37253225d4ecbba7
merge: pass wctx to batchremove and batchget

We would like to migrate direct calls of repo.wvfs/wwrite/wread/etc to a
call on the relevant workingfilectx, both as a cleanup (to reduce the number of
working copy functions on `repo`), and also to facilitate an in-memory merge
that doesn't write to the working copy.

In order to do that, the first step is to ensure we pass the target wctx around
and perform our writes and reads on it. Later, this object might become a
memctx.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1078,7 +1078,7 @@ 
 
     return actions, diverge, renamedelete
 
-def batchremove(repo, actions):
+def batchremove(repo, wctx, actions):
     """apply removes to the working directory
 
     yields tuples for progress updates
@@ -1122,7 +1122,7 @@ 
                            "(consider changing to repo root: %s)\n") %
                          repo.root)
 
-def batchget(repo, mctx, actions):
+def batchget(repo, mctx, wctx, actions):
     """apply gets to the working directory
 
     mctx is the context to get from
@@ -1222,14 +1222,16 @@ 
 
     # remove in parallel (must come first)
     z = 0
-    prog = worker.worker(repo.ui, 0.001, batchremove, (repo,), actions['r'])
+    prog = worker.worker(repo.ui, 0.001, batchremove, (repo, wctx),
+                         actions['r'])
     for i, item in prog:
         z += i
         progress(_updating, z, item=item, total=numupdates, unit=_files)
     removed = len(actions['r'])
 
     # get in parallel
-    prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx), actions['g'])
+    prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx, wctx),
+                         actions['g'])
     for i, item in prog:
         z += i
         progress(_updating, z, item=item, total=numupdates, unit=_files)