Community
Participate
Working Groups
The Synchronize View uses the current HEAD as the base for the comparison. For explanation please see this simple example together with the screen shot of the three-way compare triggered from the synchronize view: <example> ! [branch1] Change in branch1 * [master] Change in master -- * [master] Change in master + [branch1] Change in branch1 +* [master^] Create class Fritz.java I had added a comment to the class Fritz.java both in branch1 and in master. Then I synronized master with branch1. As base version I expect master^. However, as can be seen in the screen shot, the content of master is displayed there. </example> The reason seems to be that GitResourceVariantTreeSubscriber returns the content of the current HEAD in the method getBaseTree(). This is in my opinion not the correct implementation when we compare two branches. I would suggest the following solution: Return the content of the common base commit of the HEAD and the other branch here. The common base can be found using a RevWalk using RevFilter.MERGE_BASE. You can look at the class org.eclipse.jgit.revwalk.RevWalkMergeBaseTest for an example. We should discuss the (rather exotic) case of multiple merge bases with Shawn and the other JGit experts. I think that with this approach a lot of coding in GitSyncInfo and GitResourceVariantComparator would be way easier. In GitInfo we could get rid of the strange traversal over the commit lists in calculateDescBasedOnGitCommits. I would even assume that the algorithm in calculateKind() of the base class SyncInfo would already do the most of the work.
Created attachment 172726 [details] Three way compare in synchronize view The creation of the attachment had failed during bug creation.
I'm currently working on this issue.My idea was to implement whole structure of IProject, IFile, IContainer, IFolder and IResource so that this implementation can read data from Git and return this when team framework calls roots() method on GitResourceVariantTreeSubscriber. But Stefan's approach seams to be easier, therefore I'll switch and try to implement this as it is suggested.
I think that I've manage to fix this issue. As Stefan suggested I used RevWalk with RevFilter.MERGE_BASE. Additionally I've added Git implementations for eclipse's resource interfaces (IResource, IContainer, IFile and so on) to be able return IResource[] in GitResourceVariantTree.members(). I think that this change will be ready to publish in two or three days. This code really need to be refactored ;), also tests need to be written.
Created attachment 172865 [details] Presentation of fixed three-way compare view
I hit a race condition some how ... when synchronization stops on break points for debuging result is returned properly, but when I remove break points synchronization says "no changes found"; in some cases . This is quite huge problem because synchronization process is quite complicated :|
I've manage to fix this issue (actually this was my mistake because remote resource variants had a reference to local resource content instead of content obtained from git). My patch set desperately need some cleaning and refactoring (before I'll publish it). I'll continue working on it and push it as fast as I can.
I've already pushed patch for this issue for code review: http://egit.eclipse.org/r/#change,1064
I created a CQ for this change... https://dev.eclipse.org/ipzilla/show_bug.cgi?id=4390
Dariusz could you make the necessary confirmations for the IP review as a comment to this bug: a. authored 100% b. has the rights to donate the content to Eclipse c. contributes the content under the EPL
(In reply to comment #9) > a. authored 100% Yes, this code is 100% authored by me > b. has the rights to donate the content to Eclipse Yes, I have full right to donate this code to Eclipse > c. contributes the content under the EPL Yes, it is contributed under EPL
Fixed with. 986e3823e1e3555bda426b3b09bd790d4595113a. Thanks Dariusz!