This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfd1dd79cff20: cmdutil: pass in parsed patch to 
tryimportone() (API) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3305?vs=8106&id=8110

REVISION DETAIL
  https://phab.mercurial-scm.org/D3305

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

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')
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1343,16 +1343,17 @@
 # - 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
     wrap this part of the import logic.
 
     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



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to