git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Luke Diamand <luke@diamand.org>
To: git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
	"Chen Bin" <chenbin.sh@gmail.com>,
	"Miguel Torroja" <miguel.torroja@gmail.com>,
	"George Vanburgh" <gvanburgh@bloomberg.net>,
	"Merland Romain" <merlorom@yahoo.fr>,
	"Vinicius Kursancew" <viniciusalexandre@gmail.com>,
	larsxschneider@gmail.com, "Lex Spoon" <lex@lexspoon.org>,
	"Luke Diamand" <luke@diamand.org>
Subject: [PATCHv1 1/3] git-p4: do not fail in verbose mode for missing 'fileSize' key
Date: Fri, 12 Oct 2018 06:28:31 +0100	[thread overview]
Message-ID: <20181012052833.6945-2-luke@diamand.org> (raw)
In-Reply-To: <20181012052833.6945-1-luke@diamand.org>

If deleting or moving a file, sometimes P4 doesn't report the file size.

The code handles this just fine but some logging crashes. Stop this
happening.

There was some earlier discussion on the list about this:

https://public-inbox.org/git/xmqq1sqpp1vv.fsf@gitster.mtv.corp.google.com/

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index 7fab255584..5701bad06a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2775,7 +2775,10 @@ def streamOneP4File(self, file, contents):
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         relPath = self.encodeWithUTF8(relPath)
         if verbose:
-            size = int(self.stream_file['fileSize'])
+            if 'fileSize' in self.stream_file:
+                size = int(self.stream_file['fileSize'])
+            else:
+                size = 0 # deleted files don't get a fileSize apparently
             sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
             sys.stdout.flush()
 
-- 
2.19.1.272.gf84b9b09d4


  reply	other threads:[~2018-10-12  5:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  5:28 [PATCHv1 0/3] git-p4: improved unshelving Luke Diamand
2018-10-12  5:28 ` Luke Diamand [this message]
2018-10-12  5:28 ` [PATCHv1 2/3] git-p4: unshelve into refs/remotes/p4-unshelved, not refs/remotes/p4/unshelved Luke Diamand
2018-10-12 13:45   ` Junio C Hamano
2018-10-12 18:19     ` Luke Diamand
2018-10-15 11:03       ` Luke Diamand
2018-10-12  5:28 ` [PATCHv1 3/3] git-p4: fully support unshelving changelists Luke Diamand

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=20181012052833.6945-2-luke@diamand.org \
    --to=luke@diamand.org \
    --cc=chenbin.sh@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gvanburgh@bloomberg.net \
    --cc=larsxschneider@gmail.com \
    --cc=lex@lexspoon.org \
    --cc=merlorom@yahoo.fr \
    --cc=miguel.torroja@gmail.com \
    --cc=szeder.dev@gmail.com \
    --cc=viniciusalexandre@gmail.com \
    /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).