##// END OF EJS Templates
context: inline makememctx (API)...
Sean Farley -
r32765:041d976b default
parent child Browse files
Show More
@@ -1108,11 +1108,13 b' def tryimportone(ui, repo, hunk, parents'
1108 editor = None
1108 editor = None
1109 else:
1109 else:
1110 editor = getcommiteditor(editform='import.bypass')
1110 editor = getcommiteditor(editform='import.bypass')
1111 memctx = context.makememctx(repo, (p1.node(), p2.node()),
1111 memctx = context.memctx(repo, (p1.node(), p2.node()),
1112 message,
1112 message,
1113 user,
1113 files=files,
1114 date,
1114 filectxfn=store,
1115 branch, files, store,
1115 user=user,
1116 date=date,
1117 branch=branch,
1116 editor=editor)
1118 editor=editor)
1117 n = memctx.commit()
1119 n = memctx.commit()
1118 finally:
1120 finally:
@@ -385,24 +385,6 b' class basectx(object):'
385
385
386 return r
386 return r
387
387
388
389 def makememctx(repo, parents, text, user, date, branch, files, store,
390 editor=None, extra=None):
391 def getfilectx(repo, memctx, path):
392 data, mode, copied = store.getfile(path)
393 if data is None:
394 return None
395 islink, isexec = mode
396 return memfilectx(repo, path, data, islink=islink, isexec=isexec,
397 copied=copied, memctx=memctx)
398 if extra is None:
399 extra = {}
400 if branch:
401 extra['branch'] = encoding.fromlocal(branch)
402 ctx = memctx(repo, parents, text, files, getfilectx, user,
403 date, extra, editor)
404 return ctx
405
406 def _filterederror(repo, changeid):
388 def _filterederror(repo, changeid):
407 """build an exception to be raised about a filtered changeid
389 """build an exception to be raised about a filtered changeid
408
390
@@ -2110,7 +2092,7 b' class memctx(committablectx):'
2110 _returnnoneformissingfiles = True
2092 _returnnoneformissingfiles = True
2111
2093
2112 def __init__(self, repo, parents, text, files, filectxfn, user=None,
2094 def __init__(self, repo, parents, text, files, filectxfn, user=None,
2113 date=None, extra=None, editor=False):
2095 date=None, extra=None, branch=None, editor=False):
2114 super(memctx, self).__init__(repo, text, user, date, extra)
2096 super(memctx, self).__init__(repo, text, user, date, extra)
2115 self._rev = None
2097 self._rev = None
2116 self._node = None
2098 self._node = None
@@ -2119,10 +2101,14 b' class memctx(committablectx):'
2119 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
2101 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
2120 files = sorted(set(files))
2102 files = sorted(set(files))
2121 self._files = files
2103 self._files = files
2104 if branch is not None:
2105 self._extra['branch'] = encoding.fromlocal(branch)
2122 self.substate = {}
2106 self.substate = {}
2123
2107
2124 # if store is not callable, wrap it in a function
2108 if isinstance(filectxfn, patch.filestore):
2125 if not callable(filectxfn):
2109 self._filectxfn = memfilefrompatch(filectxfn)
2110 elif not callable(filectxfn):
2111 # if store is not callable, wrap it in a function
2126 self._filectxfn = memfilefromctx(filectxfn)
2112 self._filectxfn = memfilefromctx(filectxfn)
2127 else:
2113 else:
2128 # memoizing increases performance for e.g. vcs convert scenarios.
2114 # memoizing increases performance for e.g. vcs convert scenarios.
General Comments 0
You need to be logged in to leave comments. Login now