context: inline makememctx (API)
I have always thought it weird that we have a helper method instead of
just using __init__. So, I ripped it out.
--- a/mercurial/cmdutil.py Fri Jun 09 13:39:13 2017 -0700
+++ b/mercurial/cmdutil.py Sat Jun 10 10:24:33 2017 -0400
@@ -1108,11 +1108,13 @@
editor = None
else:
editor = getcommiteditor(editform='import.bypass')
- memctx = context.makememctx(repo, (p1.node(), p2.node()),
+ memctx = context.memctx(repo, (p1.node(), p2.node()),
message,
- user,
- date,
- branch, files, store,
+ files=files,
+ filectxfn=store,
+ user=user,
+ date=date,
+ branch=branch,
editor=editor)
n = memctx.commit()
finally:
--- a/mercurial/context.py Fri Jun 09 13:39:13 2017 -0700
+++ b/mercurial/context.py Sat Jun 10 10:24:33 2017 -0400
@@ -385,24 +385,6 @@
return r
-
-def makememctx(repo, parents, text, user, date, branch, files, store,
- editor=None, extra=None):
- def getfilectx(repo, memctx, path):
- data, mode, copied = store.getfile(path)
- if data is None:
- return None
- islink, isexec = mode
- return memfilectx(repo, path, data, islink=islink, isexec=isexec,
- copied=copied, memctx=memctx)
- if extra is None:
- extra = {}
- if branch:
- extra['branch'] = encoding.fromlocal(branch)
- ctx = memctx(repo, parents, text, files, getfilectx, user,
- date, extra, editor)
- return ctx
-
def _filterederror(repo, changeid):
"""build an exception to be raised about a filtered changeid
@@ -2110,7 +2092,7 @@
_returnnoneformissingfiles = True
def __init__(self, repo, parents, text, files, filectxfn, user=None,
- date=None, extra=None, editor=False):
+ date=None, extra=None, branch=None, editor=False):
super(memctx, self).__init__(repo, text, user, date, extra)
self._rev = None
self._node = None
@@ -2119,10 +2101,14 @@
self._parents = [changectx(self._repo, p) for p in (p1, p2)]
files = sorted(set(files))
self._files = files
+ if branch is not None:
+ self._extra['branch'] = encoding.fromlocal(branch)
self.substate = {}
- # if store is not callable, wrap it in a function
- if not callable(filectxfn):
+ if isinstance(filectxfn, patch.filestore):
+ self._filectxfn = memfilefrompatch(filectxfn)
+ elif not callable(filectxfn):
+ # if store is not callable, wrap it in a function
self._filectxfn = memfilefromctx(filectxfn)
else:
# memoizing increases performance for e.g. vcs convert scenarios.