Patchwork [2,of,5] simplemerge: add optional context parameters to simplemerge

login
register
mail settings
Submitter Phillip Cohen
Date Jan. 1, 1970, 12:03 a.m.
Message ID <282b1d2e4df6061d3f91.192@phillco-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/21949/
State Superseded
Headers show

Comments

Phillip Cohen - Jan. 1, 1970, 12:03 a.m.
# HG changeset patch
# User Phil Cohen <phillco@fb.com>
# Date 2177 28800
#      Wed Dec 31 16:36:17 1969 -0800
# Node ID 282b1d2e4df6061d3f91ed521c563e5b29da57c0
# Parent  c33a1225fcbc5cc2c13391fe4f72d329abbe6129
simplemerge: add optional context parameters to simplemerge

Rename the existing parameters for clarity.

These will, in subsequent patches, allow callers to redirect reads (of the
three sides of the merge) and writes (of the result) to the given contexts,
instead of using the filesystem.

While in most cases, the writes will go to a workingfilectx, this opens the
door for it to be a memfilectx in the case of an in-memory merge.

Repo will be necessary in a subsequent comit.

Patch

diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -407,7 +407,8 @@ 
             raise error.Abort(msg)
     return text
 
-def simplemerge(ui, local, base, other, **opts):
+def simplemerge(ui, localfile, basefile, otherfile,
+                localctx=None, basectx=None, otherctx=None, repo=None, **opts):
     def readfile(filename):
         f = open(filename, "rb")
         text = f.read()
@@ -420,8 +421,8 @@ 
         name_b = None
         name_base = None
     else:
-        name_a = local
-        name_b = other
+        name_a = localfile
+        name_b = otherfile
         name_base = None
         labels = opts.get('label', [])
         if len(labels) > 0:
@@ -434,16 +435,16 @@ 
             raise error.Abort(_("can only specify three labels."))
 
     try:
-        localtext = readfile(local)
-        basetext = readfile(base)
-        othertext = readfile(other)
+        localtext = readfile(localfile)
+        basetext = readfile(basefile)
+        othertext = readfile(otherfile)
     except error.Abort:
         return 1
 
-    local = os.path.realpath(local)
+    localfile = os.path.realpath(localfile)
     if not opts.get('print'):
-        opener = vfsmod.vfs(os.path.dirname(local))
-        out = opener(os.path.basename(local), "w", atomictemp=True)
+        opener = vfsmod.vfs(os.path.dirname(localfile))
+        out = opener(os.path.basename(localfile), "w", atomictemp=True)
     else:
         out = ui.fout