largefiles: use util.readfile in overrides
authorBryan O'Sullivan <bryano@fb.com>
Tue, 12 Jan 2016 14:29:34 -0800
changeset 27772 00bd72629a45
parent 27771 338c9d227a9e
child 27773 bf45edfa9d90
largefiles: use util.readfile in overrides
hgext/largefiles/overrides.py
--- 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)