Add experimental support for automatic conflict handling
Use new content merge functionality in JGit for automatic resolution of conflicts within a file. Change-Id: Ifae8a94709fb60f13e4c79fb6bb77a214ef5f0b7 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
35d753c8f7
commit
876953ea4d
@@ -102,6 +102,7 @@ public class GitProjectImporter {
|
||||
p.setSubmitType(SubmitType.MERGE_IF_NECESSARY);
|
||||
p.setUseContributorAgreements(false);
|
||||
p.setUseSignedOffBy(false);
|
||||
p.setUseContentMerge(false);
|
||||
p.setRequireChangeID(false);
|
||||
db.projects().insert(Collections.singleton(p));
|
||||
|
||||
|
||||
@@ -436,7 +436,18 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private void mergeOneCommit(final CodeReviewCommit n) throws MergeException {
|
||||
final Merger m = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
|
||||
final ThreeWayMerger m;
|
||||
if (destProject.isUseContentMerge()) {
|
||||
// Settings for this project allow us to try and
|
||||
// automatically resolve conflicts within files if needed.
|
||||
// Use ResolveMerge and instruct to operate in core.
|
||||
m = MergeStrategy.RESOLVE.newMerger(db, true);
|
||||
} else {
|
||||
// No auto conflict resolving allowed. If any of the
|
||||
// affected files was modified, merge will fail.
|
||||
m = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
|
||||
}
|
||||
|
||||
try {
|
||||
if (m.merge(new AnyObjectId[] {mergeTip, n})) {
|
||||
writeMergeCommit(m, n);
|
||||
@@ -606,7 +617,17 @@ public class MergeOp {
|
||||
final CodeReviewCommit n = toMerge.remove(0);
|
||||
final ThreeWayMerger m;
|
||||
|
||||
m = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
|
||||
if (destProject.isUseContentMerge()) {
|
||||
// Settings for this project allow us to try and
|
||||
// automatically resolve conflicts within files if needed.
|
||||
// Use ResolveMerge and instruct to operate in core.
|
||||
m = MergeStrategy.RESOLVE.newMerger(db, true);
|
||||
} else {
|
||||
// No auto conflict resolving allowed. If any of the
|
||||
// affected files was modified, merge will fail.
|
||||
m = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
|
||||
}
|
||||
|
||||
try {
|
||||
if (mergeTip == null) {
|
||||
// The branch is unborn. Take a fast-forward resolution to
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
private static final Class<? extends SchemaVersion> C = Schema_46.class;
|
||||
private static final Class<? extends SchemaVersion> C = Schema_47.class;
|
||||
|
||||
public static class Module extends AbstractModule {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Schema_47 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_47(Provider<Schema_46> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user