# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-12 22:29:34 # Node ID 00bd72629a457dd2b466e8b56fd0872844aff412 # Parent 338c9d227a9e8e38c4cc90fad8a88f32f342de40 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)