mercurial/commands.py
changeset 37621 5537d8f5e989
parent 37620 fd1dd79cff20
child 37684 5fc502e149f1
--- a/mercurial/commands.py	Thu Apr 12 23:06:27 2018 -0700
+++ b/mercurial/commands.py	Thu Apr 12 23:14:38 2018 -0700
@@ -3089,11 +3089,10 @@
 
             haspatch = False
             for hunk in patch.split(patchfile):
-                patchdata = patch.extract(ui, hunk)
-
-                msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata,
-                                                      parents, opts,
-                                                      msgs, hg.clean)
+                with patch.extract(ui, hunk) as patchdata:
+                    msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata,
+                                                          parents, opts,
+                                                          msgs, hg.clean)
                 if msg:
                     haspatch = True
                     ui.note(msg + '\n')