git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
@ 2018-04-16 23:35 Thandesha VK
  2018-04-17 16:00 ` Mazo, Andrey
  2018-04-17 16:22 ` Andrey Mazo
  0 siblings, 2 replies; 15+ messages in thread
From: Thandesha VK @ 2018-04-16 23:35 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-04-18 14:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 23:35 [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key Thandesha VK
2018-04-17 16:00 ` Mazo, Andrey
2018-04-17 16:22 ` Andrey Mazo
2018-04-17 16:22   ` [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize' Andrey Mazo
     [not found]     ` <CAE5ih7-iQsBxM3Gn4B1Q9WZ2A0=eTHn9nt3a0LVURppOCQsAWA@mail.gmail.com>
2018-04-17 21:18       ` Mazo, Andrey
2018-04-17 21:24         ` Thandesha VK
2018-04-17 21:38           ` Mazo, Andrey
2018-04-17 22:29             ` Thandesha VK
2018-04-17 17:21   ` [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key Thandesha VK
2018-04-17 17:33     ` Mazo, Andrey
2018-04-17 18:01       ` Thandesha VK
2018-04-17 18:47         ` Mazo, Andrey
2018-04-17 19:12           ` Thandesha VK
2018-04-18 11:08             ` Luke Diamand
2018-04-18 14:59               ` Thandesha VK

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).