# HG changeset patch # User Augie Fackler # Date 2013-11-07 03:09:15 # Node ID cd79d9ab5e423f8962abded97b16ff21b887d363 # Parent 1e5b38a919dd460ec7602dbd7c5d33bbdd008fb1 makememctx: move from patch to context to break import cycle diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3761,12 +3761,12 @@ def import_(ui, repo, patch1=None, *patc files, eolmode=None) except patch.PatchError, e: raise util.Abort(str(e)) - memctx = patch.makememctx(repo, (p1.node(), p2.node()), - message, - opts.get('user') or user, - opts.get('date') or date, - branch, files, store, - editor=cmdutil.commiteditor) + memctx = context.makememctx(repo, (p1.node(), p2.node()), + message, + opts.get('user') or user, + opts.get('date') or date, + branch, files, store, + editor=cmdutil.commiteditor) repo.savecommitmessage(memctx.description()) n = memctx.commit() finally: diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -195,6 +195,21 @@ class basectx(object): def dirty(self): return False +def makememctx(repo, parents, text, user, date, branch, files, store, + editor=None): + def getfilectx(repo, memctx, path): + data, (islink, isexec), copied = store.getfile(path) + return memfilectx(path, data, islink=islink, isexec=isexec, + copied=copied) + extra = {} + if branch: + extra['branch'] = encoding.fromlocal(branch) + ctx = memctx(repo, parents, text, files, getfilectx, user, + date, extra) + if editor: + ctx._text = editor(repo, ctx, []) + return ctx + class changectx(basectx): """A changecontext object makes access to data related to a particular changeset convenient. It represents a read-only context already present in diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -16,7 +16,6 @@ import email.Parser from i18n import _ from node import hex, short import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error -import context gitre = re.compile('diff --git a/(.*) b/(.*)') @@ -1441,21 +1440,6 @@ def patchrepo(ui, repo, ctx, store, patc backend = repobackend(ui, repo, ctx, store) return patchbackend(ui, backend, patchobj, strip, files, eolmode) -def makememctx(repo, parents, text, user, date, branch, files, store, - editor=None): - def getfilectx(repo, memctx, path): - data, (islink, isexec), copied = store.getfile(path) - return context.memfilectx(path, data, islink=islink, isexec=isexec, - copied=copied) - extra = {} - if branch: - extra['branch'] = encoding.fromlocal(branch) - ctx = context.memctx(repo, parents, text, files, getfilectx, user, - date, extra) - if editor: - ctx._text = editor(repo, ctx, []) - return ctx - def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict', similarity=0): """Apply to the working directory.