git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key

From
TVThandesha VK <thanvk@gmail.com>
Date
Apr 17, 2018, 18:01 UTC
Message-ID
<CAJJpmi_Qk-Q3ndiOFiYy5fGsKsJ0mF=nKbSDkdY-NE0DRkZTEg@mail.gmail.com>
In-Reply-To
<BYAPR08MB384591845049E50D98A42303DAB70@BYAPR08MB3845.namprd08.prod.outlook.com>

Sounds good. How about an enhanced version of fix from both of us. This will let us know that something is not right with the file but will not bark

$ git diff
diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc6..df901976f 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         relPath = self.encodeWithUTF8(relPath)
         if verbose:
-            size = int(self.stream_file['fileSize'])
+            if 'fileSize' not in self.stream_file:
+               print "WARN: File size from perforce unknown. Please
verify by p4 sizes %s" %(file['depotFile'])
+               size = "-1"
+            else:
+               size = self.stream_file['fileSize']
+            size = int(size)
             sys.stdout.write('\r%s --> %s (%i MB)\n' %
(file['depotFile'], relPath, size/1024/1024))
             sys.stdout.flush()


On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
> Sure, I totally agree.
> Sorry, I just wasn't clear enough in my previous email.
> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
> In other words,
>  * if "fileSize" is known:
>  ** both yours and mine patches don't change existing behavior;
>  * if "fileSize" is not known:
>  ** your patch makes streamOneP4File() not print anything;
>  ** my patch makes streamOneP4File() print "%s --> %s".
>
> Hope, I'm clearer this time.
>
> Thank you,
> Andrey
>
> From: Thandesha VK <thanvk@gmail.com>
>> *I* think keeping the filesize info is better with --verbose option as
>> that gives some clue about the file we are working on. What do you
>> think?
>> Script has similar checks of key existence at other places where it is
>> looking for fileSize.
>>
>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>> Huh, I actually have a slightly different fix for the same issue.
>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>
>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>
>>> Andrey Mazo (1):
>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>
>>>  git-p4.py | 8 ++++++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>>
>>> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
>>> --
>>> 2.16.1
>>>
>>
>> --
>> Thanks & Regards
>> Thandesha VK | Cellphone +1 (703) 459-5386
-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386
Previous: Mazo, AndreyNext: Mazo, Andrey
Message 6 of 15 in “[BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key”
  1. Thandesha VKApr 16, 2018
  2. Andrey MazoApr 17, 2018
  3. 1/1 git-p4: fix `sync --verbose` traceback due to 'fileSize'Andrey Mazo, Apr 17, 2018
  4. Thandesha VKApr 17, 2018
  5. Mazo, AndreyApr 17, 2018
  6. Thandesha VKApr 17, 2018
  7. Mazo, AndreyApr 17, 2018
  8. Thandesha VKApr 17, 2018
  9. Luke DiamandApr 18, 2018
  10. Thandesha VKApr 18, 2018
  11. Mazo, AndreyApr 17, 2018
  12. Mazo, AndreyApr 17, 2018
  13. Thandesha VKApr 17, 2018
  14. Mazo, AndreyApr 17, 2018
  15. Thandesha VKApr 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.