Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-09-25 18:45:22 -0400
committerGerrit Code Review @ Eclipse.org2013-09-26 15:18:00 -0400
commit3bfadd0f4253f5d30433b04691c35ef25bcfc4bd (patch)
treeedcea33da1a83af9ca2f9ad04faf3572349e5c7f
parentcbd0af1664fa3e4efd47745b14b28a619149ae54 (diff)
downloadegit-3bfadd0f4253f5d30433b04691c35ef25bcfc4bd.tar.gz
egit-3bfadd0f4253f5d30433b04691c35ef25bcfc4bd.tar.xz
egit-3bfadd0f4253f5d30433b04691c35ef25bcfc4bd.zip
Fix regression of switched sides in "Compare with Version in Ancestor"
In EGit 3.0, the "new" state was shown on the left and the "old" on the right, which is consistent with other Eclipse usage, see bug 213780. In the fix for bug 416808, the sides were switched (probably not intentionally). This restores the order and also renames the parameters in the compare methods to be more clear. It's now also more consistent with how includeLocal is handled, as local is shown on the left and uses the "old" parameter for the right side. Bug: 418029 Change-Id: I4288fac38a3681638601a8fd81f30f5210bdcaa3 Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java61
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java40
2 files changed, 51 insertions, 50 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
index 878d845f31..d898ba952c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
@@ -519,11 +519,12 @@ public class CompareUtils {
* we'll synchronize the whole repository).
* @param repository
* The repository to load file revisions from.
- * @param srcRev
- * Source revision of the comparison (or "left" side). Won't be
- * used if <code>includeLocal</code> is <code>true</code>.
- * @param dstRev
- * Destination revision of the comparison ("right" side).
+ * @param leftRev
+ * Left revision of the comparison (usually the local or "new"
+ * revision). Won't be used if <code>includeLocal</code> is
+ * <code>true</code>.
+ * @param rightRev
+ * Right revision of the comparison (usually the "old" revision).
* @param includeLocal
* If <code>true</code>, this will use the local data as the
* "left" side of the comparison.
@@ -533,25 +534,24 @@ public class CompareUtils {
* @throws IOException
*/
public static void compare(IResource[] resources, Repository repository,
- String srcRev, String dstRev, boolean includeLocal,
+ String leftRev, String rightRev, boolean includeLocal,
IWorkbenchPage page) throws IOException {
if (resources.length == 1 && resources[0] instanceof IFile
&& canDirectlyOpenInCompare((IFile) resources[0])) {
if (includeLocal)
compareWorkspaceWithRef(repository, (IFile) resources[0],
- dstRev, page);
+ rightRev, page);
else {
final IFile file = (IFile) resources[0];
final RepositoryMapping mapping = RepositoryMapping
.getMapping(file);
final String gitPath = mapping.getRepoRelativePath(file);
- compareBetween(repository, gitPath, srcRev,
- dstRev, page);
+ compareBetween(repository, gitPath, leftRev, rightRev, page);
}
} else
- GitModelSynchronize.synchronize(resources, repository, srcRev,
- dstRev, includeLocal);
+ GitModelSynchronize.synchronize(resources, repository, leftRev,
+ rightRev, includeLocal);
}
/**
@@ -561,11 +561,12 @@ public class CompareUtils {
* Location of the file to compare.
* @param repository
* The repository to load file revisions from.
- * @param srcRev
- * Source revision of the comparison (or "left" side). Won't be
- * used if <code>includeLocal</code> is <code>true</code>.
- * @param dstRev
- * Destination revision of the comparison ("right" side).
+ * @param leftRev
+ * Left revision of the comparison (usually the local or "new"
+ * revision). Won't be used if <code>includeLocal</code> is
+ * <code>true</code>.
+ * @param rightRev
+ * Right revision of the comparison (usually the "old" revision).
* @param includeLocal
* If <code>true</code>, this will use the local data as the
* "left" side of the comparison.
@@ -575,37 +576,37 @@ public class CompareUtils {
* @throws IOException
*/
public static void compare(IPath location, Repository repository,
- String srcRev, String dstRev, boolean includeLocal,
+ String leftRev, String rightRev, boolean includeLocal,
IWorkbenchPage page) throws IOException {
if (includeLocal)
- compareLocalWithRef(repository, location, dstRev, page);
+ compareLocalWithRef(repository, location, rightRev, page);
else {
final String gitPath = RepositoryMapping.getMapping(location)
.getRepoRelativePath(location);
- compareBetween(repository, gitPath, srcRev, dstRev, page);
+ compareBetween(repository, gitPath, leftRev, rightRev, page);
}
}
private static void compareBetween(Repository repository, String gitPath,
- String srcRev, String dstRev, IWorkbenchPage page)
+ String leftRev, String rightRev, IWorkbenchPage page)
throws IOException {
- final ITypedElement src = getTypedElementFor(repository, gitPath,
- srcRev);
- final ITypedElement dst = getTypedElementFor(repository, gitPath,
- dstRev);
+ final ITypedElement left = getTypedElementFor(repository, gitPath,
+ leftRev);
+ final ITypedElement right = getTypedElementFor(repository, gitPath,
+ rightRev);
final ITypedElement commonAncestor;
- if (src != null && dst != null && !GitFileRevision.INDEX.equals(srcRev)
- && !GitFileRevision.INDEX.equals(dstRev))
+ if (left != null && right != null && !GitFileRevision.INDEX.equals(leftRev)
+ && !GitFileRevision.INDEX.equals(rightRev))
commonAncestor = getTypedElementForCommonAncestor(repository,
- gitPath, srcRev, dstRev);
+ gitPath, leftRev, rightRev);
else
commonAncestor = null;
final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
- src, dst, commonAncestor, null);
- in.getCompareConfiguration().setLeftLabel(srcRev);
- in.getCompareConfiguration().setRightLabel(dstRev);
+ left, right, commonAncestor, null);
+ in.getCompareConfiguration().setLeftLabel(leftRev);
+ in.getCompareConfiguration().setRightLabel(rightRev);
if (page != null)
openInCompare(page, in);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
index 7bdaed3e2d..08e807a43c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
@@ -490,41 +490,41 @@ public class CommitFileDiffViewer extends TableViewer {
final RevCommit c = d.getCommit();
// extract commits
- final RevCommit leftCommit;
- final ObjectId baseObjectId;
+ final RevCommit oldCommit;
+ final ObjectId oldObjectId;
if (d.getBlobs().length == 2 && !d.getChange().equals(ChangeType.ADD)) {
- leftCommit = c.getParent(0);
- baseObjectId = d.getBlobs()[0];
+ oldCommit = c.getParent(0);
+ oldObjectId = d.getBlobs()[0];
} else {
// Initial import
- leftCommit = null;
- baseObjectId = null;
+ oldCommit = null;
+ oldObjectId = null;
}
- final RevCommit rightCommit;
- final ObjectId rightObjectId;
+ final RevCommit newCommit;
+ final ObjectId newObjectId;
if (d.getChange().equals(ChangeType.DELETE)) {
- rightCommit = null;
- rightObjectId = null;
+ newCommit = null;
+ newObjectId = null;
} else {
- rightCommit = c;
- rightObjectId = d.getBlobs()[1];
+ newCommit = c;
+ newObjectId = d.getBlobs()[1];
}
IWorkbenchPage page = site.getWorkbenchWindow().getActivePage();
- if (leftCommit != null && rightCommit != null) {
+ if (oldCommit != null && newCommit != null) {
IFile file = ResourceUtil.getFileForLocation(getRepository(), np);
try {
if (file != null) {
IResource[] resources = new IResource[] { file, };
CompareUtils.compare(resources, getRepository(),
- leftCommit.getName(), rightCommit.getName(), false,
+ newCommit.getName(), oldCommit.getName(), false,
page);
} else {
IPath location = new Path(getRepository().getWorkTree()
.getAbsolutePath()).append(np);
CompareUtils.compare(location, getRepository(),
- leftCommit.getName(), rightCommit.getName(), false,
+ newCommit.getName(), oldCommit.getName(), false,
page);
}
} catch (Exception e) {
@@ -535,12 +535,12 @@ public class CommitFileDiffViewer extends TableViewer {
}
// still happens on initial commits
- final ITypedElement base = createTypedElement(op, leftCommit,
- baseObjectId);
- final ITypedElement next = createTypedElement(np, rightCommit,
- rightObjectId);
+ final ITypedElement oldSide = createTypedElement(op, oldCommit,
+ oldObjectId);
+ final ITypedElement newSide = createTypedElement(np, newCommit,
+ newObjectId);
CompareUtils.openInCompare(page, new GitCompareFileRevisionEditorInput(
- next, base, null));
+ newSide, oldSide, null));
}
private ITypedElement createTypedElement(final String path,

Back to the top