Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349739

Summary: Invalid value returned when getting GitArtifact full path
Product: z_Archived Reporter: Sebastien Dubois <sebastien.dubois>
Component: MylynAssignee: Sebastien Dubois <sebastien.dubois>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: alvaro.sanchez-leon, lmcbout, steffen.pingel
Version: unspecified   
Target Milestone: 0.9   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Bug Depends on:    
Bug Blocks: 348719    
Attachments:
Description Flags
tentative solution for bug 349739
none
updated comments in code none

Description Sebastien Dubois CLA 2011-06-17 17:51:09 EDT
There is a problem in the Git Connector where the path returned when getting a FileRevision full storage path is invalid.  The returned path is missing the root of the Git Repository (i.e. is starts one level too low).  This can cause multiple problems that could be very hard to track.  In our case, when using R4E to import Git Files as review item components for a Review, this could cause the compare editor to open the wrong file versions and show incorrect information.

So for example the following code will not return the correct path in artifactPath

IPath artifactPath = scmArtifact.getFileRevision(null).getStorage(null).getFullPath();

The solution is to prepend the repository path to the artifact path.  Take note that this is done correctly in Egit, but not in Mylyn Versions Git connector.
Comment 1 Sebastien Dubois CLA 2011-06-17 17:53:26 EDT
Created attachment 198220 [details]
tentative solution for bug 349739

This is a tentative solution for bug 349739
Comment 2 Sebastien Dubois CLA 2011-06-17 17:55:41 EDT
Take note that I have included a tentative solution for this bug.  Since I cannot commit changes to mylyn versions (I am not a committer on this project), I would like it to be reviewed and included ASAP.

Thanks,
/Sebastien
Comment 3 Sebastien Dubois CLA 2011-06-17 18:02:58 EDT
Created attachment 198221 [details]
updated comments in code
Comment 4 Alvaro Sanchez-Leon CLA 2011-06-24 22:00:35 EDT
I have made a quick check on the serialized data and I don't see any segments missing e.g. I used the R4E commit, 2011-Jun-17, 09:51:49, id: e5376d6..

See the repository paths below, they start with r4e which is the correct folder relative to the root of the repository.
Please clarify what's missing.

  <r4ecore:R4EFileVersion xmi:id="_CUCfQ57JEeCvAPj6HzzVzA" platformURI="platform:/resource/org.eclipse.mylyn.reviews.r4e.core/src/org/eclipse/mylyn/reviews/r4e/core/model/impl/RModelFactoryImpl.java" versionID="d26261e5d1552c35eecd3925a1b0332d8883e817" repositoryPath="r4e/org.eclipse.mylyn.reviews.r4e.core/src/org/eclipse/mylyn/reviews/r4e/core/model/impl/RModelFactoryImpl.java" name="RModelFactoryImpl.java" localVersionID="d26261e5d1552c35eecd3925a1b0332d8883e817" fileRevision="org.eclipse.mylyn.reviews.r4e.core.rfs.ReviewsRFSProxy$1@128537b"/>
  <r4ecore:R4EFileVersion xmi:id="_CU73IJ7JEeCvAPj6HzzVzA" platformURI="platform:/resource/org.eclipse.mylyn.reviews.r4e.core/src/org/eclipse/mylyn/reviews/r4e/core/model/impl/RModelFactoryImpl.java" versionID="d9c767a3b760930e1488d2b71f887b02ffa93984" repositoryPath="r4e/org.eclipse.mylyn.reviews.r4e.core/src/org/eclipse/mylyn/reviews/r4e/core/model/impl/RModelFactoryImpl.java" name="RModelFactoryImpl.java" localVersionID="d9c767a3b760930e1488d2b71f887b02ffa93984" fileRevision="org.eclipse.mylyn.reviews.r4e.core.rfs.ReviewsRFSProxy$1@6735fd"/>
  <r4ecore:R4EFileContext xmi:id="_CY80cJ7JEeCvAPj6HzzVzA" type="R4E_MODIFIED">
Comment 5 Sebastien Dubois CLA 2011-06-24 22:31:48 EDT
Like I said it works for R4E by luck, because R4E has a subdirectory r4e below the root repository.  But for project that do not have this e.g. JGit this will not work.  

You can easily reproduce the problem by trying to use commits from JGit.  

Also take note that, as I also stated above, EGit does the right thing.  The Mylyn Versions Git connector does not.
Comment 6 Sebastien Dubois CLA 2011-06-27 14:22:40 EDT
After investigating a little bit more, it appears that the EGit behavior is only valid for indexed files.  This means that the real solution to the problem is to fetch the correct contents from the local R4E repository when opening the comapre editor.
So the implementation of the solution is done on R4E and the bug is being moved accordingly
Comment 7 Sebastien Dubois CLA 2011-06-27 14:41:24 EDT
Fixed is now available