DESCRIPTION

Consider the ancestor when comparing with remote revisions

This changes all of the actions where comparing with a common ancestor
makes sense :
- Compare With > Commit
- Compare With > Branch, Tag, Reference
- Double-click a commit in the history view
- Right-click a commit in the history view > Compare With Workspace
- Right-click a file in the history view > Compare With Workspace
- Right-clik a file in the commit viewer > Compare With Workspace

Bug: 400943
Change-Id: I26bce7a1bde3b944f10f40eacbbdb7c41e486c0b


COMMENTS

author: Gustavo Green
date: 2013-02-19 08:33:59.000000000

Uploaded patch set 2.

-------------------------------------
author: Brenden Conley
date: 2013-02-19 08:34:04.000000000

Patch Set 2:

Build Started https://hudson.eclipse.org/sandbox/job/egit.gerrit/4210/ 

-------------------------------------
author: Brenden Conley
date: 2013-02-19 08:47:37.000000000

Patch Set 2: I would prefer that you didn't submit this

Build Unstable 

https://hudson.eclipse.org/sandbox/job/egit.gerrit/4210/ : UNSTABLE

-------------------------------------
author: Carlie Harper
date: 2013-02-21 10:08:07.000000000

Patch Set 2:

I had implemented three-way-compare for most of your cases. Please see
https://git.eclipse.org/r/#/c/8487/

I think most of your scenarios above work already.
Only 

- Compare With > Branch, Tag, Reference
- Right-clik a file in the commit viewer > Compare With Workspace
seem to be missing

But I agree, a refactoring makes sense. I'll have a closer look soon.

-------------------------------------
author: Gustavo Green
date: 2013-02-21 10:10:53.000000000

Patch Set 2:

Stefan,

Yes, some of the cases were already working. As you pointed out only two of them were not taking the ancestor into account.

The only reason I changed "all" was to factorize the code as much as possible since in the end the need is the same (and the code is 'almost' identical :).

-------------------------------------
author: Carlie Harper
date: 2013-02-21 13:53:53.000000000

Patch Set 2:

Hi Laurent,

this sounds very good. Maybe you could write that into the commit message. Now it is a little bit misleading, it does not tell clearly what this change is about.

Stefan

-------------------------------------
author: Gustavo Green
date: 2013-02-21 14:27:01.000000000

Patch Set 2:

I did not want to put in too much info in the commit message either :). I will add a paragraph to mention which were previously failing and which were only refactored.

If that's okay with you, I'll only push this change when the rest of the review is complete, that will avoid too many patch sets.

-------------------------------------
author: Carlie Harper
date: 2013-02-21 15:34:24.000000000

Patch Set 2: I would prefer that you didn't submit this

(3 inline comments)

Overall great work.

Please have a look at my inline comments.

Line:392, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> s/direction/directory/

Line:467, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> There is now a lot of duplicate code with the method above. Please refactor out the common code.

Line:556, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java -> I just wonder if that would also work with 
CompareUtils.compareWorkspaceWithRef(getRepository(), file,
commit.getName(), null);

 with file being an instance of java.io.file.

-------------------------------------
author: Gustavo Green
date: 2013-02-21 15:41:35.000000000

Patch Set 2:

I did my best to refactor the existing code so as to factorize it as much as possible ... and still managed to forget that my own code was duplicating a lot of common lines :).

Fixing this asap.

-------------------------------------
author: Gustavo Green
date: 2013-02-21 15:48:34.000000000

Patch Set 2: (1 inline comment)

ha .... replies to in-line comments need to be "published" along with a review too. Sorry for the two comments in a row, I am quite new to gerrit.

Line:556, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java -> I have to admit that I did not understand why this one method was coded so differently from the others. Had I had unit tests to check, I probably would have changed it to use what we now have in CompareUtils.

I'll try and test this point in more depth to see whether it can be changed to the common code.

-------------------------------------
author: Douglas Trujillo
date: 2013-02-21 23:03:52.000000000

Patch Set 2: I would prefer that you didn't submit this

(11 inline comments)



Line:397, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> maybe shorter: The repository to load file revisions from

Line:400, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> File to compare revisions for

Line:402, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> Reference to compare with the workspace version of xxx@xxx.xxx file}

Line:406, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> if not xxx@xxx.xxx try to re-use a compare editor on this page if any is available. Otherwise open a new one.

Line:439, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> style nit: we don't use braces around single line blocks

Line:455, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> see above

Line:457, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> see above

Line:461, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> see above

Line:465, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> if HEAD or xxx@xxx.xxx refName} can't be resolved in the given repository.

Line:496, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java -> no braces here

Line:556, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java -> please add missing tests

-------------------------------------
author: Gustavo Green
date: 2013-02-22 11:32:37.000000000

Patch Set 2:

Matthias, Stefan,

While refactoring the "CommitFileDiffViewer" and testing in more details, I stumbled over a few things I would consider as bugs :

There are four actions that can trigger a comparison with a file that is not in the workspace; the last four I mentionned in the commit message.

The first two are failing with the current implementation because of a regression introduced by commit 5246f10 2 years ago. See this line exactly ( http://git.eclipse.org/c/egit/egit.git/tree/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java#n74 ) that sets the input of the history page to a Boolean instead of a File. I'm fixing this with the next push for this review.

However, even when I fix that issue, a second one appears : the first of these two actions are comparing "HEAD" with the selected commit, while the last two compare "the local file" with the selected commit. I believe that the desired behavior is to compare the working directory, not HEAD, so I'll harmonize all four actions to have that behavior.

Unit tests would have caught that, but I am not familiar with SWTBot, so what I'll push here will only be the code, manually tested on my end.

-------------------------------------
