{"thread":{"id":"51572","subject":"[PATCH 0/1] git-p4: auto-delete named temporary file","startedAt":"2019-08-01T21:39:13Z","lastAt":"2019-10-06T02:43:19Z","messageCount":12,"participants":["Philip McGraw via GitGitGadget","Andrey","Git Gadget","Junio C Hamano","Andrey Mazo","Luke Diamand","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"379780","messageId":"pull.303.git.gitgitgadget@gmail.com","threadId":"51572","inReplyTo":null,"subject":"[PATCH 0/1] git-p4: auto-delete named temporary file","fromName":"Philip McGraw via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-01T21:39:10Z","receivedAt":"2019-08-01T21:39:13Z","isPatch":true,"sender":{"key":"philip.mcgraw@bentley.com","avatar":"https://avatars.githubusercontent.com/u/18532989?v=4"},"body":"Take new approach using the NamedTemporaryFile() file-like object as input\nto the ZipFile() which auto-deletes after implicit close leaving with scope.\n\nOriginal code produced double-open problems on Windows platform from using\nalready open NamedTemporaryFile() generated filename instead of object.\n\nThanks to Andrey for patiently suggesting several iterations on this change\nfor avoiding exceptions!\n\nAlso print error details after resulting IOError to make debugging cause of\nexception less mysterious when it has nothing to do with \"git version recent\nenough.\"\n\nSigned-off-by: Philip.McGraw Philip.McGraw@bentley.com\n[Philip.McGraw@bentley.com]\n\nPhilip.McGraw (1):\n  git-p4: auto-delete named temporary file\n\n git-p4.py | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\n\nbase-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-303%2Fphilip-mcgraw%2Fgit-p4-auto-delete-named-temporary-file-v3-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-303/philip-mcgraw/git-p4-auto-delete-named-temporary-file-v3-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/303\n-- \ngitgitgadget\n"},{"id":"379802","messageId":"28840571564717728@iva1-44bdf084ee9e.qloud-c.yandex.net","threadId":"51572","inReplyTo":"pull.303.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/1] git-p4: auto-delete named temporary file","fromName":"Andrey","fromEmail":"ahippo@yandex.ru","sentAt":"2019-08-02T03:48:48Z","receivedAt":"2019-08-02T03:48:54Z","isPatch":true,"sender":{"key":"ahippo@yandex.ru","avatar":null},"body":"\n\n01.08.2019, 17:39, \"Philip McGraw via GitGitGadget\" <gitgitgadget@gmail.com>:\n> Take new approach using the NamedTemporaryFile() file-like object as input\n> to the ZipFile() which auto-deletes after implicit close leaving with scope.\n>\n> Original code produced double-open problems on Windows platform from using\n> already open NamedTemporaryFile() generated filename instead of object.\n>\n> Thanks to Andrey for patiently suggesting several iterations on this change\n> for avoiding exceptions!\n>\n> Also print error details after resulting IOError to make debugging cause of\n> exception less mysterious when it has nothing to do with \"git version recent\n> enough.\"\n>\n> Signed-off-by: Philip.McGraw Philip.McGraw@bentley.com\n> [Philip.McGraw@bentley.com]\n>\n> Philip.McGraw (1):\n>   git-p4: auto-delete named temporary file\n>\n>  git-p4.py | 13 ++++++-------\n>  1 file changed, 6 insertions(+), 7 deletions(-)\n>\n> base-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-303%2Fphilip-mcgraw%2Fgit-p4-auto-delete-named-temporary-file-v3-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-303/philip-mcgraw/git-p4-auto-delete-named-temporary-file-v3-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/303\n> --\n> gitgitgadget\n\nLooks good to me!\nReviewed-by: Andrey Mazo <ahippo@yandex.com>\n\n\n-- \nAndrey.\n\n"},{"id":"379850","messageId":"pull.303.v2.git.gitgitgadget@gmail.com","threadId":"51572","inReplyTo":"pull.303.git.gitgitgadget@gmail.com","subject":"[PATCH v2 0/1] git-p4: auto-delete named temporary file","fromName":"Philip McGraw via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-02T19:43:37Z","receivedAt":"2019-08-02T19:43:42Z","isPatch":true,"sender":{"key":"philip.mcgraw@bentley.com","avatar":"https://avatars.githubusercontent.com/u/18532989?v=4"},"body":"Take new approach using the NamedTemporaryFile() file-like object as input\nto the ZipFile() which auto-deletes after implicit close leaving with scope.\n\nOriginal code produced double-open problems on Windows platform from using\nalready open NamedTemporaryFile() generated filename instead of object.\n\nThanks to Andrey for patiently suggesting several iterations on this change\nfor avoiding exceptions!\n\nAlso print error details after resulting IOError to make debugging cause of\nexception less mysterious when it has nothing to do with \"git version recent\nenough.\"\n\nSigned-off-by: Philip.McGraw Philip.McGraw@bentley.com\n[Philip.McGraw@bentley.com]\n\nPhilip.McGraw (1):\n  git-p4: auto-delete named temporary file\n\n git-p4.py | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\n\nbase-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-303%2Fphilip-mcgraw%2Fgit-p4-auto-delete-named-temporary-file-v3-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-303/philip-mcgraw/git-p4-auto-delete-named-temporary-file-v3-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/303\n\nRange-diff vs v1:\n\n 1:  1b270ef9a6 ! 1:  7e59b5cec2 git-p4: auto-delete named temporary file\n     @@ -2,13 +2,17 @@\n      \n          git-p4: auto-delete named temporary file\n      \n     +    Avoid double-open exceptions on Windows platform when\n     +    calculating for lfs compressed size threshold\n     +    (git-p4.largeFileCompressedThreshold) comparisons.\n     +\n          Take new approach using the NamedTemporaryFile()\n          file-like object as input to the ZipFile() which\n          auto-deletes after implicit close leaving with scope.\n      \n     -    Original code produced double-open problems on Windows\n     -    platform from using already open NamedTemporaryFile()\n     -    generated filename instead of object.\n     +    Original code had double-open exception on Windows\n     +    platform because file still open from NamedTemporaryFile()\n     +    using generated filename instead of object.\n      \n          Thanks to Andrey for patiently suggesting several\n          iterations on this change for avoiding exceptions!\n     @@ -18,6 +22,7 @@\n          nothing to do with \"git version recent enough.\"\n      \n          Signed-off-by: Philip.McGraw <Philip.McGraw@bentley.com>\n     +    Reviewed-by: Andrey Mazo <ahippo@yandex.com>\n      \n       diff --git a/git-p4.py b/git-p4.py\n       --- a/git-p4.py\n\n-- \ngitgitgadget\n"},{"id":"381172","messageId":"CANg4QoGSVQWG3QXzoiA8oDsjXaXGoZ+WMNLSPpu75eJWdrWxLQ@mail.gmail.com","threadId":"51572","inReplyTo":"pull.303.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git-p4: auto-delete named temporary file","fromName":"Git Gadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-26T13:51:06Z","receivedAt":"2019-08-26T13:51:19Z","isPatch":true,"sender":{"key":"gitgitgadget@gmail.com","avatar":null},"body":"From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n\nTake new approach using the NamedTemporaryFile()\nfile-like object as input to the ZipFile() which\nauto-deletes after implicit close leaving with scope.\n\nOriginal code produced double-open problems on Windows\nplatform from using already open NamedTemporaryFile()\ngenerated filename instead of object.\n\nThanks to Andrey for patiently suggesting several\niterations on this change for avoiding exceptions!\n\nAlso print error details after resulting IOError to make\ndebugging cause of exception less mysterious when it has\nnothing to do with \"git version recent enough.\"\n\nSigned-off-by: Philip.McGraw <Philip.McGraw@bentley.com>\n---\n git-p4.py | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c71a6832e2..33bdb14fd1 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1160,13 +1160,11 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n             if contentsSize <=\ngitConfigInt('git-p4.largeFileCompressedThreshold'):\n                 return False\n             contentTempFile = self.generateTempFile(contents)\n-            compressedContentFile =\ntempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n-            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n-            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n-            zf.close()\n-            compressedContentsSize = zf.infolist()[0].compress_size\n+            compressedContentFile =\ntempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=True)\n+            with zipfile.ZipFile(compressedContentFile, mode='w') as zf:\n+                zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n+                compressedContentsSize = zf.infolist()[0].compress_size\n             os.remove(contentTempFile)\n-            os.remove(compressedContentFile.name)\n             if compressedContentsSize >\ngitConfigInt('git-p4.largeFileCompressedThreshold'):\n                 return True\n         return False\n@@ -3514,8 +3512,9 @@ def importHeadRevision(self, revision):\n         self.updateOptionDict(details)\n         try:\n             self.commit(details,\nself.extractFilesFromCommit(details), self.branch)\n-        except IOError:\n+        except IOError as err:\n             print(\"IO error with git fast-import. Is your git version\nrecent enough?\")\n+            print(\"IO error details: {}\".format(err))\n             print(self.gitError.read())\n\n     def openStreams(self):\n\n--\ngitgitgadget\n"},{"id":"381208","messageId":"xmqqo90bj2ye.fsf@gitster-ct.c.googlers.com","threadId":"51572","inReplyTo":"CANg4QoGSVQWG3QXzoiA8oDsjXaXGoZ+WMNLSPpu75eJWdrWxLQ@mail.gmail.com","subject":"Re: [PATCH 1/1] git-p4: auto-delete named temporary file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-26T16:39:37Z","receivedAt":"2019-08-26T16:39:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Funny that the patch is line-wrapped, which I do not recall ever\nseeing in GGG-generated e-mails.  Dscho, do you know if anything\nfunny is going on?\n\nGit Gadget <gitgitgadget@gmail.com> writes:\n\n> From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n> ...\n> diff --git a/git-p4.py b/git-p4.py\n> index c71a6832e2..33bdb14fd1 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -1160,13 +1160,11 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n>              if contentsSize <=\n> gitConfigInt('git-p4.largeFileCompressedThreshold'):\n>                  return False\n>              contentTempFile = self.generateTempFile(contents)\n> -            compressedContentFile =\n> tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n> -            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n> -            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> ...\n"},{"id":"381286","messageId":"7e59b5cec2f267820feeeeb63a20814fe67d61e3.1566876175.git.ahippo@yandex.com","threadId":"51572","inReplyTo":"pull.303.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 1/1] git-p4: auto-delete named temporary file","fromName":"Andrey Mazo","fromEmail":"ahippo@yandex.ru","sentAt":"2019-08-27T03:43:58Z","receivedAt":"2019-08-27T03:44:14Z","isPatch":true,"sender":{"key":"ahippo@yandex.ru","avatar":null},"body":"From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n\nAvoid double-open exceptions on Windows platform when\ncalculating for lfs compressed size threshold\n(git-p4.largeFileCompressedThreshold) comparisons.\n\nTake new approach using the NamedTemporaryFile()\nfile-like object as input to the ZipFile() which\nauto-deletes after implicit close leaving with scope.\n\nOriginal code had double-open exception on Windows\nplatform because file still open from NamedTemporaryFile()\nusing generated filename instead of object.\n\nThanks to Andrey for patiently suggesting several\niterations on this change for avoiding exceptions!\n\nAlso print error details after resulting IOError to make\ndebugging cause of exception less mysterious when it has\nnothing to do with \"git version recent enough.\"\n\nSigned-off-by: Philip.McGraw <Philip.McGraw@bentley.com>\nReviewed-by: Andrey Mazo <ahippo@yandex.com>\n---\n git-p4.py | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c71a6832e2..33bdb14fd1 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1158,17 +1158,15 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n         if gitConfigInt('git-p4.largeFileCompressedThreshold'):\n             contentsSize = sum(len(d) for d in contents)\n             if contentsSize <= gitConfigInt('git-p4.largeFileCompressedThreshold'):\n                 return False\n             contentTempFile = self.generateTempFile(contents)\n-            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n-            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n-            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n-            zf.close()\n-            compressedContentsSize = zf.infolist()[0].compress_size\n+            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=True)\n+            with zipfile.ZipFile(compressedContentFile, mode='w') as zf:\n+                zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n+                compressedContentsSize = zf.infolist()[0].compress_size\n             os.remove(contentTempFile)\n-            os.remove(compressedContentFile.name)\n             if compressedContentsSize > gitConfigInt('git-p4.largeFileCompressedThreshold'):\n                 return True\n         return False\n \n     def addLargeFile(self, relPath):\n@@ -3512,12 +3510,13 @@ def importHeadRevision(self, revision):\n         details[\"time\"] = res[\"time\"]\n \n         self.updateOptionDict(details)\n         try:\n             self.commit(details, self.extractFilesFromCommit(details), self.branch)\n-        except IOError:\n+        except IOError as err:\n             print(\"IO error with git fast-import. Is your git version recent enough?\")\n+            print(\"IO error details: {}\".format(err))\n             print(self.gitError.read())\n \n     def openStreams(self):\n         self.importProcess = subprocess.Popen([\"git\", \"fast-import\"],\n                                               stdin=subprocess.PIPE,\n\nbase-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\nPull-Request: https://github.com/gitgitgadget/git/pull/303\n-- \n2.21.0\n\n"},{"id":"381404","messageId":"xmqq1rx62qbe.fsf@gitster-ct.c.googlers.com","threadId":"51572","inReplyTo":"7e59b5cec2f267820feeeeb63a20814fe67d61e3.1566876175.git.ahippo@yandex.com","subject":"Re: [PATCH v2 1/1] git-p4: auto-delete named temporary file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-27T22:31:33Z","receivedAt":"2019-08-27T22:31:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrey Mazo <ahippo@yandex.ru> writes:\n\n> From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n>\n> Avoid double-open exceptions on Windows platform when\n> calculating for lfs compressed size threshold\n> (git-p4.largeFileCompressedThreshold) comparisons.\n>\n> Take new approach using the NamedTemporaryFile()\n> file-like object as input to the ZipFile() which\n> auto-deletes after implicit close leaving with scope.\n>\n> Original code had double-open exception on Windows\n> platform because file still open from NamedTemporaryFile()\n> using generated filename instead of object.\n>\n> Thanks to Andrey for patiently suggesting several\n> iterations on this change for avoiding exceptions!\n>\n> Also print error details after resulting IOError to make\n> debugging cause of exception less mysterious when it has\n> nothing to do with \"git version recent enough.\"\n>\n> Signed-off-by: Philip.McGraw <Philip.McGraw@bentley.com>\n> Reviewed-by: Andrey Mazo <ahippo@yandex.com>\n> ---\n\nLuke, does this look good?\n\nI know Mazo is the only other contributor who has multiple commits\nto git-p4.py in the past 2 years, to make Reviewed-by carry some\nweight ;-) but as we have so small number of people touching this\nscript anyway, I'd rather see what the main contributor in the past\n2 years thinks.\n\nThanks.\n\n>  git-p4.py | 13 ++++++-------\n>  1 file changed, 6 insertions(+), 7 deletions(-)\n>\n> diff --git a/git-p4.py b/git-p4.py\n> index c71a6832e2..33bdb14fd1 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -1158,17 +1158,15 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n>          if gitConfigInt('git-p4.largeFileCompressedThreshold'):\n>              contentsSize = sum(len(d) for d in contents)\n>              if contentsSize <= gitConfigInt('git-p4.largeFileCompressedThreshold'):\n>                  return False\n>              contentTempFile = self.generateTempFile(contents)\n> -            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n> -            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n> -            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> -            zf.close()\n> -            compressedContentsSize = zf.infolist()[0].compress_size\n> +            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=True)\n> +            with zipfile.ZipFile(compressedContentFile, mode='w') as zf:\n> +                zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> +                compressedContentsSize = zf.infolist()[0].compress_size\n>              os.remove(contentTempFile)\n> -            os.remove(compressedContentFile.name)\n>              if compressedContentsSize > gitConfigInt('git-p4.largeFileCompressedThreshold'):\n>                  return True\n>          return False\n>  \n>      def addLargeFile(self, relPath):\n> @@ -3512,12 +3510,13 @@ def importHeadRevision(self, revision):\n>          details[\"time\"] = res[\"time\"]\n>  \n>          self.updateOptionDict(details)\n>          try:\n>              self.commit(details, self.extractFilesFromCommit(details), self.branch)\n> -        except IOError:\n> +        except IOError as err:\n>              print(\"IO error with git fast-import. Is your git version recent enough?\")\n> +            print(\"IO error details: {}\".format(err))\n>              print(self.gitError.read())\n>  \n>      def openStreams(self):\n>          self.importProcess = subprocess.Popen([\"git\", \"fast-import\"],\n>                                                stdin=subprocess.PIPE,\n>\n> base-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\n> Pull-Request: https://github.com/gitgitgadget/git/pull/303\n"},{"id":"381422","messageId":"CAE5ih78iSO+yu0KC8gg450iv5iY1gJusN33uatFdRgp_1ToALw@mail.gmail.com","threadId":"51572","inReplyTo":"xmqq1rx62qbe.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v2 1/1] git-p4: auto-delete named temporary file","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2019-08-28T08:34:17Z","receivedAt":"2019-08-28T08:34:32Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On Tue, 27 Aug 2019 at 23:31, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Andrey Mazo <ahippo@yandex.ru> writes:\n>\n> > From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n> >\n> > Avoid double-open exceptions on Windows platform when\n> > calculating for lfs compressed size threshold\n> > (git-p4.largeFileCompressedThreshold) comparisons.\n> >\n> > Take new approach using the NamedTemporaryFile()\n> > file-like object as input to the ZipFile() which\n> > auto-deletes after implicit close leaving with scope.\n> >\n> > Original code had double-open exception on Windows\n> > platform because file still open from NamedTemporaryFile()\n> > using generated filename instead of object.\n> >\n> > Thanks to Andrey for patiently suggesting several\n> > iterations on this change for avoiding exceptions!\n> >\n> > Also print error details after resulting IOError to make\n> > debugging cause of exception less mysterious when it has\n> > nothing to do with \"git version recent enough.\"\n> >\n> > Signed-off-by: Philip.McGraw <Philip.McGraw@bentley.com>\n> > Reviewed-by: Andrey Mazo <ahippo@yandex.com>\n> > ---\n>\n> Luke, does this look good?\n>\n> I know Mazo is the only other contributor who has multiple commits\n> to git-p4.py in the past 2 years, to make Reviewed-by carry some\n> weight ;-) but as we have so small number of people touching this\n> script anyway, I'd rather see what the main contributor in the past\n> 2 years thinks.\n\nI think it looks reasonable.\n\nAck.\n\n\n>\n> Thanks.\n>\n> >  git-p4.py | 13 ++++++-------\n> >  1 file changed, 6 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/git-p4.py b/git-p4.py\n> > index c71a6832e2..33bdb14fd1 100755\n> > --- a/git-p4.py\n> > +++ b/git-p4.py\n> > @@ -1158,17 +1158,15 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n> >          if gitConfigInt('git-p4.largeFileCompressedThreshold'):\n> >              contentsSize = sum(len(d) for d in contents)\n> >              if contentsSize <= gitConfigInt('git-p4.largeFileCompressedThreshold'):\n> >                  return False\n> >              contentTempFile = self.generateTempFile(contents)\n> > -            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n> > -            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n> > -            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> > -            zf.close()\n> > -            compressedContentsSize = zf.infolist()[0].compress_size\n> > +            compressedContentFile = tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=True)\n> > +            with zipfile.ZipFile(compressedContentFile, mode='w') as zf:\n> > +                zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> > +                compressedContentsSize = zf.infolist()[0].compress_size\n> >              os.remove(contentTempFile)\n> > -            os.remove(compressedContentFile.name)\n> >              if compressedContentsSize > gitConfigInt('git-p4.largeFileCompressedThreshold'):\n> >                  return True\n> >          return False\n> >\n> >      def addLargeFile(self, relPath):\n> > @@ -3512,12 +3510,13 @@ def importHeadRevision(self, revision):\n> >          details[\"time\"] = res[\"time\"]\n> >\n> >          self.updateOptionDict(details)\n> >          try:\n> >              self.commit(details, self.extractFilesFromCommit(details), self.branch)\n> > -        except IOError:\n> > +        except IOError as err:\n> >              print(\"IO error with git fast-import. Is your git version recent enough?\")\n> > +            print(\"IO error details: {}\".format(err))\n> >              print(self.gitError.read())\n> >\n> >      def openStreams(self):\n> >          self.importProcess = subprocess.Popen([\"git\", \"fast-import\"],\n> >                                                stdin=subprocess.PIPE,\n> >\n> > base-commit: 1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4\n> > Pull-Request: https://github.com/gitgitgadget/git/pull/303\n"},{"id":"381436","messageId":"nycvar.QRO.7.76.6.1908281424240.46@tvgsbejvaqbjf.bet","threadId":"51572","inReplyTo":"xmqqo90bj2ye.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/1] git-p4: auto-delete named temporary file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-28T12:25:28Z","receivedAt":"2019-08-28T12:25:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Mon, 26 Aug 2019, Junio C Hamano wrote:\n\n> Funny that the patch is line-wrapped, which I do not recall ever\n> seeing in GGG-generated e-mails.  Dscho, do you know if anything\n> funny is going on?\n\nYes, this was me trying to re-send the patch via GMail's web UI because\nthe first time GitGitGadget sent it, it did not get through (only the\ncover letter did).\n\nSo I tried to fix the screw-up by sending manually, and screwed it up\neven more.\n\nSorry about that.\nDscho\n\n>\n> Git Gadget <gitgitgadget@gmail.com> writes:\n>\n> > From: \"Philip.McGraw\" <Philip.McGraw@bentley.com>\n> > ...\n> > diff --git a/git-p4.py b/git-p4.py\n> > index c71a6832e2..33bdb14fd1 100755\n> > --- a/git-p4.py\n> > +++ b/git-p4.py\n> > @@ -1160,13 +1160,11 @@ def exceedsLargeFileThreshold(self, relPath, contents):\n> >              if contentsSize <=\n> > gitConfigInt('git-p4.largeFileCompressedThreshold'):\n> >                  return False\n> >              contentTempFile = self.generateTempFile(contents)\n> > -            compressedContentFile =\n> > tempfile.NamedTemporaryFile(prefix='git-p4-large-file', delete=False)\n> > -            zf = zipfile.ZipFile(compressedContentFile.name, mode='w')\n> > -            zf.write(contentTempFile, compress_type=zipfile.ZIP_DEFLATED)\n> > ...\n>\n"},{"id":"381494","messageId":"xmqqpnkozkqz.fsf@gitster-ct.c.googlers.com","threadId":"51572","inReplyTo":"nycvar.QRO.7.76.6.1908281424240.46@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 1/1] git-p4: auto-delete named temporary file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-29T03:57:40Z","receivedAt":"2019-08-29T03:57:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Yes, this was me trying to re-send the patch via GMail's web UI because\n> the first time GitGitGadget sent it, it did not get through (only the\n> cover letter did).\n\nAs long as that was manual screw-up, while fixing some glitches in\nthe machinery, that is fine.  I care about automation running\nsmoothly.\n\nThanks.\n"},{"id":"381502","messageId":"nycvar.QRO.7.76.6.1908291341330.46@tvgsbejvaqbjf.bet","threadId":"51572","inReplyTo":"xmqqpnkozkqz.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/1] git-p4: auto-delete named temporary file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-29T11:45:11Z","receivedAt":"2019-08-29T11:45:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Wed, 28 Aug 2019, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>\n> > Yes, this was me trying to re-send the patch via GMail's web UI because\n> > the first time GitGitGadget sent it, it did not get through (only the\n> > cover letter did).\n>\n> As long as that was manual screw-up, while fixing some glitches in\n> the machinery, that is fine.  I care about automation running\n> smoothly.\n\nIndeed, I also care about automation, as that keeps me sane (I would not\nbe able to do everything I do without offloading substantial parts to\nAzure Pipelines, like GitGitGadget).\n\nI am quite a bit worried about this, as it seemed to happen at least\nthree times. I'll see if it happens again, and when it does, I will try\nto save the mbox files as build artifacts, and then add another job that\nI can run manually to re-send the mbox files that did not make it to the\nmailing list (identified by the absence from public-inbox).\n\nAt the moment, I am still rather busy elsewhere, trying to catch up\nafter three weeks that I spent (or tried to spend) mostly offline.\n\nAnd I am really sorry for not writing a reply to the thread when I tried\nto re-send the patch manually, describing what I was doing, and why. I\nwill try to do better next time!\n\nCiao,\nDscho\n"},{"id":"383509","messageId":"CAPc5daXU=fcjYJ4p6wQH-Ljz1Y8j=sBiwcN96hkxhP4CP_k8uA@mail.gmail.com","threadId":"51572","inReplyTo":"10209481570324845@myt6-4218ece6190d.qloud-c.yandex.net","subject":"Re: [PATCH v2 1/1] git-p4: auto-delete named temporary file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-06T02:43:01Z","receivedAt":"2019-10-06T02:43:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> >> ...\n> >>  Luke, does this look good?\n> >>\n> >>  I know Mazo is the only other contributor who has multiple commits\n> >>  to git-p4.py in the past 2 years, to make Reviewed-by carry some\n> >>  weight ;-) but as we have so small number of people touching this\n> >>  script anyway, I'd rather see what the main contributor in the past\n> >>  2 years thinks.\n> >\n> > I think it looks reasonable.\n> >\n> > Ack.\n>\n> Junio, does Philip need to resend a v3 with Luke's ack or will you just add it yourself while queuing the patch?\n> (sorry, if you already picked up the patch -- I just didn't see it in the last What's cooking update)\n\nSorry, I do not recall the details of this old a thread but if I\nrecall correctly there was only a corrupt patch that I cannot use,\nso somebody would need to send a patch that actually applies. With a\npatch that applies, I can tweak the log message\nwith acked-by etc. just fine.\n\nThanks.\n"}]}