|
|
@ -85,6 +85,7 @@ import org.eclipse.jgit.errors.IndexWriteException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.errors.NoWorkTreeException; |
|
|
|
import org.eclipse.jgit.errors.NoWorkTreeException; |
|
|
|
import org.eclipse.jgit.lib.Config; |
|
|
|
import org.eclipse.jgit.lib.Config; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.ConfigConstants; |
|
|
|
import org.eclipse.jgit.lib.FileMode; |
|
|
|
import org.eclipse.jgit.lib.FileMode; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
@ -272,6 +273,12 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected MergeAlgorithm mergeAlgorithm; |
|
|
|
protected MergeAlgorithm mergeAlgorithm; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The size limit (bytes) which controls a file to be stored in {@code Heap} or |
|
|
|
|
|
|
|
* {@code LocalFile} during the merge. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int inCoreLimit; |
|
|
|
|
|
|
|
|
|
|
|
private static MergeAlgorithm getMergeAlgorithm(Config config) { |
|
|
|
private static MergeAlgorithm getMergeAlgorithm(Config config) { |
|
|
|
SupportedAlgorithm diffAlg = config.getEnum( |
|
|
|
SupportedAlgorithm diffAlg = config.getEnum( |
|
|
|
CONFIG_DIFF_SECTION, null, CONFIG_KEY_ALGORITHM, |
|
|
|
CONFIG_DIFF_SECTION, null, CONFIG_KEY_ALGORITHM, |
|
|
@ -279,6 +286,11 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
return new MergeAlgorithm(DiffAlgorithm.getAlgorithm(diffAlg)); |
|
|
|
return new MergeAlgorithm(DiffAlgorithm.getAlgorithm(diffAlg)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int getInCoreLimit(Config config) { |
|
|
|
|
|
|
|
return config.getInt( |
|
|
|
|
|
|
|
ConfigConstants.CONFIG_MERGE_SECTION, ConfigConstants.CONFIG_KEY_IN_CORE_LIMIT, 10 << 20); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String[] defaultCommitNames() { |
|
|
|
private static String[] defaultCommitNames() { |
|
|
|
return new String[] { "BASE", "OURS", "THEIRS" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
|
|
return new String[] { "BASE", "OURS", "THEIRS" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
|
|
} |
|
|
|
} |
|
|
@ -289,7 +301,9 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected ResolveMerger(Repository local, boolean inCore) { |
|
|
|
protected ResolveMerger(Repository local, boolean inCore) { |
|
|
|
super(local); |
|
|
|
super(local); |
|
|
|
mergeAlgorithm = getMergeAlgorithm(local.getConfig()); |
|
|
|
Config config = local.getConfig(); |
|
|
|
|
|
|
|
mergeAlgorithm = getMergeAlgorithm(config); |
|
|
|
|
|
|
|
inCoreLimit = getInCoreLimit(config); |
|
|
|
commitNames = defaultCommitNames(); |
|
|
|
commitNames = defaultCommitNames(); |
|
|
|
this.inCore = inCore; |
|
|
|
this.inCore = inCore; |
|
|
|
|
|
|
|
|
|
|
@ -835,7 +849,7 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
private ObjectId insertMergeResult(MergeResult<RawText> result) |
|
|
|
private ObjectId insertMergeResult(MergeResult<RawText> result) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile( |
|
|
|
TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile( |
|
|
|
db != null ? nonNullRepo().getDirectory() : null, 10 << 20); |
|
|
|
db != null ? nonNullRepo().getDirectory() : null, inCoreLimit); |
|
|
|
try { |
|
|
|
try { |
|
|
|
new MergeFormatter().formatMerge(buf, result, |
|
|
|
new MergeFormatter().formatMerge(buf, result, |
|
|
|
Arrays.asList(commitNames), CHARACTER_ENCODING); |
|
|
|
Arrays.asList(commitNames), CHARACTER_ENCODING); |
|
|
|