# HG changeset patch # User Matt Harbison # Date 1734400862 18000 # Node ID 7108459cc8012541a9880b1a11717995f5c9d91a # Parent 92dff84829b3fc50b317d0e7f250cdd5275accad releasenotes: replace a few trivial file reads/writes with `util` functions diff -r 92dff84829b3 -r 7108459cc801 hgext/releasenotes.py --- a/hgext/releasenotes.py Mon Dec 16 20:57:01 2024 -0500 +++ b/hgext/releasenotes.py Mon Dec 16 21:01:02 2024 -0500 @@ -683,15 +683,13 @@ return ui.write(serializenotes(sections, incoming)) try: - with open(file_, 'rb') as fh: - notes = parsereleasenotesfile(sections, fh.read()) + notes = parsereleasenotesfile(sections, util.readfile(file_)) except FileNotFoundError: notes = parsedreleasenotes() notes.merge(ui, incoming) - with open(file_, 'wb') as fh: - fh.write(serializenotes(sections, notes)) + util.writefile(file_, serializenotes(sections, notes)) @command(b'debugparsereleasenotes', norepo=True) @@ -700,8 +698,7 @@ if path == b'-': text = procutil.stdin.read() else: - with open(path, 'rb') as fh: - text = fh.read() + text = util.readfile(path) sections = releasenotessections(ui, repo)