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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  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
  1 sibling, 0 replies; 15+ messages in thread
From: Mazo, Andrey @ 2018-04-17 16:00 UTC (permalink / raw)
  To: Thandesha VK, git@vger.kernel.org

Huh, I actually have a slightly different fix for the same issue.
It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
I'll (try to) post it as a reply to this email.

Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.

Thank you,
Andrey

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  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
  2018-04-17 17:21   ` [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key Thandesha VK
  1 sibling, 2 replies; 15+ messages in thread
From: Andrey Mazo @ 2018-04-17 16:22 UTC (permalink / raw)
  To: git; +Cc: Andrey Mazo, luke, gvanburgh, larsxschneider, miguel.torroja,
	thanvk

Huh, I actually have a slightly different fix for the same issue.
It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.

Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.

Andrey Mazo (1):
  git-p4: fix `sync --verbose` traceback due to 'fileSize'

 git-p4.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)


base-commit: 468165c1d8a442994a825f3684528361727cd8c0
-- 
2.16.1


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

* [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize'
  2018-04-17 16:22 ` Andrey Mazo
@ 2018-04-17 16:22   ` Andrey Mazo
       [not found]     ` <CAE5ih7-iQsBxM3Gn4B1Q9WZ2A0=eTHn9nt3a0LVURppOCQsAWA@mail.gmail.com>
  2018-04-17 17:21   ` [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key Thandesha VK
  1 sibling, 1 reply; 15+ messages in thread
From: Andrey Mazo @ 2018-04-17 16:22 UTC (permalink / raw)
  To: git; +Cc: Andrey Mazo, luke, gvanburgh, larsxschneider, miguel.torroja,
	thanvk

Perforce server 2007.2 (and maybe others) doesn't return "fileSize"
attribute in its reply to `p4 -G print` command.
This causes the following traceback when running `git p4 sync --verbose`:
"""
    Traceback (most recent call last):
      File "/usr/libexec/git-core/git-p4", line 3839, in <module>
	main()
      File "/usr/libexec/git-core/git-p4", line 3833, in main
	if not cmd.run(args):
      File "/usr/libexec/git-core/git-p4", line 3567, in run
	self.importChanges(changes)
      File "/usr/libexec/git-core/git-p4", line 3233, in importChanges
	self.commit(description, filesForCommit, branch, parent)
      File "/usr/libexec/git-core/git-p4", line 2855, in commit
	self.streamP4Files(files)
      File "/usr/libexec/git-core/git-p4", line 2747, in streamP4Files
	cb=streamP4FilesCbSelf)
      File "/usr/libexec/git-core/git-p4", line 552, in p4CmdList
	cb(entry)
      File "/usr/libexec/git-core/git-p4", line 2741, in streamP4FilesCbSelf
	self.streamP4FilesCb(entry)
      File "/usr/libexec/git-core/git-p4", line 2689, in streamP4FilesCb
	self.streamOneP4File(self.stream_file, self.stream_contents)
      File "/usr/libexec/git-core/git-p4", line 2566, in streamOneP4File
	size = int(self.stream_file['fileSize'])
    KeyError: 'fileSize'
"""

Fix this by omitting the file size information from the verbose print out.
Also, don't use "self.stream_file" directly,
but rather use passed in "file" argument.
(which point to the same "self.stream_file" for all existing callers)

Signed-off-by: Andrey Mazo <amazo@checkvideo.com>
---
 git-p4.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc6..6f05f915a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2566,8 +2566,12 @@ class P4Sync(Command, P4UserMap):
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         relPath = self.encodeWithUTF8(relPath)
         if verbose:
-            size = int(self.stream_file['fileSize'])
-            sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
+            size = file.get('fileSize', None)
+            if size is None:
+                sizeStr = ''
+            else:
+                sizeStr = ' (%i MB)' % (int(size)/1024/1024)
+            sys.stdout.write('\r%s --> %s%s\n' % (file['depotFile'], relPath, sizeStr))
             sys.stdout.flush()
 
         (type_base, type_mods) = split_p4_type(file["type"])
-- 
2.16.1


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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  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
@ 2018-04-17 17:21   ` Thandesha VK
  2018-04-17 17:33     ` Mazo, Andrey
  1 sibling, 1 reply; 15+ messages in thread
From: Thandesha VK @ 2018-04-17 17:21 UTC (permalink / raw)
  To: Andrey Mazo; +Cc: git, luke, gvanburgh, larsxschneider, miguel.torroja

*I* think keeping the filesize info is better with --verbose option as
that gives some clue about the file we are working on. What do you
think?
Script has similar checks of key existence at other places where it is
looking for fileSize.

On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
> Huh, I actually have a slightly different fix for the same issue.
> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>
> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>
> Andrey Mazo (1):
>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>
>  git-p4.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
>
> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
> --
> 2.16.1
>



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Mazo, Andrey @ 2018-04-17 17:33 UTC (permalink / raw)
  To: Thandesha VK
  Cc: git@vger.kernel.org, luke@diamand.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

Sure, I totally agree.
Sorry, I just wasn't clear enough in my previous email.
I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
In other words,
 * if "fileSize" is known:
 ** both yours and mine patches don't change existing behavior;
 * if "fileSize" is not known:
 ** your patch makes streamOneP4File() not print anything;
 ** my patch makes streamOneP4File() print "%s --> %s".

Hope, I'm clearer this time.
     
Thank you,
Andrey

From: Thandesha VK <thanvk@gmail.com>
> *I* think keeping the filesize info is better with --verbose option as
> that gives some clue about the file we are working on. What do you
> think?
> Script has similar checks of key existence at other places where it is
> looking for fileSize.
> 
> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>> Huh, I actually have a slightly different fix for the same issue.
>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>
>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>
>> Andrey Mazo (1):
>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>
>>  git-p4.py | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>>
>> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
>> --
>> 2.16.1
>>
> 
> -- 
> Thanks & Regards
> Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  2018-04-17 17:33     ` Mazo, Andrey
@ 2018-04-17 18:01       ` Thandesha VK
  2018-04-17 18:47         ` Mazo, Andrey
  0 siblings, 1 reply; 15+ messages in thread
