From 9e1b64bd3e0608abaa24f665f899cf3a0467eb0b Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Fri, 2 Dec 2011 14:27:51 +0100 Subject: [PATCH 1/5] Fix History rendering There was the possibility that during history rendering we draw a lane "trough" a passed commit. Vadim Dmitriev found that out in bug 335818. I added the needed check to that block of code where it was missing. Bug: 335818 Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f Signed-off-by: Christian Halstrick --- .../eclipse/jgit/revplot/PlotCommitList.java | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java index 6ffa0336a..e8263c5a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java @@ -141,6 +141,7 @@ public class PlotCommitList extends } currCommit.lane = c.lane; + handleBlockedLanes(index, currCommit, nChildren); } else { // More than one child, or our child is a merge. // Use a different lane. @@ -189,39 +190,50 @@ public class PlotCommitList extends currCommit.lane = nextFreeLane(); activeLanes.add(currCommit.lane); - // take care: when connecting yourself to your child make sure that - // you will not be located on a lane on which a passed commit is - // located on. Otherwise we would have to draw a line through a - // commit. - int remaining = nChildren; - BitSet blockedPositions = new BitSet(); - for (int r = index - 1; r >= 0; r--) { - final PlotCommit rObj = get(r); - if (currCommit.isChild(rObj)) { - if (--remaining == 0) - break; - } - if (rObj != null) { - PlotLane lane = rObj.getLane(); - if (lane != null) - blockedPositions.set(lane.getPosition()); - rObj.addPassingLane(currCommit.lane); - } + handleBlockedLanes(index, currCommit, nChildren); + } + } + + /** + * when connecting a plotcommit to the child make sure that you will not be + * located on a lane on which a passed commit is located on. Otherwise we + * would have to draw a line through a commit. + * + * @param index + * @param commit + * @param nChildren + */ + private void handleBlockedLanes(final int index, + final PlotCommit commit, final int nChildren) { + // take care: + int remaining = nChildren; + BitSet blockedPositions = new BitSet(); + for (int r = index - 1; r >= 0; r--) { + final PlotCommit rObj = get(r); + if (commit.isChild(rObj)) { + if (--remaining == 0) + break; } - // Now let's check whether we have to reposition the lane - if (blockedPositions.get(currCommit.lane.getPosition())) { - int newPos = -1; - for (Integer pos : freePositions) - if (!blockedPositions.get(pos)) { - newPos = pos; - break; - } - if (newPos == -1) - newPos = positionsAllocated++; - freePositions.add(currCommit.lane.getPosition()); - currCommit.lane.position = newPos; + if (rObj != null) { + PlotLane lane = rObj.getLane(); + if (lane != null) + blockedPositions.set(lane.getPosition()); + rObj.addPassingLane(commit.lane); } } + // Now let's check whether we have to reposition the lane + if (blockedPositions.get(commit.lane.getPosition())) { + int newPos = -1; + for (Integer pos : freePositions) + if (!blockedPositions.get(pos)) { + newPos = pos; + break; + } + if (newPos == -1) + newPos = positionsAllocated++; + freePositions.add(commit.lane.getPosition()); + commit.lane.position = newPos; + } } private void closeLane(PlotLane lane) { From 251bc02840a2e722a6cf660e4adde0e63d3d2de1 Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Tue, 6 Dec 2011 23:10:03 +0100 Subject: [PATCH 2/5] Fix history rendering not to occupy too many lanes There was a bug in history rendering which caused jgit to use too many lanes in case lanes get repositioned. Looking at commit 90c11cbaeb83ee9b02238cbd2c0e5bcf68068772 in JGit was one example. Vadim Dmitriev found the problem and the solution. Bug: 365460 Change-Id: I6024265b7a593dcfd4fc612d0baf6652a0092ff4 Also-by: Vadim Dmitriev Signed-off-by: Christian Halstrick --- .../src/org/eclipse/jgit/revplot/PlotCommitList.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java index e8263c5a9..f66e5e7ef 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java @@ -232,7 +232,9 @@ public class PlotCommitList extends if (newPos == -1) newPos = positionsAllocated++; freePositions.add(commit.lane.getPosition()); + activeLanes.remove(commit.lane); commit.lane.position = newPos; + activeLanes.add(commit.lane); } } From dfcb43eff1bbdc58b6d286b4d18256ce8af56a78 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Wed, 26 Oct 2011 01:54:54 +0200 Subject: [PATCH 3/5] Add methods for configuring platform emulation Specifically we support setting system properties for Windows, generic Unix and current test platform. Change-Id: Ib02be417c4915350dfec64fda3face1138552871 --- .../eclipse/jgit/junit/MockSystemReader.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java index b9bc25857..ae1c5d9fe 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java @@ -150,4 +150,34 @@ public class MockSystemReader extends SystemReader { public Locale getLocale() { return Locale.US; } + + /** + * Assign some properties for the currently executing platform + */ + public void setCurrentPlatform() { + setProperty("os.name", System.getProperty("os.name")); + setProperty("file.separator", System.getProperty("file.separator")); + setProperty("path.separator", System.getProperty("path.separator")); + setProperty("line.separator", System.getProperty("line.separator")); + } + + /** + * Emulate Windows + */ + public void setWindows() { + setProperty("os.name", "Windows"); + setProperty("file.separator", "\\"); + setProperty("path.separator", ";"); + setProperty("line.separator", "\r\n"); + } + + /** + * Emulate Unix + */ + public void setUnix() { + setProperty("os.name", "*nix"); // Essentially anything but Windows + setProperty("file.separator", "/"); + setProperty("path.separator", ":"); + setProperty("line.separator", "\n"); + } } From 26b573862912b2faf3824bb18dfeb44a3b700014 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 8 Dec 2011 23:33:53 +0100 Subject: [PATCH 4/5] Throw API exception when MergeCommand hits checkout conflicts When MergeCommand hit checkout conflicts it did throw an internal JGit exception org.eclipse.jgit.errors.CheckoutConflictException instead of org.eclipse.jgit.api.errors.CheckoutConflictException which it declares to throw. Hence translate the internal exception to the exception declared in the API. Bug: 327573 Change-Id: I1efcd93a43ecbf4a40583e0fc9d8d53cffc98cae Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/api/MergeCommand.java | 12 +++++++++--- .../api/errors/CheckoutConflictException.java | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index c7a30ebe1..85686da4d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.api; import java.io.IOException; import java.text.MessageFormat; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -122,6 +123,7 @@ public class MergeCommand extends GitCommand { Integer.valueOf(commits.size()))); RevWalk revWalk = null; + DirCacheCheckout dco = null; try { Ref head = repo.getRef(Constants.HEAD); if (head == null) @@ -147,7 +149,7 @@ public class MergeCommand extends GitCommand { ObjectId headId = head.getObjectId(); if (headId == null) { revWalk.parseHeaders(srcCommit); - DirCacheCheckout dco = new DirCacheCheckout(repo, + dco = new DirCacheCheckout(repo, repo.lockDirCache(), srcCommit.getTree()); dco.setFailOnConflict(true); dco.checkout(); @@ -176,7 +178,7 @@ public class MergeCommand extends GitCommand { // FAST_FORWARD detected: skip doing a real merge but only // update HEAD refLogMessage.append(": " + MergeStatus.FAST_FORWARD); - DirCacheCheckout dco = new DirCacheCheckout(repo, + dco = new DirCacheCheckout(repo, headCommit.getTree(), repo.lockDirCache(), srcCommit.getTree()); dco.setFailOnConflict(true); @@ -214,7 +216,7 @@ public class MergeCommand extends GitCommand { refLogMessage.append(mergeStrategy.getName()); refLogMessage.append('.'); if (noProblems) { - DirCacheCheckout dco = new DirCacheCheckout(repo, + dco = new DirCacheCheckout(repo, headCommit.getTree(), repo.lockDirCache(), merger.getResultTreeId()); dco.setFailOnConflict(true); @@ -250,6 +252,10 @@ public class MergeCommand extends GitCommand { } } } + } catch (org.eclipse.jgit.errors.CheckoutConflictException e) { + List conflicts = (dco == null) ? Collections + . emptyList() : dco.getConflicts(); + throw new CheckoutConflictException(conflicts, e); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java index de45c1d8e..4d5bd1e03 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java @@ -48,6 +48,20 @@ public class CheckoutConflictException extends GitAPIException { private static final long serialVersionUID = 1L; private List conflictingPaths; + /** + * Translate internal exception to API exception + * + * @param conflictingPaths + * list of conflicting paths + * + * @param e + */ + public CheckoutConflictException(List conflictingPaths, + org.eclipse.jgit.errors.CheckoutConflictException e) { + super(e.getMessage(), e); + this.conflictingPaths = conflictingPaths; + } + CheckoutConflictException(String message, Throwable cause) { super(message, cause); } @@ -73,6 +87,7 @@ public class CheckoutConflictException extends GitAPIException { /** * Adds a new conflicting path + * * @param conflictingPath * @return {@code this} */ From c1f352c100278551a7a144b756983ed8a5990c41 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 10 Dec 2011 00:49:39 +0100 Subject: [PATCH 5/5] Fix version.sh Change-Id: Icdf5d9ea3ca62839cbf7de13dfee9682056b7cef Signed-off-by: Matthias Sohn --- tools/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/version.sh b/tools/version.sh index 2fae5e142..eaff9a61d 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -141,7 +141,7 @@ perl -pi~ -e ' $seen_version = 0; $old_argv = $ARGV; } - if ($seen_version < 6) { + if ($seen_version < 5) { $seen_version++ if s{<(version)>.*}{<${1}>'"$POM_V"'}; }