changeset 52565:d3d1fd3b8a9d

mq: don't leak a file descriptor when reading a patch header
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 16 Dec 2024 20:45:49 -0500
parents 7da165194128
children 2bf9458cede3
files hgext/mq.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Dec 16 20:44:05 2024 -0500
+++ b/hgext/mq.py	Mon Dec 16 20:45:49 2024 -0500
@@ -319,8 +319,8 @@
         nodeid = None
         diffstart = 0
 
-        if True:
-            for line in open(pf, 'rb'):
+        with open(pf, 'rb') as fp:
+            for line in fp:
                 line = line.rstrip()
                 if line.startswith(b'diff --git') or (
                     diffstart and line.startswith(b'+++ ')