diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2022-09-06 00:06:04 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-09-06 10:40:26 +0200 |
commit | 7c4a5421ccd16b84b1ea4f3c1e566bfdf9c0e30d (patch) | |
tree | a6a83ce0c8a774556fac8b8efd947ea018b01196 /org.eclipse.jgit | |
parent | ee6334bccf6d81b1bf513c44897e2a63b6300400 (diff) | |
download | jgit-7c4a5421ccd16b84b1ea4f3c1e566bfdf9c0e30d.tar.gz jgit-7c4a5421ccd16b84b1ea4f3c1e566bfdf9c0e30d.zip |
Revert "Adds FilteredRevCommit that can overwrites its parents in the
DAG."
This reverts commit 6297491e8adb85e43d60ffe75fb71f335e733449.
This is done as a quick fix for the failure of egit tests caused by the
introduction of FilteredRevCommit.
Bug: 580690
Change-Id: Ia6b651dd11b0a4b02d5e52247eb4bf13adf94e27
Diffstat (limited to 'org.eclipse.jgit')
3 files changed, 8 insertions, 142 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java deleted file mode 100644 index 16beac3903..0000000000 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2022, Google LLC. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0 which is available at - * https://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -package org.eclipse.jgit.revwalk; - -/** - * A filtered commit reference that overrides its parent in the DAG. - * - * @since 6.3 - */ -public class FilteredRevCommit extends RevCommit { - private RevCommit[] overriddenParents; - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - */ - public FilteredRevCommit(RevCommit commit) { - this(commit, NO_PARENTS); - } - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - * @param parents - * overridden parents for the commit - */ - public FilteredRevCommit(RevCommit commit, RevCommit... parents) { - super(commit); - this.overriddenParents = parents; - this.parents = NO_PARENTS; - } - - /** - * Update parents on the commit - * - * @param overriddenParents - * parents to be overwritten - */ - public void setParents(RevCommit... overriddenParents) { - this.overriddenParents = overriddenParents; - } - - /** - * Get the number of parent commits listed in this commit. - * - * @return number of parents; always a positive value but can be 0 if it has - * no parents. - */ - @Override - public int getParentCount() { - return overriddenParents.length; - } - - /** - * Get the nth parent from this commit's parent list. - * - * @param nth - * parent index to obtain. Must be in the range 0 through - * {@link #getParentCount()}-1. - * @return the specified parent. - * @throws java.lang.ArrayIndexOutOfBoundsException - * an invalid parent index was specified. - */ - @Override - public RevCommit getParent(int nth) { - return overriddenParents[nth]; - } - - /** - * Obtain an array of all parents (<b>NOTE - THIS IS NOT A COPY</b>). - * - * <p> - * This method is exposed only to provide very fast, efficient access to - * this commit's parent list. Applications relying on this list should be - * very careful to ensure they do not modify its contents during their use - * of it. - * - * @return the array of parents. - */ - @Override - public RevCommit[] getParents() { - return overriddenParents; - } -} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java index a7c21e3f13..6b644cef90 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java @@ -114,7 +114,7 @@ public class RevCommit extends RevObject { * * @since 6.3 */ - RevCommit[] parents; + protected RevCommit[] parents; int commitTime; // An int here for performance, overflows in 2038 @@ -132,22 +132,6 @@ public class RevCommit extends RevObject { super(id); } - /** - * Create a new commit reference. - * - * @param orig - * commit to be copied from. - */ - RevCommit(RevCommit orig) { - super(orig.getId()); - this.buffer = orig.buffer; - this.commitTime = orig.commitTime; - this.flags = orig.flags; - this.parents = orig.parents; - this.tree = orig.tree; - this.inDegree = orig.inDegree; - } - @Override void parseHeaders(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java index 9ec331b697..2c88bb872e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java @@ -11,8 +11,6 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -40,13 +38,10 @@ class RewriteGenerator extends Generator { private final FIFORevQueue pending; - private final Map<RevCommit, FilteredRevCommit> transformedCommits; - RewriteGenerator(Generator s) { super(s.firstParent); source = s; pending = new FIFORevQueue(s.firstParent); - transformedCommits = new HashMap<>(); } @Override @@ -63,10 +58,10 @@ class RewriteGenerator extends Generator { @Override RevCommit next() throws MissingObjectException, IncorrectObjectTypeException, IOException { - FilteredRevCommit c = (FilteredRevCommit) pending.next(); + RevCommit c = pending.next(); if (c == null) { - c = transform(source.next()); + c = source.next(); if (c == null) { // We are done: Both the source generator and our internal list // are completely exhausted. @@ -84,9 +79,9 @@ class RewriteGenerator extends Generator { final RevCommit newp = rewrite(oldp); if (firstParent) { if (newp == null) { - c.setParents(RevCommit.NO_PARENTS); + c.parents = RevCommit.NO_PARENTS; } else { - c.setParents(newp); + c.parents = new RevCommit[] { newp }; } return c; } @@ -96,7 +91,7 @@ class RewriteGenerator extends Generator { } } if (rewrote) { - c.setParents(cleanup(pList)); + c.parents = cleanup(pList); } return c; } @@ -116,7 +111,7 @@ class RewriteGenerator extends Generator { for (RevCommit parent : c.getParents()) { while ((parent.flags & RevWalk.TREE_REV_FILTER_APPLIED) == 0) { - FilteredRevCommit n = transform(source.next()); + RevCommit n = source.next(); if (n != null) { pending.add(n); @@ -135,8 +130,6 @@ class RewriteGenerator extends Generator { IncorrectObjectTypeException, IOException { for (;;) { - p = transform(p); - if (p.getParentCount() > 1) { // This parent is a merge, so keep it. // @@ -165,25 +158,9 @@ class RewriteGenerator extends Generator { } applyFilterToParents(p.getParent(0)); - p = transform(p.getParent(0)); - - } - } + p = p.getParent(0); - private FilteredRevCommit transform(RevCommit c) { - if (c == null) { - return null; } - - if (c instanceof FilteredRevCommit) { - return (FilteredRevCommit) c; - } - - if (!transformedCommits.containsKey(c)) { - transformedCommits.put(c, new FilteredRevCommit(c, c.getParents())); - } - - return transformedCommits.get(c); } private RevCommit[] cleanup(RevCommit[] oldList) { |