]> source.dussan.org Git - jgit.git/commitdiff
Move deepenSince and deepenNotRefs up to FetchRequest 21/131021/2
authorIvan Frade <ifrade@google.com>
Tue, 16 Oct 2018 19:51:00 +0000 (12:51 -0700)
committerIvan Frade <ifrade@google.com>
Tue, 16 Oct 2018 23:12:59 +0000 (16:12 -0700)
These properties are protocol v2 specific, but they have clear default
no-op values and having them in the common superclass simplifies client
code.

Move properties deepenSince and deepenNotRefs up to FetchRequest. In
FetchV0Request, they are initialized with their no-op values (0 for
deepenSince and empty list for deepenNotRefs)

Change-Id: I9d46a6dfbe29ebd794b5a6482033cdc70d411a23
Signed-off-by: Ivan Frade <ifrade@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java

index fbb58ccbc8c35f994814bd102e27beb754c07a7e..5d28a4d9f23c0b9836fca11a424851c4984821c3 100644 (file)
@@ -44,6 +44,7 @@ package org.eclipse.jgit.transport;
 
 import static java.util.Objects.requireNonNull;
 
+import java.util.List;
 import java.util.Set;
 
 import org.eclipse.jgit.annotations.NonNull;
@@ -64,6 +65,10 @@ abstract class FetchRequest {
 
        final Set<String> clientCapabilities;
 
+       final int deepenSince;
+
+       final List<String> deepenNotRefs;
+
        /**
         * Initialize the common fields of a fetch request.
         *
@@ -77,15 +82,24 @@ abstract class FetchRequest {
         *            to exclude blobs on certain conditions
         * @param clientCapabilities
         *            capabilities sent in the request
+        * @param deepenNotRefs
+        *            Requests that the shallow clone/fetch should be cut at these
+        *            specific revisions instead of a depth.
+        * @param deepenSince
+        *            Requests that the shallow clone/fetch should be cut at a
+        *            specific time, instead of depth
         */
        FetchRequest(@NonNull Set<ObjectId> wantIds, int depth,
                        @NonNull Set<ObjectId> clientShallowCommits, long filterBlobLimit,
-                       @NonNull Set<String> clientCapabilities) {
+                       @NonNull Set<String> clientCapabilities, int deepenSince,
+                       @NonNull List<String> deepenNotRefs) {
                this.wantIds = requireNonNull(wantIds);
                this.depth = depth;
                this.clientShallowCommits = requireNonNull(clientShallowCommits);
                this.filterBlobLimit = filterBlobLimit;
                this.clientCapabilities = requireNonNull(clientCapabilities);
+               this.deepenSince = deepenSince;
+               this.deepenNotRefs = requireNonNull(deepenNotRefs);
        }
 
        /**
@@ -138,4 +152,23 @@ abstract class FetchRequest {
        Set<String> getClientCapabilities() {
                return clientCapabilities;
        }
+
+       /**
+        * The value in a "deepen-since" line in the request, indicating the
+        * timestamp where to stop fetching/cloning.
+        *
+        * @return timestamp in seconds since the epoch, where to stop the shallow
+        *         fetch/clone. Defaults to 0 if not set in the request.
+        */
+       int getDeepenSince() {
+               return deepenSince;
+       }
+
+       /**
+        * @return refs received in "deepen-not" lines.
+        */
+       @NonNull
+       List<String> getDeepenNotRefs() {
+               return deepenNotRefs;
+       }
 }
\ No newline at end of file
index 22ad629e3778b1abdc63ab862daffaf6014568c6..bb358c886fd3961bbb23028b8d5fc51e2fc41e7c 100644 (file)
@@ -43,6 +43,7 @@
 package org.eclipse.jgit.transport;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -58,7 +59,7 @@ final class FetchV0Request extends FetchRequest {
                        @NonNull Set<ObjectId> clientShallowCommits, long filterBlobLimit,
                        @NonNull Set<String> clientCapabilities) {
                super(wantIds, depth, clientShallowCommits, filterBlobLimit,
-                               clientCapabilities);
+                               clientCapabilities, 0, Collections.emptyList());
        }
 
        static final class Builder {
index dcca522ae14485832bb1b3007fb68feab3079594..cd3906ea612883e78d4862d06671d774166e2c5e 100644 (file)
@@ -67,10 +67,6 @@ public final class FetchV2Request extends FetchRequest {
 
        private final TreeMap<String, ObjectId> wantedRefs;
 
-       private final int deepenSince;
-
-       private final List<String> deepenNotRefs;
-
        private final boolean doneReceived;
 
        FetchV2Request(@NonNull List<ObjectId> peerHas,
@@ -80,11 +76,10 @@ public final class FetchV2Request extends FetchRequest {
                        @NonNull List<String> deepenNotRefs, int depth,
                        long filterBlobLimit,
                        boolean doneReceived, @NonNull Set<String> clientCapabilities) {
-               super(wantIds, depth, clientShallowCommits, filterBlobLimit, clientCapabilities);
+               super(wantIds, depth, clientShallowCommits, filterBlobLimit,
+                               clientCapabilities, deepenSince, deepenNotRefs);
                this.peerHas = requireNonNull(peerHas);
                this.wantedRefs = requireNonNull(wantedRefs);
-               this.deepenSince = deepenSince;
-               this.deepenNotRefs = requireNonNull(deepenNotRefs);
                this.doneReceived = doneReceived;
        }
 
@@ -104,25 +99,6 @@ public final class FetchV2Request extends FetchRequest {
                return wantedRefs;
        }
 
-       /**
-        * The value in a "deepen-since" line in the request, indicating the
-        * timestamp where to stop fetching/cloning.
-        *
-        * @return timestamp in seconds since the epoch, where to stop the shallow
-        *         fetch/clone. Defaults to 0 if not set in the request.
-        */
-       int getDeepenSince() {
-               return deepenSince;
-       }
-
-       /**
-        * @return refs received in "deepen-not" lines.
-        */
-       @NonNull
-       List<String> getDeepenNotRefs() {
-               return deepenNotRefs;
-       }
-
        /**
         * @return true if the request had a "done" line
         */
@@ -135,7 +111,6 @@ public final class FetchV2Request extends FetchRequest {
                return new Builder();
        }
 
-
        /** A builder for {@link FetchV2Request}. */
        static final class Builder {
                final List<ObjectId> peerHas = new ArrayList<>();