import: adapt to fd1dd79cff20
With the latest state of the code, the patch is passed to "import try one" as
parsed.
--- a/hgext3rd/evolve/__init__.py Tue Apr 17 18:10:53 2018 +0200
+++ b/hgext3rd/evolve/__init__.py Tue Apr 17 18:30:56 2018 +0200
@@ -886,17 +886,21 @@
@eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
expected = {'node': None}
- oldextract = patch.extract
+ if not util.safehasattr(hunk, 'get'): # hg < 4.6
+ oldextract = patch.extract
- def extract(*args, **kwargs):
- ret = oldextract(*args, **kwargs)
- _getnodefrompatch(ret, expected)
- return ret
- try:
- patch.extract = extract
+ def extract(*args, **kwargs):
+ ret = oldextract(*args, **kwargs)
+ _getnodefrompatch(ret, expected)
+ return ret
+ try:
+ patch.extract = extract
+ ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
+ finally:
+ patch.extract = oldextract
+ else:
+ _getnodefrompatch(hunk, expected)
ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
- finally:
- patch.extract = oldextract
created = ret[1]
if (opts['obsolete'] and None not in (created, expected['node'])
and created != expected['node']):