1341 # 'postimport' are run after the commit is made and are provided the following |
1341 # 'postimport' are run after the commit is made and are provided the following |
1342 # argument: |
1342 # argument: |
1343 # - ctx: the changectx created by import. |
1343 # - ctx: the changectx created by import. |
1344 extrapostimportmap = {} |
1344 extrapostimportmap = {} |
1345 |
1345 |
1346 def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc): |
1346 def tryimportone(ui, repo, patchdata, parents, opts, msgs, updatefunc): |
1347 """Utility function used by commands.import to import a single patch |
1347 """Utility function used by commands.import to import a single patch |
1348 |
1348 |
1349 This function is explicitly defined here to help the evolve extension to |
1349 This function is explicitly defined here to help the evolve extension to |
1350 wrap this part of the import logic. |
1350 wrap this part of the import logic. |
1351 |
1351 |
1352 The API is currently a bit ugly because it a simple code translation from |
1352 The API is currently a bit ugly because it a simple code translation from |
1353 the import command. Feel free to make it better. |
1353 the import command. Feel free to make it better. |
1354 |
1354 |
1355 :hunk: a patch (as a binary string) |
1355 :patchdata: a dictionary containing parsed patch data (such as from |
|
1356 ``patch.extract()``) |
1356 :parents: nodes that will be parent of the created commit |
1357 :parents: nodes that will be parent of the created commit |
1357 :opts: the full dict of option passed to the import command |
1358 :opts: the full dict of option passed to the import command |
1358 :msgs: list to save commit message to. |
1359 :msgs: list to save commit message to. |
1359 (used in case we need to save it when failing) |
1360 (used in case we need to save it when failing) |
1360 :updatefunc: a function that update a repo to a given node |
1361 :updatefunc: a function that update a repo to a given node |
1361 updatefunc(<repo>, <node>) |
1362 updatefunc(<repo>, <node>) |
1362 """ |
1363 """ |
1363 # avoid cycle context -> subrepo -> cmdutil |
1364 # avoid cycle context -> subrepo -> cmdutil |
1364 from . import context |
1365 from . import context |
1365 extractdata = patch.extract(ui, hunk) |
1366 |
1366 tmpname = extractdata.get('filename') |
1367 tmpname = patchdata.get('filename') |
1367 message = extractdata.get('message') |
1368 message = patchdata.get('message') |
1368 user = opts.get('user') or extractdata.get('user') |
1369 user = opts.get('user') or patchdata.get('user') |
1369 date = opts.get('date') or extractdata.get('date') |
1370 date = opts.get('date') or patchdata.get('date') |
1370 branch = extractdata.get('branch') |
1371 branch = patchdata.get('branch') |
1371 nodeid = extractdata.get('nodeid') |
1372 nodeid = patchdata.get('nodeid') |
1372 p1 = extractdata.get('p1') |
1373 p1 = patchdata.get('p1') |
1373 p2 = extractdata.get('p2') |
1374 p2 = patchdata.get('p2') |
1374 |
1375 |
1375 nocommit = opts.get('no_commit') |
1376 nocommit = opts.get('no_commit') |
1376 importbranch = opts.get('import_branch') |
1377 importbranch = opts.get('import_branch') |
1377 update = not opts.get('bypass') |
1378 update = not opts.get('bypass') |
1378 strip = opts["strip"] |
1379 strip = opts["strip"] |
1460 else: |
1461 else: |
1461 editor = getcommiteditor(editform=editform, |
1462 editor = getcommiteditor(editform=editform, |
1462 **pycompat.strkwargs(opts)) |
1463 **pycompat.strkwargs(opts)) |
1463 extra = {} |
1464 extra = {} |
1464 for idfunc in extrapreimport: |
1465 for idfunc in extrapreimport: |
1465 extrapreimportmap[idfunc](repo, extractdata, extra, opts) |
1466 extrapreimportmap[idfunc](repo, patchdata, extra, opts) |
1466 overrides = {} |
1467 overrides = {} |
1467 if partial: |
1468 if partial: |
1468 overrides[('ui', 'allowemptycommit')] = True |
1469 overrides[('ui', 'allowemptycommit')] = True |
1469 with repo.ui.configoverride(overrides, 'import'): |
1470 with repo.ui.configoverride(overrides, 'import'): |
1470 n = repo.commit(message, user, |
1471 n = repo.commit(message, user, |