import: use a less direct approach to store the expected node
This will help later refactoring.
--- a/hgext3rd/evolve/__init__.py Tue Apr 17 15:45:58 2018 +0200
+++ b/hgext3rd/evolve/__init__.py Tue Apr 17 17:58:12 2018 +0200
@@ -880,10 +880,11 @@
@eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
+ expected = {'node': None}
extracted = patch.extract(ui, hunk)
- expected = extracted.get('nodeid')
- if expected is not None:
- expected = node.bin(expected)
+ expectednode = extracted.get('nodeid')
+ if expectednode is not None:
+ expected['node'] = node.bin(expectednode)
oldextract = patch.extract
try:
patch.extract = lambda ui, hunk: extracted
@@ -891,12 +892,12 @@
finally:
patch.extract = oldextract
created = ret[1]
- if (opts['obsolete'] and None not in (created, expected)
- and created != expected):
+ if (opts['obsolete'] and None not in (created, expected['node'])
+ and created != expected['node']):
tr = repo.transaction('import-obs')
try:
metadata = {'user': ui.username()}
- repo.obsstore.create(tr, expected, (created,),
+ repo.obsstore.create(tr, expected['node'], (created,),
metadata=metadata)
tr.close()
finally: