Browse Source

Merge branch 'stable-1.2'

* stable-1.2:
  Fix version.sh
  Throw API exception when MergeCommand hits checkout conflicts
  Add methods for configuring platform emulation
  Fix history rendering not to occupy too many lanes
  Fix History rendering

Change-Id: If71cc760423ae2b76c7435ca4830edc1745556de
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-1.3
Matthias Sohn 13 years ago
parent
commit
e11af56828
  1. 30
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
  2. 12
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  3. 15
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
  5. 2
      tools/version.sh

30
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java

@ -150,4 +150,34 @@ public class MockSystemReader extends SystemReader {
public Locale getLocale() { public Locale getLocale() {
return Locale.US; 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");
}
} }

12
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.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -122,6 +123,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
Integer.valueOf(commits.size()))); Integer.valueOf(commits.size())));
RevWalk revWalk = null; RevWalk revWalk = null;
DirCacheCheckout dco = null;
try { try {
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.getRef(Constants.HEAD);
if (head == null) if (head == null)
@ -147,7 +149,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
ObjectId headId = head.getObjectId(); ObjectId headId = head.getObjectId();
if (headId == null) { if (headId == null) {
revWalk.parseHeaders(srcCommit); revWalk.parseHeaders(srcCommit);
DirCacheCheckout dco = new DirCacheCheckout(repo, dco = new DirCacheCheckout(repo,
repo.lockDirCache(), srcCommit.getTree()); repo.lockDirCache(), srcCommit.getTree());
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
dco.checkout(); dco.checkout();
@ -176,7 +178,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
// FAST_FORWARD detected: skip doing a real merge but only // FAST_FORWARD detected: skip doing a real merge but only
// update HEAD // update HEAD
refLogMessage.append(": " + MergeStatus.FAST_FORWARD); refLogMessage.append(": " + MergeStatus.FAST_FORWARD);
DirCacheCheckout dco = new DirCacheCheckout(repo, dco = new DirCacheCheckout(repo,
headCommit.getTree(), repo.lockDirCache(), headCommit.getTree(), repo.lockDirCache(),
srcCommit.getTree()); srcCommit.getTree());
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
@ -214,7 +216,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
refLogMessage.append(mergeStrategy.getName()); refLogMessage.append(mergeStrategy.getName());
refLogMessage.append('.'); refLogMessage.append('.');
if (noProblems) { if (noProblems) {
DirCacheCheckout dco = new DirCacheCheckout(repo, dco = new DirCacheCheckout(repo,
headCommit.getTree(), repo.lockDirCache(), headCommit.getTree(), repo.lockDirCache(),
merger.getResultTreeId()); merger.getResultTreeId());
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
@ -250,6 +252,10 @@ public class MergeCommand extends GitCommand<MergeResult> {
} }
} }
} }
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
List<String> conflicts = (dco == null) ? Collections
.<String> emptyList() : dco.getConflicts();
throw new CheckoutConflictException(conflicts, e);
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException( throw new JGitInternalException(
MessageFormat.format( MessageFormat.format(

15
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 static final long serialVersionUID = 1L;
private List<String> conflictingPaths; private List<String> conflictingPaths;
/**
* Translate internal exception to API exception
*
* @param conflictingPaths
* list of conflicting paths
*
* @param e
*/
public CheckoutConflictException(List<String> conflictingPaths,
org.eclipse.jgit.errors.CheckoutConflictException e) {
super(e.getMessage(), e);
this.conflictingPaths = conflictingPaths;
}
CheckoutConflictException(String message, Throwable cause) { CheckoutConflictException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
@ -73,6 +87,7 @@ public class CheckoutConflictException extends GitAPIException {
/** /**
* Adds a new conflicting path * Adds a new conflicting path
*
* @param conflictingPath * @param conflictingPath
* @return {@code this} * @return {@code this}
*/ */

2
org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java

@ -232,7 +232,9 @@ public class PlotCommitList<L extends PlotLane> extends
if (newPos == -1) if (newPos == -1)
newPos = positionsAllocated++; newPos = positionsAllocated++;
freePositions.add(commit.lane.getPosition()); freePositions.add(commit.lane.getPosition());
activeLanes.remove(commit.lane);
commit.lane.position = newPos; commit.lane.position = newPos;
activeLanes.add(commit.lane);
} }
} }

2
tools/version.sh

@ -141,7 +141,7 @@ perl -pi~ -e '
$seen_version = 0; $seen_version = 0;
$old_argv = $ARGV; $old_argv = $ARGV;
} }
if ($seen_version < 6) { if ($seen_version < 5) {
$seen_version++ if $seen_version++ if
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>}; s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
} }

Loading…
Cancel
Save