From 19ef3a084140513902c74c061eeb6c2f91154ba0 Mon Sep 17 00:00:00 2001 From: Phil Cohen Date: Sun, 13 Aug 2017 20:06:52 -0700 Subject: [PATCH] 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. Differential Revision: https://phab.mercurial-scm.org/D372 --- mercurial/simplemerge.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py index 6e75fd5e52..ac0ea199b9 100644 --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -408,7 +408,8 @@ def _verifytext(text, path, ui, opts): 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() @@ -421,8 +422,8 @@ def simplemerge(ui, local, base, other, **opts): 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: @@ -435,16 +436,16 @@ def simplemerge(ui, local, base, other, **opts): 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