Patchwork [3,of,7] util: stop using readfile() in tempfilter()

login
register
mail settings
Submitter Yuya Nishihara
Date March 25, 2018, 3:36 a.m.
Message ID <dd177967cc70361c854a.1521948977@mimosa>
Download mbox | patch
Permalink /patch/29833/
State Accepted
Headers show

Comments

Yuya Nishihara - March 25, 2018, 3:36 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521869554 -32400
#      Sat Mar 24 14:32:34 2018 +0900
# Node ID dd177967cc70361c854ac5b59672c1c903a11c7c
# Parent  4bd2d19ecff7aa5ce3ce695427a478b9d3be9ff1
util: stop using readfile() in tempfilter()

To unblock code move to utils.*. It's merely two lines of very Pythonic code.
No helper function should be needed.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1528,7 +1528,8 @@  def tempfilter(s, cmd):
         if code:
             raise error.Abort(_("command '%s' failed: %s") %
                               (cmd, explainexit(code)))
-        return readfile(outname)
+        with open(outname, 'rb') as fp:
+            return fp.read()
     finally:
         try:
             if inname: