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

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

From
TVThandesha VK <thanvk@gmail.com>
Date
Apr 16, 2018, 23:35 UTC
Message-ID
<CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com>

git p4 clone fails when p4 sizes does not return 'fileSize' key. There are few cases when p4 sizes returens 0 size and with marshaled output, it doesn’t return the fileSize attribute.

Here is the demonstration and potential fix
$ cd /tmp/git/
$ git remote -v
origin  https://github.com/git/git.git (fetch)
origin  https://github.com/git/git.git (push)
$ git branch  -v
* master fe0a9eaf3 Merge branch 'svn/authors-prog-2' of
git://bogomips.org/git-svn
Problem:
$ /tmp/git/git-p4.py clone //depot/<path>/@all   . –verbose
.
.
.
Traceback (most recent call last):
  File "/tmp/git/git-p4.py", line 3840, in <module>
    main()
  File "/tmp/git/git-p4.py", line 3834, in main
    if not cmd.run(args):
  File "/tmp/git/git-p4.py", line 3706, in run
    if not P4Sync.run(self, depotPaths):
  File "/tmp/git/git-p4.py", line 3568, in run
    self.importChanges(changes)
  File "/tmp/git/git-p4.py", line 3240, in importChanges
    self.initialParent)
  File "/tmp/git/git-p4.py", line 2858, in commit
    self.streamP4Files(files)
  File "/tmp/git/git-p4.py", line 2750, in streamP4Files
    cb=streamP4FilesCbSelf)
  File "/tmp/git/git-p4.py", line 552, in p4CmdList
    cb(entry)
  File "/tmp/git/git-p4.py", line 2744, in streamP4FilesCbSelf
    self.streamP4FilesCb(entry)
  File "/tmp/git/git-p4.py", line 2692, in streamP4FilesCb
    self.streamOneP4File(self.stream_file, self.stream_contents)
  File "/tmp/git/git-p4.py", line 2569, in streamOneP4File
    size = int(self.stream_file['fileSize'])
KeyError: 'fileSize'
Signature of the sizes output resulting in this problem:
$ p4 -p <port>  sizes //foo.c
//foo.c#5 <n/a> bytes
$ p4 -p <port>  -G sizes //foo.c
{scodesstats    depotFiles4//fooc.c50
Signature for a file without problem:
$ p4 -p <port>  sizes //bar.c
//bar.c#5 1105 bytes
$ p4 -p <port> -G  sizes //bar.c
{scodesstats    depotFiles;//bar.csrevs5fileSizes11050
Patch:
$ git diff
diff --git a/git-p4.py b/git-p4.py

index 7bb9cadc6..f908e805e 100755

--- a/git-p4.py

+++ b/git-p4.py

@@ -2565,7 +2565,7 @@ class P4Sync(Command, P4UserMap):

     def streamOneP4File(self, file, contents):

         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)

         relPath = self.encodeWithUTF8(relPath)

-        if verbose:

+        if verbose and 'fileSize' in self.stream_file:

             size = int(self.stream_file['fileSize'])

             sys.stdout.write('\r%s --> %s (%i MB)\n' %
(file['depotFile'], relPath, size/1024/1024))

             sys.stdout.flush()



Thanks & Regards

Thandesha
Next: Andrey Mazo
Message 1 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.