git-p4: do not fail in verbose mode for missing 'fileSize' key

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Luke Diamand committed Oct 12, 2018 at 06:28 UTC 0742b7c860a4291868dec79b90a217db6b129d2b
1 file changed +4 -1
git-p4.py
+4 -1
@@ -2775,7 +2775,10 @@ class P4Sync(Command, P4UserMap):
2775 relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
2776 relPath = self.encodeWithUTF8(relPath)
2777 if verbose:
2778 - size = int(self.stream_file['fileSize'])
2778 + if 'fileSize' in self.stream_file:
2779 + size = int(self.stream_file['fileSize'])
2780 + else:
2781 + size = 0 # deleted files don't get a fileSize apparently
2782 sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
2783 sys.stdout.flush()
2784