Mercurial > evolve
changeset 3672:f4d5ef9ba074
import: grab the expected node value on the fly
We no longer parse the patch beforehand this will reduce inconsistency with
newer API.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 17 Apr 2018 18:10:53 +0200 |
parents | c82f0d5740b4 |
children | 9c12b6520a20 |
files | hgext3rd/evolve/__init__.py |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Tue Apr 17 17:58:12 2018 +0200 +++ b/hgext3rd/evolve/__init__.py Tue Apr 17 18:10:53 2018 +0200 @@ -878,16 +878,22 @@ _('mark the old node as obsoleted by ' 'the created commit'))) +def _getnodefrompatch(patch, dest): + patchnode = patch.get('nodeid') + if patchnode is not None: + dest['node'] = node.bin(patchnode) + @eh.wrapfunction(mercurial.cmdutil, 'tryimportone') def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs): expected = {'node': None} - extracted = patch.extract(ui, hunk) - expectednode = extracted.get('nodeid') - if expectednode is not None: - expected['node'] = node.bin(expectednode) oldextract = patch.extract + + def extract(*args, **kwargs): + ret = oldextract(*args, **kwargs) + _getnodefrompatch(ret, expected) + return ret try: - patch.extract = lambda ui, hunk: extracted + patch.extract = extract ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs) finally: patch.extract = oldextract