]> source.dussan.org Git - jgit.git/commitdiff
Provide default shallowCommits getter and setter in ObjectDatabase 85/195085/11
authorRonald Bhuleskar <funronald@google.com>
Sat, 6 Aug 2022 00:30:55 +0000 (17:30 -0700)
committerJonathan Nieder <jrn@google.com>
Mon, 8 Aug 2022 22:30:00 +0000 (18:30 -0400)
I649db9ae679ec2606cf7c530b040f8b6b93eb81a added a default implementation
for getShallowCommits and setShallowCommits to DfsObjDatabase, for the
convenience of any implementers that define subclasses. But we forgot
that some implementers inherit from ObjectDatabase directly instead.
Move the default getter and setter to the base class so that such
callers do not need source changes to unbreak their build.

This also lets us update the api_filters to reflect that this is no
longer an API-breaking change.

Change-Id: I5dcca462eb306e511e57907b7d9264d51b3f3014

org.eclipse.jgit/.settings/.api_filters
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

index 4af7adc72b11c85b47595e145683f97cecf1161c..1c283e7613648178e4a47d800516137f3341d41e 100644 (file)
@@ -9,20 +9,6 @@
             </message_arguments>
         </filter>
     </resource>
-    <resource path="src/org/eclipse/jgit/lib/ObjectDatabase.java" type="org.eclipse.jgit.lib.ObjectDatabase">
-        <filter id="336695337">
-            <message_arguments>
-                <message_argument value="org.eclipse.jgit.lib.ObjectDatabase"/>
-                <message_argument value="getShallowCommits()"/>
-            </message_arguments>
-        </filter>
-        <filter id="336695337">
-            <message_arguments>
-                <message_argument value="org.eclipse.jgit.lib.ObjectDatabase"/>
-                <message_argument value="setShallowCommits(Set&lt;ObjectId&gt;)"/>
-            </message_arguments>
-        </filter>
-    </resource>
     <resource path="src/org/eclipse/jgit/lib/TypedConfigGetter.java" type="org.eclipse.jgit.lib.TypedConfigGetter">
         <filter id="403767336">
             <message_arguments>
index c50e03869ccfb652675cfeb56eefb927c4336c3c..46ec87df54c5b5ef5051b4ed2b6614a2a9c41953 100644 (file)
@@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.eclipse.jgit.internal.storage.pack.PackExt;
 import org.eclipse.jgit.lib.AnyObjectId;
 import org.eclipse.jgit.lib.ObjectDatabase;
-import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectInserter;
 import org.eclipse.jgit.lib.ObjectReader;
 
@@ -58,8 +57,6 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
                }
        };
 
-       private static final Set<ObjectId> shallowCommits = Collections.emptySet();
-
        /**
         * Sources for a pack file.
         * <p>
@@ -507,19 +504,6 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
        protected abstract DfsOutputStream writeFile(
                        DfsPackDescription desc, PackExt ext) throws IOException;
 
-       @Override
-       public Set<ObjectId> getShallowCommits() throws IOException {
-               return shallowCommits;
-       }
-
-       @Override
-       public void setShallowCommits(Set<ObjectId> shallowCommits) {
-               if (!shallowCommits.isEmpty()) {
-                       throw new UnsupportedOperationException(
-                                       "Shallow commits expected to be empty.");
-               }
-       }
-
        void addPack(DfsPackFile newPack) throws IOException {
                PackList o, n;
                do {
index 1c0f436090eeac6c5923dcfce8daec173a4ad1c0..a39766cbd088e0f4e7cf50cf1a62f07c4172a568 100644 (file)
@@ -11,6 +11,7 @@
 package org.eclipse.jgit.lib;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Set;
 
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
@@ -23,6 +24,9 @@ import org.eclipse.jgit.errors.MissingObjectException;
  * {@link org.eclipse.jgit.lib.ObjectId}.
  */
 public abstract class ObjectDatabase implements AutoCloseable {
+
+       private static final Set<ObjectId> shallowCommits = Collections.emptySet();
+
        /**
         * Initialize a new database instance for access.
         */
@@ -79,7 +83,10 @@ public abstract class ObjectDatabase implements AutoCloseable {
         *
         * @since 6.3
         */
-       public abstract Set<ObjectId> getShallowCommits() throws IOException;
+       public Set<ObjectId> getShallowCommits() throws IOException {
+               return shallowCommits;
+       }
+
 
        /**
         * Update the shallow commits of the current repository
@@ -90,7 +97,13 @@ public abstract class ObjectDatabase implements AutoCloseable {
         *
         * @since 6.3
         */
-       public abstract void setShallowCommits(Set<ObjectId> shallowCommits) throws IOException;
+       public void setShallowCommits(Set<ObjectId> shallowCommits)
+                       throws IOException {
+               if (!shallowCommits.isEmpty()) {
+                       throw new UnsupportedOperationException(
+                                       "Shallow commits expected to be empty."); //$NON-NLS-1$
+               }
+       }
 
        /**
         * Close any resources held by this database.