From: Thandesha VK @ 2018-04-17 18:01 UTC (permalink / raw)
  To: Mazo, Andrey
  Cc: git@vger.kernel.org, luke@diamand.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

Sounds good. How about an enhanced version of fix from both of us.
This will let us know that something is not right with the file but
will not bark

$ git diff
diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc6..df901976f 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         relPath = self.encodeWithUTF8(relPath)
         if verbose:
-            size = int(self.stream_file['fileSize'])
+            if 'fileSize' not in self.stream_file:
+               print "WARN: File size from perforce unknown. Please
verify by p4 sizes %s" %(file['depotFile'])
+               size = "-1"
+            else:
+               size = self.stream_file['fileSize']
+            size = int(size)
             sys.stdout.write('\r%s --> %s (%i MB)\n' %
(file['depotFile'], relPath, size/1024/1024))
             sys.stdout.flush()


On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
> Sure, I totally agree.
> Sorry, I just wasn't clear enough in my previous email.
> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
> In other words,
>  * if "fileSize" is known:
>  ** both yours and mine patches don't change existing behavior;
>  * if "fileSize" is not known:
>  ** your patch makes streamOneP4File() not print anything;
>  ** my patch makes streamOneP4File() print "%s --> %s".
>
> Hope, I'm clearer this time.
>
> Thank you,
> Andrey
>
> From: Thandesha VK <thanvk@gmail.com>
>> *I* think keeping the filesize info is better with --verbose option as
>> that gives some clue about the file we are working on. What do you
>> think?
>> Script has similar checks of key existence at other places where it is
>> looking for fileSize.
>>
>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>> Huh, I actually have a slightly different fix for the same issue.
>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>
>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>
>>> Andrey Mazo (1):
>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>
>>>  git-p4.py | 8 ++++++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>>
>>> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
>>> --
>>> 2.16.1
>>>
>>
>> --
>> Thanks & Regards
>> Thandesha VK | Cellphone +1 (703) 459-5386



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  2018-04-17 18:01       ` Thandesha VK
@ 2018-04-17 18:47         ` Mazo, Andrey
  2018-04-17 19:12           ` Thandesha VK
  0 siblings, 1 reply; 15+ messages in thread
From: Mazo, Andrey @ 2018-04-17 18:47 UTC (permalink / raw)
  To: Thandesha VK
  Cc: git@vger.kernel.org, luke@diamand.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

Does a missing "fileSize" actually mean that there is something wrong with the file?
Because, for me, `p4 -G print` doesn't print "fileSize" for _any_ file.
(which I attribute to our rather ancient (2007.2) Perforce server)
I'm not an expert in Perforce, so don't know for sure.

However, `p4 -G sizes` works fine even with our p4 server.
Should we then go one step further and use `p4 -G sizes` to obtain the "fileSize" when it's not returned by `p4 -G print`?
Or is it an overkill for a simple verbose print out?

Also, please, find one comment inline below.

Thank you,
Andrey

From: Thandesha VK <thanvk@gmail.com>
> Sounds good. How about an enhanced version of fix from both of us.
> This will let us know that something is not right with the file but
> will not bark
> 
> $ git diff
> diff --git a/git-p4.py b/git-p4.py
> index 7bb9cadc6..df901976f 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>          relPath = self.encodeWithUTF8(relPath)
>          if verbose:
> -            size = int(self.stream_file['fileSize'])
> +            if 'fileSize' not in self.stream_file:
> +               print "WARN: File size from perforce unknown. Please verify by p4 sizes %s" %(file['depotFile'])
For whatever reason, the code below uses sys.stdout.write() instead of print().
Should it be used here for consistency as well?

> +               size = "-1"
> +            else:
> +               size = self.stream_file['fileSize']
> +            size = int(size)
>              sys.stdout.write('\r%s --> %s (%i MB)\n' %
> (file['depotFile'], relPath, size/1024/1024))
>              sys.stdout.flush()
> 
> 
> On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>> Sure, I totally agree.
>> Sorry, I just wasn't clear enough in my previous email.
>> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
>> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
>> In other words,
>>  * if "fileSize" is known:
>>  ** both yours and mine patches don't change existing behavior;
>>  * if "fileSize" is not known:
>>  ** your patch makes streamOneP4File() not print anything;
>>  ** my patch makes streamOneP4File() print "%s --> %s".
>>
>> Hope, I'm clearer this time.
>>
>> Thank you,
>> Andrey
>>
>> From: Thandesha VK <thanvk@gmail.com>
>>> *I* think keeping the filesize info is better with --verbose option as
>>> that gives some clue about the file we are working on. What do you
>>> think?
>>> Script has similar checks of key existence at other places where it is
>>> looking for fileSize.
>>>
>>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>>> Huh, I actually have a slightly different fix for the same issue.
>>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>>
>>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>>
>>>> Andrey Mazo (1):
>>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>>
>>>>  git-p4.py | 8 ++++++--
>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>
>>>>
>>>> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
>>>> --
>>>> 2.16.1
>>>>
>>>
>>> --
>>> Thanks & Regards
>>> Thandesha VK | Cellphone +1 (703) 459-5386
>
>
>
> -- 
> Thanks & Regards
> Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  2018-04-17 18:47         ` Mazo, Andrey
@ 2018-04-17 19:12           ` Thandesha VK
  2018-04-18 11:08             ` Luke Diamand
  0 siblings, 1 reply; 15+ messages in thread
