changeset 27772:00bd72629a45

largefiles: use util.readfile in overrides
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 12 Jan 2016 14:29:34 -0800
parents 338c9d227a9e
children bf45edfa9d90
files hgext/largefiles/overrides.py
diffstat 1 files changed, 2 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Tue Jan 12 14:28:43 2016 -0800
+++ b/hgext/largefiles/overrides.py	Tue Jan 12 14:29:34 2016 -0800
@@ -967,16 +967,7 @@
 
             f = lfutil.splitstandin(f)
 
-            def getdatafn():
-                fd = None
-                try:
-                    fd = open(path, 'rb')
-                    return fd.read()
-                finally:
-                    if fd:
-                        fd.close()
-
-            getdata = getdatafn
+            getdata = lambda: util.readfile(path)
         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
 
     if subrepos:
@@ -1024,16 +1015,7 @@
 
             f = lfutil.splitstandin(f)
 
-            def getdatafn():
-                fd = None
-                try:
-                    fd = open(os.path.join(prefix, path), 'rb')
-                    return fd.read()
-                finally:
-                    if fd:
-                        fd.close()
-
-            getdata = getdatafn
+            getdata = lambda: util.readfile(os.path.join(prefix, path))
 
         write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)