Mercurial > public > mercurial-scm > hg-stable
changeset 52593:92dff84829b3
rebase: don't leak a file descriptor when updating an MQ patch
`patch.linereader()` isn't a context manager, rather a simple iterator over a
file descriptor. So let's manage the fd outside of it.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 16 Dec 2024 20:57:01 -0500 |
parents | 2bf9458cede3 |
children | 7108459cc801 |
files | hgext/rebase.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Mon Dec 16 20:52:20 2024 -0500 +++ b/hgext/rebase.py Mon Dec 16 20:57:01 2024 -0500 @@ -1856,9 +1856,11 @@ def isagitpatch(repo, patchname): """Return true if the given patch is in git format""" mqpatch = os.path.join(repo.mq.path, patchname) - for line in patch.linereader(open(mqpatch, 'rb')): - if line.startswith(b'diff --git'): - return True + + with open(mqpatch, 'rb') as fp: + for line in patch.linereader(fp): + if line.startswith(b'diff --git'): + return True return False