From: Thandesha VK @ 2018-04-17 19:12 UTC (permalink / raw)
  To: Mazo, Andrey
  Cc: git@vger.kernel.org, luke@diamand.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

I have few cases where even p4 -G sizes (or p4 sizes) is not returning
the size value even with latest version of p4 (17.2). In that case, we
have to regenerate the digest for file save it - It mean something is
wrong with the file in perforce.
Regarding, sys.stdout.write v/s print, I see script using both of them
without a common pattern. I can change it to whatever is more
appropriate.

On Tue, Apr 17, 2018 at 11:47 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
> Does a missing "fileSize" actually mean that there is something wrong with the file?
> Because, for me, `p4 -G print` doesn't print "fileSize" for _any_ file.
> (which I attribute to our rather ancient (2007.2) Perforce server)
> I'm not an expert in Perforce, so don't know for sure.
>
> However, `p4 -G sizes` works fine even with our p4 server.
> Should we then go one step further and use `p4 -G sizes` to obtain the "fileSize" when it's not returned by `p4 -G print`?
> Or is it an overkill for a simple verbose print out?
>
> Also, please, find one comment inline below.
>
> Thank you,
> Andrey
>
> From: Thandesha VK <thanvk@gmail.com>
>> Sounds good. How about an enhanced version of fix from both of us.
>> This will let us know that something is not right with the file but
>> will not bark
>>
>> $ git diff
>> diff --git a/git-p4.py b/git-p4.py
>> index 7bb9cadc6..df901976f 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>          relPath = self.encodeWithUTF8(relPath)
>>          if verbose:
>> -            size = int(self.stream_file['fileSize'])
>> +            if 'fileSize' not in self.stream_file:
>> +               print "WARN: File size from perforce unknown. Please verify by p4 sizes %s" %(file['depotFile'])
> For whatever reason, the code below uses sys.stdout.write() instead of print().
> Should it be used here for consistency as well?
>
>> +               size = "-1"
>> +            else:
>> +               size = self.stream_file['fileSize']
>> +            size = int(size)
>>              sys.stdout.write('\r%s --> %s (%i MB)\n' %
>> (file['depotFile'], relPath, size/1024/1024))
>>              sys.stdout.flush()
>>
>>
>> On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>>> Sure, I totally agree.
>>> Sorry, I just wasn't clear enough in my previous email.
>>> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
>>> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
>>> In other words,
>>>  * if "fileSize" is known:
>>>  ** both yours and mine patches don't change existing behavior;
>>>  * if "fileSize" is not known:
>>>  ** your patch makes streamOneP4File() not print anything;
>>>  ** my patch makes streamOneP4File() print "%s --> %s".
>>>
>>> Hope, I'm clearer this time.
>>>
>>> Thank you,
>>> Andrey
>>>
>>> From: Thandesha VK <thanvk@gmail.com>
>>>> *I* think keeping the filesize info is better with --verbose option as
>>>> that gives some clue about the file we are working on. What do you
>>>> think?
>>>> Script has similar checks of key existence at other places where it is
>>>> looking for fileSize.
>>>>
>>>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>>>> Huh, I actually have a slightly different fix for the same issue.
>>>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>>>
>>>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>>>
>>>>> Andrey Mazo (1):
>>>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>>>
>>>>>  git-p4.py | 8 ++++++--
>>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>
>>>>>
>>>>> base-commit: 468165c1d8a442994a825f3684528361727cd8c0
>>>>> --
>>>>> 2.16.1
>>>>>
>>>>
>>>> --
>>>> Thanks & Regards
>>>> Thandesha VK | Cellphone +1 (703) 459-5386
>>
>>
>>
>> --
>> Thanks & Regards
>> Thandesha VK | Cellphone +1 (703) 459-5386



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize'
       [not found]     ` <CAE5ih7-iQsBxM3Gn4B1Q9WZ2A0=eTHn9nt3a0LVURppOCQsAWA@mail.gmail.com>
@ 2018-04-17 21:18       ` Mazo, Andrey
  2018-04-17 21:24         ` Thandesha VK
  0 siblings, 1 reply; 15+ messages in thread
From: Mazo, Andrey @ 2018-04-17 21:18 UTC (permalink / raw)
  To: Luke Diamand
  Cc: George Vanburgh, larsxschneider@gmail.com,
	miguel.torroja@gmail.com, thanvk@gmail.com, Git Users

Luke,

Thank you for reviewing and acking my patch!
By the way, did you see Thandesha's proposed patch [1] to print a warning in case of the missing "fileSize" attribute?
Should we go that route instead?
Or should we try harder to get the size by running `p4 -G sizes`?

[1] https://public-inbox.org/git/CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com/t/#m6053d2031020e08edd24ada6c9eb49721ebc4e27

Thank you,
Andrey

From: Luke Diamand <luke@diamand.org>
> On Tue, 17 Apr 2018, 09:22 Andrey Mazo, <amazo@checkvideo.com> wrote:
>>  Perforce server 2007.2 (and maybe others) doesn't return "fileSize"
>> attribute in its reply to `p4 -G print` command.
>> This causes the following traceback when running `git p4 sync --verbose`:
>> """
>>     Traceback (most recent call last):
>>       File "/usr/libexec/git-core/git-p4", line 3839, in <module>
>>         main()
>>       File "/usr/libexec/git-core/git-p4", line 3833, in main
>>         if not cmd.run(args):
>>       File "/usr/libexec/git-core/git-p4", line 3567, in run
>>         self.importChanges(changes)
>>       File "/usr/libexec/git-core/git-p4", line 3233, in importChanges
>>         self.commit(description, filesForCommit, branch, parent)
>>       File "/usr/libexec/git-core/git-p4", line 2855, in commit
>>         self.streamP4Files(files)
>>       File "/usr/libexec/git-core/git-p4", line 2747, in streamP4Files
>>         cb=streamP4FilesCbSelf)
>>       File "/usr/libexec/git-core/git-p4", line 552, in p4CmdList
>>         cb(entry)
>>       File "/usr/libexec/git-core/git-p4", line 2741, in streamP4FilesCbSelf
>>         self.streamP4FilesCb(entry)
>>       File "/usr/libexec/git-core/git-p4", line 2689, in streamP4FilesCb
>>         self.streamOneP4File(self.stream_file, self.stream_contents)
>>       File "/usr/libexec/git-core/git-p4", line 2566, in streamOneP4File
>>         size = int(self.stream_file['fileSize'])
>>     KeyError: 'fileSize'
>> """
>> 
>> Fix this by omitting the file size information from the verbose print out.
>> Also, don't use "self.stream_file" directly,
>> but rather use passed in "file" argument.
>> (which point to the same "self.stream_file" for all existing callers)
>> 
>> Signed-off-by: Andrey Mazo <amazo@checkvideo.com>
>> ---
>>  git -p4.py | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/git-p4.py b/git-p4.py
>> index 7bb9cadc6..6f05f915a 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -2566,8 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>          relPath = self.encodeWithUTF8(relPath)
>>          if verbose:
>> -            size = int(self.stream_file['fileSize'])
>> -            sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
>> +            size = file.get('fileSize', None)
>> +            if size is None:
>> +                sizeStr = ''
>> +            else:
>> +                sizeStr = ' (%i MB)' % (int(size)/1024/1024)
>> +            sys.stdout.write('\r%s --> %s%s\n' % (file['depotFile'], relPath, sizeStr))
>>              sys.stdout.flush()
>> 
>>          (type_base, type_mods) = split_p4_type(file["type"])
>> -- 
>> 2.16.1
>>
> Thanks, that looks like a good fix to me.  Ack.

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

* Re: [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize'
  2018-04-17 21:18       ` Mazo, Andrey
@ 2018-04-17 21:24         ` Thandesha VK
  2018-04-17 21:38           ` Mazo, Andrey
  0 siblings, 1 reply; 15+ messages in thread
From: Thandesha VK @ 2018-04-17 21:24 UTC (permalink / raw)
  To: Mazo, Andrey
  Cc: Luke Diamand, George Vanburgh, larsxschneider@gmail.com,
	miguel.torroja@gmail.com, Git Users

My fix is for the case where p4 -G sizes not returning the key and
value for fileSize. This can happen in some cases. Only option at that
point of time is to warn the user about the problematic file and keep
moving (or should we abort??)

Thanks
Thandesha

On Tue, Apr 17, 2018 at 2:18 PM, Mazo, Andrey <amazo@checkvideo.com> wrote:
> Luke,
>
> Thank you for reviewing and acking my patch!
> By the way, did you see Thandesha's proposed patch [1] to print a warning in case of the missing "fileSize" attribute?
> Should we go that route instead?
> Or should we try harder to get the size by running `p4 -G sizes`?
>
> [1] https://public-inbox.org/git/CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com/t/#m6053d2031020e08edd24ada6c9eb49721ebc4e27
>
> Thank you,
> Andrey
>
> From: Luke Diamand <luke@diamand.org>
>> On Tue, 17 Apr 2018, 09:22 Andrey Mazo, <amazo@checkvideo.com> wrote:
>>>  Perforce server 2007.2 (and maybe others) doesn't return "fileSize"
>>> attribute in its reply to `p4 -G print` command.
>>> This causes the following traceback when running `git p4 sync --verbose`:
>>> """
>>>     Traceback (most recent call last):
>>>       File "/usr/libexec/git-core/git-p4", line 3839, in <module>
>>>         main()
>>>       File "/usr/libexec/git-core/git-p4", line 3833, in main
>>>         if not cmd.run(args):
>>>       File "/usr/libexec/git-core/git-p4", line 3567, in run
>>>         self.importChanges(changes)
>>>       File "/usr/libexec/git-core/git-p4", line 3233, in importChanges
>>>         self.commit(description, filesForCommit, branch, parent)
>>>       File "/usr/libexec/git-core/git-p4", line 2855, in commit
>>>         self.streamP4Files(files)
>>>       File "/usr/libexec/git-core/git-p4", line 2747, in streamP4Files
>>>         cb=streamP4FilesCbSelf)
>>>       File "/usr/libexec/git-core/git-p4", line 552, in p4CmdList
>>>         cb(entry)
>>>       File "/usr/libexec/git-core/git-p4", line 2741, in streamP4FilesCbSelf
>>>         self.streamP4FilesCb(entry)
>>>       File "/usr/libexec/git-core/git-p4", line 2689, in streamP4FilesCb
>>>         self.streamOneP4File(self.stream_file, self.stream_contents)
>>>       File "/usr/libexec/git-core/git-p4", line 2566, in streamOneP4File
>>>         size = int(self.stream_file['fileSize'])
>>>     KeyError: 'fileSize'
>>> """
>>>
>>> Fix this by omitting the file size information from the verbose print out.
>>> Also, don't use "self.stream_file" directly,
>>> but rather use passed in "file" argument.
>>> (which point to the same "self.stream_file" for all existing callers)
>>>
>>> Signed-off-by: Andrey Mazo <amazo@checkvideo.com>
>>> ---
>>>  git -p4.py | 8 ++++++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/git-p4.py b/git-p4.py
>>> index 7bb9cadc6..6f05f915a 100755
>>> --- a/git-p4.py
>>> +++ b/git-p4.py
>>> @@ -2566,8 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>>          relPath = self.encodeWithUTF8(relPath)
>>>          if verbose:
>>> -            size = int(self.stream_file['fileSize'])
>>> -            sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
>>> +            size = file.get('fileSize', None)
>>> +            if size is None:
>>> +                sizeStr = ''
>>> +            else:
>>> +                sizeStr = ' (%i MB)' % (int(size)/1024/1024)
>>> +            sys.stdout.write('\r%s --> %s%s\n' % (file['depotFile'], relPath, sizeStr))
>>>              sys.stdout.flush()
>>>
>>>          (type_base, type_mods) = split_p4_type(file["type"])
>>> --
>>> 2.16.1
>>>
>> Thanks, that looks like a good fix to me.  Ack.



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize'
  2018-04-17 21:24         ` Thandesha VK
@ 2018-04-17 21:38           ` Mazo, Andrey
  2018-04-17 22:29             ` Thandesha VK
  0 siblings, 1 reply; 15+ messages in thread
From: Mazo, Andrey @ 2018-04-17 21:38 UTC (permalink / raw)
  To: Thandesha VK
  Cc: Luke Diamand, George Vanburgh, larsxschneider@gmail.com,
	miguel.torroja@gmail.com, Git Users

Thandesha,

If I read your patch correctly, it adds a warning in case `p4 -G print` doesn't return "fileSize" (not `p4 sizes`).
I don't see `p4 sizes` being used by git-p4 at all.
As I said earlier, for our ancient Perforce server, `p4 -G print` _never_ returns "fileSize".
So, it's definitely not a reason to abort.

Thank you,
Andrey

From: Thandesha VK <thanvk@gmail.com>
> My fix is for the case where p4 -G sizes not returning the key and
> value for fileSize. This can happen in some cases. Only option at that
> point of time is to warn the user about the problematic file and keep
> moving (or should we abort??)
> 
> Thanks
> Thandesha
> 
> On Tue, Apr 17, 2018 at 2:18 PM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>> Luke,
>>
>> Thank you for reviewing and acking my patch!
>> By the way, did you see Thandesha's proposed patch [1] to print a warning in case of the missing "fileSize" attribute?
>> Should we go that route instead?
>> Or should we try harder to get the size by running `p4 -G sizes`?
>>
>> [1]  https://public-inbox.org/git/CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com/t/#m6053d2031020e08edd24ada6c9eb49721ebc4e27
>>
>> Thank you,
>> Andrey
>>
>> From: Luke Diamand <luke@diamand.org>
>>> On Tue, 17 Apr 2018, 09:22 Andrey Mazo, <amazo@checkvideo.com> wrote:
>>>>  Perforce server 2007.2 (and maybe others) doesn't return "fileSize"
>>>> attribute in its reply to `p4 -G print` command.
>>>> This causes the following traceback when running `git p4 sync --verbose`:
>>>> """
>>>>     Traceback (most recent call last):
>>>>       File "/usr/libexec/git-core/git-p4", line 3839, in <module>
>>>>         main()
>>>>       File "/usr/libexec/git-core/git-p4", line 3833, in main
>>>>         if not cmd.run(args):
>>>>       File "/usr/libexec/git-core/git-p4", line 3567, in run
>>>>         self.importChanges(changes)
>>>>       File "/usr/libexec/git-core/git-p4", line 3233, in importChanges
>>>>         self.commit(description, filesForCommit, branch, parent)
>>>>       File "/usr/libexec/git-core/git-p4", line 2855, in commit
>>>>         self.streamP4Files(files)
>>>>       File "/usr/libexec/git-core/git-p4", line 2747, in streamP4Files
>>>>         cb=streamP4FilesCbSelf)
>>>>       File "/usr/libexec/git-core/git-p4", line 552, in p4CmdList
>>>>         cb(entry)
>>>>       File "/usr/libexec/git-core/git-p4", line 2741, in streamP4FilesCbSelf
>>>>         self.streamP4FilesCb(entry)
>>>>       File "/usr/libexec/git-core/git-p4", line 2689, in streamP4FilesCb
>>>>         self.streamOneP4File(self.stream_file, self.stream_contents)
>>>>       File "/usr/libexec/git-core/git-p4", line 2566, in streamOneP4File
>>>>         size = int(self.stream_file['fileSize'])
>>>>     KeyError: 'fileSize'
>>>> """
>>>>
>>>> Fix this by omitting the file size information from the verbose print out.
>>>> Also, don't use "self.stream_file" directly,
>>>> but rather use passed in "file" argument.
>>>> (which point to the same "self.stream_file" for all existing callers)
>>>>
>>>> Signed-off-by: Andrey Mazo <amazo@checkvideo.com>
>>>> ---
>>>>  git -p4.py | 8 ++++++--
>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/git-p4.py b/git-p4.py
>>>> index 7bb9cadc6..6f05f915a 100755
>>>> --- a/git-p4.py
>>>> +++ b/git-p4.py
>>>> @@ -2566,8 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>>>          relPath = self.encodeWithUTF8(relPath)
>>>>          if verbose:
>>>> -            size = int(self.stream_file['fileSize'])
>>>> -            sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
>>>> +            size = file.get('fileSize', None)
>>>> +            if size is None:
>>>> +                sizeStr = ''
>>>> +            else:
>>>> +                sizeStr = ' (%i MB)' % (int(size)/1024/1024)
>>>> +            sys.stdout.write('\r%s --> %s%s\n' % (file['depotFile'], relPath, sizeStr))
>>>>              sys.stdout.flush()
>>>>
>>>>          (type_base, type_mods) = split_p4_type(file["type"])
>>>> --
>>>> 2.16.1
>>>>
>>> Thanks, that looks like a good fix to me.  Ack.
>
> -- 
> Thanks & Regards
> Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [PATCH 1/1] git-p4: fix `sync --verbose` traceback due to 'fileSize'
  2018-04-17 21:38           ` Mazo, Andrey
@ 2018-04-17 22:29             ` Thandesha VK
  0 siblings, 0 replies; 15+ messages in thread
From: Thandesha VK @ 2018-04-17 22:29 UTC (permalink / raw)
  To: Mazo, Andrey
  Cc: Luke Diamand, George Vanburgh, larsxschneider@gmail.com,
	miguel.torroja@gmail.com, Git Users

Ah. I didn't realize the script is not using p4 sizes to get the size.
I assumed that it is using p4 sizes. Now I am looking at it using p4
-G print.
However, when the stack trace happened, I verified what is wrong and
found out that the fileSize key is not returned for "p4 -G sizes"
command.


So what I am saying is that we cannot use p4 sizes in this case to
solve the problem as even p4 sizes will fail with the same fileSize
not found stack trace.
We can continue as this is not as Critical. However it is a good idea
to let user know that they need to take action to correct this file at
the perforce side.

So irrespective of we are using p4 print or p4 sizes, the fileSize is
not returned in some cases and warning or aborting is something we
need to do.
Just ignoring may not be a good choice.

On Tue, Apr 17, 2018 at 2:38 PM, Mazo, Andrey <amazo@checkvideo.com> wrote:
> Thandesha,
>
> If I read your patch correctly, it adds a warning in case `p4 -G print` doesn't return "fileSize" (not `p4 sizes`).
> I don't see `p4 sizes` being used by git-p4 at all.
> As I said earlier, for our ancient Perforce server, `p4 -G print` _never_ returns "fileSize".
> So, it's definitely not a reason to abort.
>
> Thank you,
> Andrey
>
> From: Thandesha VK <thanvk@gmail.com>
>> My fix is for the case where p4 -G sizes not returning the key and
>> value for fileSize. This can happen in some cases. Only option at that
>> point of time is to warn the user about the problematic file and keep
>> moving (or should we abort??)
>>
>> Thanks
>> Thandesha
>>
>> On Tue, Apr 17, 2018 at 2:18 PM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>>> Luke,
>>>
>>> Thank you for reviewing and acking my patch!
>>> By the way, did you see Thandesha's proposed patch [1] to print a warning in case of the missing "fileSize" attribute?
>>> Should we go that route instead?
>>> Or should we try harder to get the size by running `p4 -G sizes`?
>>>
>>> [1]  https://public-inbox.org/git/CAJJpmi-pLb4Qcka5aLKXA8B1VOZFFF+OAQ0fgUq9YviobRpYGg@mail.gmail.com/t/#m6053d2031020e08edd24ada6c9eb49721ebc4e27
>>>
>>> Thank you,
>>> Andrey
>>>
>>> From: Luke Diamand <luke@diamand.org>
>>>> On Tue, 17 Apr 2018, 09:22 Andrey Mazo, <amazo@checkvideo.com> wrote:
>>>>>  Perforce server 2007.2 (and maybe others) doesn't return "fileSize"
>>>>> attribute in its reply to `p4 -G print` command.
>>>>> This causes the following traceback when running `git p4 sync --verbose`:
>>>>> """
>>>>>     Traceback (most recent call last):
>>>>>       File "/usr/libexec/git-core/git-p4", line 3839, in <module>
>>>>>         main()
>>>>>       File "/usr/libexec/git-core/git-p4", line 3833, in main
>>>>>         if not cmd.run(args):
>>>>>       File "/usr/libexec/git-core/git-p4", line 3567, in run
>>>>>         self.importChanges(changes)
>>>>>       File "/usr/libexec/git-core/git-p4", line 3233, in importChanges
>>>>>         self.commit(description, filesForCommit, branch, parent)
>>>>>       File "/usr/libexec/git-core/git-p4", line 2855, in commit
>>>>>         self.streamP4Files(files)
>>>>>       File "/usr/libexec/git-core/git-p4", line 2747, in streamP4Files
>>>>>         cb=streamP4FilesCbSelf)
>>>>>       File "/usr/libexec/git-core/git-p4", line 552, in p4CmdList
>>>>>         cb(entry)
>>>>>       File "/usr/libexec/git-core/git-p4", line 2741, in streamP4FilesCbSelf
>>>>>         self.streamP4FilesCb(entry)
>>>>>       File "/usr/libexec/git-core/git-p4", line 2689, in streamP4FilesCb
>>>>>         self.streamOneP4File(self.stream_file, self.stream_contents)
>>>>>       File "/usr/libexec/git-core/git-p4", line 2566, in streamOneP4File
>>>>>         size = int(self.stream_file['fileSize'])
>>>>>     KeyError: 'fileSize'
>>>>> """
>>>>>
>>>>> Fix this by omitting the file size information from the verbose print out.
>>>>> Also, don't use "self.stream_file" directly,
>>>>> but rather use passed in "file" argument.
>>>>> (which point to the same "self.stream_file" for all existing callers)
>>>>>
>>>>> Signed-off-by: Andrey Mazo <amazo@checkvideo.com>
>>>>> ---
>>>>>  git -p4.py | 8 ++++++--
>>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/git-p4.py b/git-p4.py
>>>>> index 7bb9cadc6..6f05f915a 100755
>>>>> --- a/git-p4.py
>>>>> +++ b/git-p4.py
>>>>> @@ -2566,8 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>>>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>>>>          relPath = self.encodeWithUTF8(relPath)
>>>>>          if verbose:
>>>>> -            size = int(self.stream_file['fileSize'])
>>>>> -            sys.stdout.write('\r%s --> %s (%i MB)\n' % (file['depotFile'], relPath, size/1024/1024))
>>>>> +            size = file.get('fileSize', None)
>>>>> +            if size is None:
>>>>> +                sizeStr = ''
>>>>> +            else:
>>>>> +                sizeStr = ' (%i MB)' % (int(size)/1024/1024)
>>>>> +            sys.stdout.write('\r%s --> %s%s\n' % (file['depotFile'], relPath, sizeStr))
>>>>>              sys.stdout.flush()
>>>>>
>>>>>          (type_base, type_mods) = split_p4_type(file["type"])
>>>>> --
>>>>> 2.16.1
>>>>>
>>>> Thanks, that looks like a good fix to me.  Ack.
>>
>> --
>> Thanks & Regards
>> Thandesha VK | Cellphone +1 (703) 459-5386



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  2018-04-17 19:12           ` Thandesha VK
@ 2018-04-18 11:08             ` Luke Diamand
  2018-04-18 14:59               ` Thandesha VK
  0 siblings, 1 reply; 15+ messages in thread
From: Luke Diamand @ 2018-04-18 11:08 UTC (permalink / raw)
  To: Thandesha VK
  Cc: Mazo, Andrey, git@vger.kernel.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

On 17 April 2018 at 20:12, Thandesha VK <thanvk@gmail.com> wrote:
> I have few cases where even p4 -G sizes (or p4 sizes) is not returning
> the size value even with latest version of p4 (17.2). In that case, we
> have to regenerate the digest for file save it - It mean something is
> wrong with the file in perforce.

Just to be clear - git-p4 does not use the p4 "sizes" command anywhere AFAIK.

We are just talking about the output from "p4 print" and the
"fileSize" key, right?

Does that happen with the 17.2 version of p4?

> Regarding, sys.stdout.write v/s print, I see script using both of them
> without a common pattern. I can change it to whatever is more
> appropriate.

print() probably makes more sense; can we try to use the function form
so that we don't deliberately make the path to python3 harder (albeit
in a very tiny way).

>
> On Tue, Apr 17, 2018 at 11:47 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>> Does a missing "fileSize" actually mean that there is something wrong with the file?
>> Because, for me, `p4 -G print` doesn't print "fileSize" for _any_ file.
>> (which I attribute to our rather ancient (2007.2) Perforce server)
>> I'm not an expert in Perforce, so don't know for sure.

My 2015 version of p4d reports a fileSize.

>>
>> However, `p4 -G sizes` works fine even with our p4 server.
>> Should we then go one step further and use `p4 -G sizes` to obtain the "fileSize" when it's not returned by `p4 -G print`?
>> Or is it an overkill for a simple verbose print out?

If your server isn't reporting "fileSize" then there are a few other
places where I would expect git-p4 to also fail.

If we're going to support this very ancient version of p4d, then
gracefully handling a missing fileSize will be useful.

>>
>> Also, please, find one comment inline below.
>>
>> Thank you,
>> Andrey
>>
>> From: Thandesha VK <thanvk@gmail.com>
>>> Sounds good. How about an enhanced version of fix from both of us.
>>> This will let us know that something is not right with the file but
>>> will not bark
>>>
>>> $ git diff
>>> diff --git a/git-p4.py b/git-p4.py
>>> index 7bb9cadc6..df901976f 100755
>>> --- a/git-p4.py
>>> +++ b/git-p4.py
>>> @@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>>          relPath = self.encodeWithUTF8(relPath)
>>>          if verbose:
>>> -            size = int(self.stream_file['fileSize'])
>>> +            if 'fileSize' not in self.stream_file:
>>> +               print "WARN: File size from perforce unknown. Please verify by p4 sizes %s" %(file['depotFile'])
>> For whatever reason, the code below uses sys.stdout.write() instead of print().
>> Should it be used here for consistency as well?
>>
>>> +               size = "-1"
>>> +            else:
>>> +               size = self.stream_file['fileSize']
>>> +            size = int(size)
>>>              sys.stdout.write('\r%s --> %s (%i MB)\n' %
>>> (file['depotFile'], relPath, size/1024/1024))
>>>              sys.stdout.flush()
>>>
>>>
>>> On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>>>> Sure, I totally agree.
>>>> Sorry, I just wasn't clear enough in my previous email.
>>>> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
>>>> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
>>>> In other words,
>>>>  * if "fileSize" is known:
>>>>  ** both yours and mine patches don't change existing behavior;
>>>>  * if "fileSize" is not known:
>>>>  ** your patch makes streamOneP4File() not print anything;
>>>>  ** my patch makes streamOneP4File() print "%s --> %s".
>>>>
>>>> Hope, I'm clearer this time.
>>>>
>>>> Thank you,
>>>> Andrey
>>>>
>>>> From: Thandesha VK <thanvk@gmail.com>
>>>>> *I* think keeping the filesize info is better with --verbose option as
>>>>> that gives some clue about the file we are working on. What do you
>>>>> think?
>>>>> Script has similar checks of key existence at other places where it is
>>>>> looking for fileSize.
>>>>>
>>>>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>>>>> Huh, I actually have a slightly different fix for the same issue.
>>>>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>>>>
>>>>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>>>>
>>>>>> Andrey Mazo (1):
>>>>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>>>>
>>>>>>  git-p4.py | 8 ++++++--
>>>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>>

Thanks
Luke

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

* Re: [BUG] git p4 clone fails when p4 sizes does not return 'fileSize' key
  2018-04-18 11:08             ` Luke Diamand
@ 2018-04-18 14:59               ` Thandesha VK
  0 siblings, 0 replies; 15+ messages in thread
From: Thandesha VK @ 2018-04-18 14:59 UTC (permalink / raw)
  To: Luke Diamand
  Cc: Mazo, Andrey, git@vger.kernel.org, gvanburgh@bloomberg.net,
	larsxschneider@gmail.com, miguel.torroja@gmail.com

Just to be clear - git-p4 does not use the p4 "sizes" command anywhere AFAIK.

We are just talking about the output from "p4 print" and the
"fileSize" key, right?
--> Correct.

Does that happen with the 17.2 version of p4?
-->Correct.

