git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thandesha VK <thanvk@gmail.com>
To: git@vger.kernel.org
Subject: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
Date: Mon, 16 Apr 2018 16:35:39 -0700	[thread overview]
Message-ID: <CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com> (raw)

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

             reply	other threads:[~2018-04-16 23:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 23:35 Thandesha VK [this message]
2018-04-17 16:00 ` [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com \
    --to=thanvk@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).