diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1343,7 +1343,7 @@ # - ctx: the changectx created by import. extrapostimportmap = {} -def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc): +def tryimportone(ui, repo, patchdata, parents, opts, msgs, updatefunc): """Utility function used by commands.import to import a single patch This function is explicitly defined here to help the evolve extension to @@ -1352,7 +1352,8 @@ The API is currently a bit ugly because it a simple code translation from the import command. Feel free to make it better. - :hunk: a patch (as a binary string) + :patchdata: a dictionary containing parsed patch data (such as from + ``patch.extract()``) :parents: nodes that will be parent of the created commit :opts: the full dict of option passed to the import command :msgs: list to save commit message to. @@ -1362,15 +1363,15 @@ """ # avoid cycle context -> subrepo -> cmdutil from . import context - extractdata = patch.extract(ui, hunk) - tmpname = extractdata.get('filename') - message = extractdata.get('message') - user = opts.get('user') or extractdata.get('user') - date = opts.get('date') or extractdata.get('date') - branch = extractdata.get('branch') - nodeid = extractdata.get('nodeid') - p1 = extractdata.get('p1') - p2 = extractdata.get('p2') + + tmpname = patchdata.get('filename') + message = patchdata.get('message') + user = opts.get('user') or patchdata.get('user') + date = opts.get('date') or patchdata.get('date') + branch = patchdata.get('branch') + nodeid = patchdata.get('nodeid') + p1 = patchdata.get('p1') + p2 = patchdata.get('p2') nocommit = opts.get('no_commit') importbranch = opts.get('import_branch') @@ -1462,7 +1463,7 @@ **pycompat.strkwargs(opts)) extra = {} for idfunc in extrapreimport: - extrapreimportmap[idfunc](repo, extractdata, extra, opts) + extrapreimportmap[idfunc](repo, patchdata, extra, opts) overrides = {} if partial: overrides[('ui', 'allowemptycommit')] = True diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3089,9 +3089,11 @@ haspatch = False for hunk in patch.split(patchfile): - (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, - parents, opts, - msgs, hg.clean) + patchdata = patch.extract(ui, hunk) + + msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata, + parents, opts, + msgs, hg.clean) if msg: haspatch = True ui.note(msg + '\n')