From patchwork Tue Jul 21 16:40:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8780: infinitepush: replace `NamedTemporaryFile` with `pycompat.namedtempfile` From: phabricator X-Patchwork-Id: 46824 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 21 Jul 2020 16:40:41 +0000 sheehan created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Fixes a Python 3 compat error when using the external bundle store. REPOSITORY rHG Mercurial BRANCH stable REVISION DETAIL https://phab.mercurial-scm.org/D8780 AFFECTED FILES hgext/infinitepush/store.py CHANGE DETAILS To: sheehan, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py --- a/hgext/infinitepush/store.py +++ b/hgext/infinitepush/store.py @@ -20,8 +20,6 @@ procutil, ) -NamedTemporaryFile = tempfile.NamedTemporaryFile - class BundleWriteException(Exception): pass @@ -142,7 +140,7 @@ # closing it # TODO: rewrite without str.format() and replace NamedTemporaryFile() # with pycompat.namedtempfile() - with NamedTemporaryFile() as temp: + with pycompat.namedtempfile() as temp: temp.write(data) temp.flush() temp.seek(0) @@ -168,9 +166,8 @@ def read(self, handle): # Won't work on windows because you can't open file second time without # closing it - # TODO: rewrite without str.format() and replace NamedTemporaryFile() - # with pycompat.namedtempfile() - with NamedTemporaryFile() as temp: + # TODO: rewrite without str.format() + with pycompat.namedtempfile() as temp: formatted_args = [ arg.format(filename=temp.name, handle=handle) for arg in self.get_args