diff hgext/remotefilelog/debugcommands.py @ 52571:94fa2543d710

remotefilelog: replace a few trivial file reads with the `util` function The one in `shallowutil` is especially important, because the caller may try to delete the file. That generally doesn't work on Windows when the file is open.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 16 Dec 2024 21:18:17 -0500
parents 51df2bf7c40b
children 0e11e532c958
line wrap: on
line diff
--- a/hgext/remotefilelog/debugcommands.py	Mon Dec 16 21:16:30 2024 -0500
+++ b/hgext/remotefilelog/debugcommands.py	Mon Dec 16 21:18:17 2024 -0500
@@ -23,6 +23,7 @@
     lock as lockmod,
     pycompat,
     revlog,
+    util,
 )
 from mercurial.utils import hashutil
 from . import (
@@ -227,11 +228,7 @@
 
 
 def parsefileblob(path, decompress):
-    f = open(path, "rb")
-    try:
-        raw = f.read()
-    finally:
-        f.close()
+    raw = util.readfile(path)
 
     if decompress:
         raw = _decompressblob(raw)