import: handle patch with no node information stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 14 Aug 2014 15:17:02 -0700
branchstable
changeset 1055 cfe1b9d3e5d9
parent 1054 93e920feff5e
child 1056 edfb9a0ad085
child 1057 168dfc839eca
import: handle patch with no node information patch created by old Mercurial version or other tool have no node information. We cannot create marker in this case.
hgext/evolve.py
--- a/hgext/evolve.py	Thu Aug 14 15:14:18 2014 -0700
+++ b/hgext/evolve.py	Thu Aug 14 15:17:02 2014 -0700
@@ -933,7 +933,8 @@
 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
     extracted = patch.extract(ui, hunk)
     expected = extracted[5]
-    expected = node.bin(expected)
+    if extracted is not None:
+        expected = node.bin(expected)
     oldextract = patch.extract
     try:
         patch.extract = lambda ui, hunk: extracted
@@ -941,7 +942,8 @@
     finally:
         patch.extract = oldextract
     created = ret[1]
-    if opts['obsolete'] and created is not None and created != expected:
+    if (opts['obsolete'] and None not in (created, expected)
+        and created != expected):
             tr = repo.transaction('import-obs')
             try:
                 metadata = {'user': ui.username()}