import: use a less direct approach to store the expected node
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 17 Apr 2018 17:58:12 +0200
changeset 3671 c82f0d5740b4
parent 3670 1043e9c54355
child 3672 f4d5ef9ba074
import: use a less direct approach to store the expected node This will help later refactoring.
hgext3rd/evolve/__init__.py
--- 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: