lm1 / git-p4s

Import Perforce stream history into a git repository.
13 stars 2 forks source link

Exception in git-p4s.py sync #1

Open jthomaskerr opened 10 years ago

jthomaskerr commented 10 years ago

Hi,

I am trying to initialise a repo with a number of streams from our p4 depot.

git-p4s.py sync //spfw/Main //spfw/sp16 //spfw/sp16_rtos //spfw/ppth //spfw/sp17 //spfw/neos_test //spfw/logos-test //spfw/ATBaha

The process gets to about 20% and then it dies with the following error:

  Traceback (most recent call last):
     File "/Users/joseph/etc/bin/git-p4s.py", line 1459, in <module>
        main()
     File "/Users/joseph/etc/bin/git-p4s.py", line 1455, in main
        if not cmd.run():
     File "/Users/joseph/etc/bin/git-p4s.py", line 1414, in run
      self.importChanges(allChanges)
    File "/Users/joseph/etc/bin/git-p4s.py", line 1299, in importChanges
      self.importChange(stream, details)
    File "/Users/joseph/etc/bin/git-p4s.py", line 1274, in importChange
      merges = self.detectMerges(depotpath, change, files, integrates)
    File "/Users/joseph/etc/bin/git-p4s.py", line 1229, in detectMerges
      if self.isMergeFrom(stream, change, srcStream, srcChange):
    File "/Users/joseph/etc/bin/git-p4s.py", line 1194, in isMergeFrom
      if diff[0]["code"] == "error":
  IndexError: list index out of range

In debugging I find that the p4 command raises an EOFError without adding any results (not surprising given the -q flag). When running the p4 command manually I see that every result entry gives "identical".

Consequently, I have worked around the issue (I hope) by adding a condition that returns true if diff is empty:

        if not diff:
            return True

Is this correct?

lm1 commented 10 years ago

Thank you for the debug. The assumption was that p4 diff2 (due to -G) always returns some object and there is a test for equal tree. This seems to be working for stream "copy" at least -- but perhaps this is not always the case. What p4 client/server versions are you using?

Unfortunately p4 command line documentation is not comprehensive, therefore it's not clear whether this is a valid result. Is there anything special about the failing case beside that the trees are identical?

If diff2 result is indeed empty a complete fix should probably also include a check for p4 command return code (currently it is ignored due to the ignore_error flag passed to p4CmdList). Pull request is welcome.

jthomaskerr commented 10 years ago

P4 client: Rev. P4/MACOSX105X86_64/2013.3/740675 (2013/11/11). Server version: P4D/NTX64/2013.1/659207 (2013/06/18)

I'll organise the fix and get back to you.