Mercurial > hg
diff hgext/largefiles/proto.py @ 25079:bee00e0c2e45
largefiles: use try/except/finally
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 15 May 2015 09:55:15 -0500 |
parents | 70252bdfd39c |
children | 328739ea70c3 |
line wrap: on
line diff
--- a/hgext/largefiles/proto.py Fri May 15 09:54:56 2015 -0500 +++ b/hgext/largefiles/proto.py Fri May 15 09:55:15 2015 -0500 @@ -31,17 +31,16 @@ tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) try: - try: - proto.getfile(tmpfp) - tmpfp._fp.seek(0) - if sha != lfutil.hexsha1(tmpfp._fp): - raise IOError(0, _('largefile contents do not match hash')) - tmpfp.close() - lfutil.linktousercache(repo, sha) - except IOError, e: - repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % - (sha, e.strerror)) - return wireproto.pushres(1) + proto.getfile(tmpfp) + tmpfp._fp.seek(0) + if sha != lfutil.hexsha1(tmpfp._fp): + raise IOError(0, _('largefile contents do not match hash')) + tmpfp.close() + lfutil.linktousercache(repo, sha) + except IOError, e: + repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % + (sha, e.strerror)) + return wireproto.pushres(1) finally: tmpfp.discard()