print() probably makes more sense; can we try to use the function form
so that we don't deliberately make the path to python3 harder (albeit
in a very tiny way)
-->Sure.

If your server isn't reporting "fileSize" then there are a few other
places where I would expect git-p4 to also fail.
-->Most of other places are already doing key check in the hash. Looks
like this line was missed out.

On Wed, Apr 18, 2018 at 4:08 AM, Luke Diamand <luke@diamand.org> wrote:
> On 17 April 2018 at 20:12, Thandesha VK <thanvk@gmail.com> wrote:
>> I have few cases where even p4 -G sizes (or p4 sizes) is not returning
>> the size value even with latest version of p4 (17.2). In that case, we
>> have to regenerate the digest for file save it - It mean something is
>> wrong with the file in perforce.
>
> Just to be clear - git-p4 does not use the p4 "sizes" command anywhere AFAIK.
>
> We are just talking about the output from "p4 print" and the
> "fileSize" key, right?
>
> Does that happen with the 17.2 version of p4?
>
>> Regarding, sys.stdout.write v/s print, I see script using both of them
>> without a common pattern. I can change it to whatever is more
>> appropriate.
>
> print() probably makes more sense; can we try to use the function form
> so that we don't deliberately make the path to python3 harder (albeit
> in a very tiny way).
>
>>
>> On Tue, Apr 17, 2018 at 11:47 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>>> Does a missing "fileSize" actually mean that there is something wrong with the file?
>>> Because, for me, `p4 -G print` doesn't print "fileSize" for _any_ file.
>>> (which I attribute to our rather ancient (2007.2) Perforce server)
>>> I'm not an expert in Perforce, so don't know for sure.
>
> My 2015 version of p4d reports a fileSize.
>
>>>
>>> However, `p4 -G sizes` works fine even with our p4 server.
>>> Should we then go one step further and use `p4 -G sizes` to obtain the "fileSize" when it's not returned by `p4 -G print`?
>>> Or is it an overkill for a simple verbose print out?
>
> If your server isn't reporting "fileSize" then there are a few other
> places where I would expect git-p4 to also fail.
>
> If we're going to support this very ancient version of p4d, then
> gracefully handling a missing fileSize will be useful.
>
>>>
>>> Also, please, find one comment inline below.
>>>
>>> Thank you,
>>> Andrey
>>>
>>> From: Thandesha VK <thanvk@gmail.com>
>>>> Sounds good. How about an enhanced version of fix from both of us.
>>>> This will let us know that something is not right with the file but
>>>> will not bark
>>>>
>>>> $ git diff
>>>> diff --git a/git-p4.py b/git-p4.py
>>>> index 7bb9cadc6..df901976f 100755
>>>> --- a/git-p4.py
>>>> +++ b/git-p4.py
>>>> @@ -2566,7 +2566,12 @@ class P4Sync(Command, P4UserMap):
>>>>          relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
>>>>          relPath = self.encodeWithUTF8(relPath)
>>>>          if verbose:
>>>> -            size = int(self.stream_file['fileSize'])
>>>> +            if 'fileSize' not in self.stream_file:
>>>> +               print "WARN: File size from perforce unknown. Please verify by p4 sizes %s" %(file['depotFile'])
>>> For whatever reason, the code below uses sys.stdout.write() instead of print().
>>> Should it be used here for consistency as well?
>>>
>>>> +               size = "-1"
>>>> +            else:
>>>> +               size = self.stream_file['fileSize']
>>>> +            size = int(size)
>>>>              sys.stdout.write('\r%s --> %s (%i MB)\n' %
>>>> (file['depotFile'], relPath, size/1024/1024))
>>>>              sys.stdout.flush()
>>>>
>>>>
>>>> On Tue, Apr 17, 2018 at 10:33 AM, Mazo, Andrey <amazo@checkvideo.com> wrote:
>>>>> Sure, I totally agree.
>>>>> Sorry, I just wasn't clear enough in my previous email.
>>>>> I meant that your patch suppresses "%s --> %s (%i MB)" line in case "fileSize" is not available,
>>>>> while my patch suppresses just "(%i MB)" portion if the "fileSize" is not known.
>>>>> In other words,
>>>>>  * if "fileSize" is known:
>>>>>  ** both yours and mine patches don't change existing behavior;
>>>>>  * if "fileSize" is not known:
>>>>>  ** your patch makes streamOneP4File() not print anything;
>>>>>  ** my patch makes streamOneP4File() print "%s --> %s".
>>>>>
>>>>> Hope, I'm clearer this time.
>>>>>
>>>>> Thank you,
>>>>> Andrey
>>>>>
>>>>> From: Thandesha VK <thanvk@gmail.com>
>>>>>> *I* think keeping the filesize info is better with --verbose option as
>>>>>> that gives some clue about the file we are working on. What do you
>>>>>> think?
>>>>>> Script has similar checks of key existence at other places where it is
>>>>>> looking for fileSize.
>>>>>>
>>>>>> On Tue, Apr 17, 2018 at 9:22 AM, Andrey Mazo <amazo@checkvideo.com> wrote:
>>>>>>> Huh, I actually have a slightly different fix for the same issue.
>>>>>>> It doesn't suppress the corresponding verbose output completely, but just removes the size information from it.
>>>>>>>
>>>>>>> Also, I'd mention that the workaround is trivial -- simply omit the "--verbose" option.
>>>>>>>
>>>>>>> Andrey Mazo (1):
>>>>>>>   git-p4: fix `sync --verbose` traceback due to 'fileSize'
>>>>>>>
>>>>>>>  git-p4.py | 8 ++++++--
>>>>>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>>>
>
> Thanks
> Luke



-- 
Thanks & Regards
Thandesha VK | Cellphone +1 (703) 459-5386

^ 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).