Browse Source

UploadPack: Use request instead of field for clientShallowCommits

Yet another member to field transition.

Change-Id: Ic801f4ac3a270b287591ef3cf722c399126ccdd4
Signed-off-by: Ivan Frade <ifrade@google.com>
stable-5.2
Ivan Frade 6 years ago
parent
commit
13b3881b3e
  1. 26
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

26
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -299,9 +299,6 @@ public class UploadPack {
/** Objects on both sides, these don't have to be sent. */ /** Objects on both sides, these don't have to be sent. */
private final Set<RevObject> commonBase = new HashSet<>(); private final Set<RevObject> commonBase = new HashSet<>();
/** Shallow commits the client already has. */
private Set<ObjectId> clientShallowCommits = new HashSet<>();
/** Commit time of the oldest common commit, in seconds. */ /** Commit time of the oldest common commit, in seconds. */
private int oldestTime; private int oldestTime;
@ -818,7 +815,6 @@ public class UploadPack {
currentRequest = req; currentRequest = req;
wantIds = req.getWantIds(); wantIds = req.getWantIds();
clientShallowCommits = req.getClientShallowCommits();
options = req.getClientCapabilities(); options = req.getClientCapabilities();
if (req.getWantIds().isEmpty()) { if (req.getWantIds().isEmpty()) {
@ -837,8 +833,10 @@ public class UploadPack {
else else
multiAck = MultiAck.OFF; multiAck = MultiAck.OFF;
if (!clientShallowCommits.isEmpty()) if (!req.getClientShallowCommits().isEmpty()) {
verifyClientShallow(clientShallowCommits); verifyClientShallow(req.getClientShallowCommits());
}
if (req.getDepth() != 0 || req.getDeepenSince() != 0) { if (req.getDepth() != 0 || req.getDeepenSince() != 0) {
computeShallowsAndUnshallows(req, shallow -> { computeShallowsAndUnshallows(req, shallow -> {
pckOut.writeString("shallow " + shallow.name() + '\n'); //$NON-NLS-1$ pckOut.writeString("shallow " + shallow.name() + '\n'); //$NON-NLS-1$
@ -848,8 +846,9 @@ public class UploadPack {
}); });
pckOut.end(); pckOut.end();
} }
if (!clientShallowCommits.isEmpty())
walk.assumeShallow(clientShallowCommits); if (!req.getClientShallowCommits().isEmpty())
walk.assumeShallow(req.getClientShallowCommits());
sendPack = negotiate(req, accumulator); sendPack = negotiate(req, accumulator);
accumulator.timeNegotiating += System.currentTimeMillis() accumulator.timeNegotiating += System.currentTimeMillis()
- negotiateStart; - negotiateStart;
@ -959,7 +958,6 @@ public class UploadPack {
// copying data back to class fields // copying data back to class fields
options = req.getClientCapabilities(); options = req.getClientCapabilities();
wantIds = req.getWantIds(); wantIds = req.getWantIds();
clientShallowCommits = req.getClientShallowCommits();
boolean sectionSent = false; boolean sectionSent = false;
boolean mayHaveShallow = req.getDepth() != 0 boolean mayHaveShallow = req.getDepth() != 0
@ -1907,8 +1905,9 @@ public class UploadPack {
pw.setUseCachedPacks(true); pw.setUseCachedPacks(true);
} }
pw.setUseBitmaps( pw.setUseBitmaps(
req.getDepth() == 0 && clientShallowCommits.isEmpty()); req.getDepth() == 0
pw.setClientShallowCommits(clientShallowCommits); && req.getClientShallowCommits().isEmpty());
pw.setClientShallowCommits(req.getClientShallowCommits());
pw.setReuseDeltaCommits(true); pw.setReuseDeltaCommits(true);
pw.setDeltaBaseAsOffset(options.contains(OPTION_OFS_DELTA)); pw.setDeltaBaseAsOffset(options.contains(OPTION_OFS_DELTA));
pw.setThin(options.contains(OPTION_THIN_PACK)); pw.setThin(options.contains(OPTION_THIN_PACK));
@ -1936,11 +1935,12 @@ public class UploadPack {
pw.setShallowPack(req.getDepth(), unshallowCommits); pw.setShallowPack(req.getDepth(), unshallowCommits);
rw = new DepthWalk.RevWalk(walk.getObjectReader(), walkDepth); rw = new DepthWalk.RevWalk(walk.getObjectReader(), walkDepth);
((DepthWalk.RevWalk) rw).setDeepenSince(req.getDeepenSince()); ((DepthWalk.RevWalk) rw).setDeepenSince(req.getDeepenSince());
rw.assumeShallow(clientShallowCommits); rw.assumeShallow(req.getClientShallowCommits());
} }
if (wantAll.isEmpty()) { if (wantAll.isEmpty()) {
pw.preparePack(pm, wantIds, commonBase, clientShallowCommits); pw.preparePack(pm, wantIds, commonBase,
req.getClientShallowCommits());
} else { } else {
walk.reset(); walk.reset();

Loading…
Cancel
Save