# HG changeset patch # User Pierre-Yves David # Date 1523981453 -7200 # Node ID f4d5ef9ba074bf38610baf7a0492c2a3d8cc9342 # Parent c82f0d5740b4955606301ff8f5a4e09f7718379b import: grab the expected node value on the fly We no longer parse the patch beforehand this will reduce inconsistency with newer API. diff -r c82f0d5740b4 -r f4d5ef9ba074 hgext3rd/evolve/__init__.py --- 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