[PATCH 04 of 10] largefiles: use util.readfile in overrides

Bryan O'Sullivan bos at serpentine.com
Tue Jan 12 16:50:07 CST 2016


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1452637774 28800
#      Tue Jan 12 14:29:34 2016 -0800
# Node ID 6525f45dd83f10295f6047a5c2a2648e8d45bbd6
# Parent  05b64240c26293abba48e2795c63eb5633ac3629
largefiles: use util.readfile in overrides

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -967,16 +967,7 @@ def overridearchive(orig, repo, dest, no
 
             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 @@ def hgsubrepoarchive(orig, repo, archive
 
             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)
 


More information about the Mercurial-devel mailing list