diff --git a/gerrit-server/src/main/java/gerrit/PRED_commit_edits_2.java b/gerrit-server/src/main/java/gerrit/PRED_commit_edits_2.java deleted file mode 100644 index f9e3036edd..0000000000 --- a/gerrit-server/src/main/java/gerrit/PRED_commit_edits_2.java +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2011 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 gerrit; - -import com.google.gerrit.reviewdb.PatchSetInfo; -import com.google.gerrit.rules.PrologEnvironment; -import com.google.gerrit.rules.StoredValues; -import com.google.gerrit.server.patch.PatchList; -import com.google.gerrit.server.patch.PatchListEntry; -import com.google.gerrit.server.patch.Text; - -import com.googlecode.prolog_cafe.lang.IllegalTypeException; -import com.googlecode.prolog_cafe.lang.JavaException; -import com.googlecode.prolog_cafe.lang.Operation; -import com.googlecode.prolog_cafe.lang.PInstantiationException; -import com.googlecode.prolog_cafe.lang.Predicate; -import com.googlecode.prolog_cafe.lang.Prolog; -import com.googlecode.prolog_cafe.lang.PrologException; -import com.googlecode.prolog_cafe.lang.SystemException; -import com.googlecode.prolog_cafe.lang.Term; - -import org.eclipse.jgit.diff.Edit; -import org.eclipse.jgit.errors.CorruptObjectException; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectReader; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevTree; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.treewalk.TreeWalk; - -import java.io.IOException; -import java.util.List; -import java.util.regex.Pattern; - -/** - * Returns true if any of the files that match FileNameRegex have edited lines - * that match EditRegex - * - *
- * 'commit_edits'(+FileNameRegex, +EditRegex) - *- */ -public class PRED_commit_edits_2 extends Predicate.P2 { - private static final long serialVersionUID = 1L; - - public PRED_commit_edits_2(Term a1, Term a2, Operation n) { - arg1 = a1; - arg2 = a2; - cont = n; - } - - @Override - public Operation exec(Prolog engine) throws PrologException { - engine.setB0(); - - Term a1 = arg1.dereference(); - Term a2 = arg2.dereference(); - - Pattern fileRegex = getRegexParameter(a1); - Pattern editRegex = getRegexParameter(a2); - - PrologEnvironment env = (PrologEnvironment) engine.control; - PatchSetInfo psInfo = StoredValues.PATCH_SET_INFO.get(engine); - PatchList pl = StoredValues.PATCH_LIST.get(engine); - Repository repo = StoredValues.REPOSITORY.get(engine); - - final ObjectReader reader = repo.newObjectReader(); - final RevTree aTree; - final RevTree bTree; - try { - final RevWalk rw = new RevWalk(reader); - final RevCommit bCommit = rw.parseCommit(pl.getNewId()); - - if (pl.getOldId() != null) { - aTree = rw.parseTree(pl.getOldId()); - } else { - // Octopus merge with unknown automatic merge result, since the - // web UI returns no files to match against, just fail. - return engine.fail(); - } - bTree = bCommit.getTree(); - - for (PatchListEntry entry : pl.getPatches()) { - String newName = entry.getNewName(); - String oldName = entry.getOldName(); - - if (newName.equals("/COMMIT_MSG")) { - continue; - } - - if (fileRegex.matcher(newName).find() || - (oldName != null && fileRegex.matcher(oldName).find())) { - List
- * 'commit_message'(-Msg) - *- */ -public class PRED_commit_message_1 extends Predicate.P1 { - private static final long serialVersionUID = 1L; - - public PRED_commit_message_1(Term a1, Operation n) { - arg1 = a1; - cont = n; - } - - @Override - public Operation exec(Prolog engine) throws PrologException { - engine.setB0(); - Term a1 = arg1.dereference(); - - PatchSetInfo psInfo = StoredValues.PATCH_SET_INFO.get(engine); - - SymbolTerm msg = SymbolTerm.create(psInfo.getMessage()); - if (!a1.unify(msg, engine.trail)) { - return engine.fail(); - } - return cont; - } -} \ No newline at end of file diff --git a/gerrit-server/src/main/prolog/gerrit_common.pl b/gerrit-server/src/main/prolog/gerrit_common.pl index 5342b8466b..eb83ffdd1b 100644 --- a/gerrit-server/src/main/prolog/gerrit_common.pl +++ b/gerrit-server/src/main/prolog/gerrit_common.pl @@ -394,12 +394,3 @@ split_commit_delta(rename, NewPath, OldPath, delete, OldPath). split_commit_delta(rename, NewPath, OldPath, add, NewPath) :- !. split_commit_delta(copy, NewPath, OldPath, add, NewPath) :- !. split_commit_delta(Type, Path, _, Type, Path). - - -%% commit_message_matches/1: -%% -:- public commit_message_matches/1. -%% -commit_message_matches(Pattern) :- - commit_message(Msg), - regex_matches(Pattern, Msg).