@@ -0,0 +1,1631 @@
+// Copyright (C) 2020 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage gerrit;%0A%0Aimport com.google.gerrit.server.rules.StoredValues;%0Aimport com.googlecode.prolog_cafe.exceptions.PrologException;%0Aimport com.googlecode.prolog_cafe.lang.IntegerTerm;%0Aimport com.googlecode.prolog_cafe.lang.Operation;%0Aimport com.googlecode.prolog_cafe.lang.Predicate;%0Aimport com.googlecode.prolog_cafe.lang.Prolog;%0Aimport com.googlecode.prolog_cafe.lang.Term;%0Aimport org.eclipse.jgit.revwalk.RevCommit;%0A%0A/**%0A * Prolog fact for the number of parents of a given commit%0A *%0A * %3Cpre%3E%0A *   'commit_parent_count'(-Count)%0A * %3C/pre%3E%0A */%0Apublic class PRED_commit_parent_count_1 extends Predicate.P1 %7B%0A  public PRED_commit_parent_count_1(Term a1, Operation n) %7B%0A    arg1 = a1;%0A    cont = n;%0A  %7D%0A%0A  @Override%0A  public Operation exec(Prolog engine) throws PrologException %7B%0A    engine.setB0();%0A    Term a1 = arg1.dereference();%0A%0A    RevCommit commit = StoredValues.COMMIT.get(engine);%0A%0A    if (!a1.unify(new IntegerTerm(commit.getParentCount()), engine.trail)) %7B%0A      return engine.fail();%0A    %7D%0A    return cont;%0A  %7D%0A%7D%0A

Add prolog predicate to determine number of parents