Mark fields of BaseReceivePack private

None of these should have been exposed to base classes. The majority
of them are private implementation details that are not required by a
subclass in order to interact with the base protocol definition. The
few that are needed should be visible as accessor methods, so the
internals can be modified without breaking the public JGit API.

Change-Id: I874179105c9c37703307facbbf99387c52bf772c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Shawn O. Pearce 2012-08-18 15:51:03 -07:00 committed by Matthias Sohn
parent 9638e0aa87
commit e63f1c94f8
2 changed files with 36 additions and 19 deletions

View File

@ -136,10 +136,10 @@ public Set<String> getCapabilities() {
} }
/** Database we write the stored objects into. */ /** Database we write the stored objects into. */
protected final Repository db; private final Repository db;
/** Revision traversal support over {@link #db}. */ /** Revision traversal support over {@link #db}. */
protected final RevWalk walk; private final RevWalk walk;
/** /**
* Is the client connection a bi-directional socket or pipe? * Is the client connection a bi-directional socket or pipe?
@ -152,22 +152,22 @@ public Set<String> getCapabilities() {
* If false, this class runs in a read everything then output results mode, * If false, this class runs in a read everything then output results mode,
* making it suitable for single round-trip systems RPCs such as HTTP. * making it suitable for single round-trip systems RPCs such as HTTP.
*/ */
protected boolean biDirectionalPipe = true; private boolean biDirectionalPipe = true;
/** Expecting data after the pack footer */ /** Expecting data after the pack footer */
protected boolean expectDataAfterPackFooter; private boolean expectDataAfterPackFooter;
/** Should an incoming transfer validate objects? */ /** Should an incoming transfer validate objects? */
protected boolean checkReceivedObjects; private boolean checkReceivedObjects;
/** Should an incoming transfer permit create requests? */ /** Should an incoming transfer permit create requests? */
protected boolean allowCreates; private boolean allowCreates;
/** Should an incoming transfer permit delete requests? */ /** Should an incoming transfer permit delete requests? */
protected boolean allowDeletes; private boolean allowDeletes;
/** Should an incoming transfer permit non-fast-forward requests? */ /** Should an incoming transfer permit non-fast-forward requests? */
protected boolean allowNonFastForwards; private boolean allowNonFastForwards;
private boolean allowOfsDelta; private boolean allowOfsDelta;
@ -212,23 +212,20 @@ public Set<String> getCapabilities() {
private PackParser parser; private PackParser parser;
/** The refs we advertised as existing at the start of the connection. */ /** The refs we advertised as existing at the start of the connection. */
protected Map<String, Ref> refs; private Map<String, Ref> refs;
/** All SHA-1s shown to the client, which can be possible edges. */ /** All SHA-1s shown to the client, which can be possible edges. */
protected Set<ObjectId> advertisedHaves; private Set<ObjectId> advertisedHaves;
/** Capabilities requested by the client. */ /** Capabilities requested by the client. */
protected Set<String> enabledCapabilities; private Set<String> enabledCapabilities;
private List<ReceiveCommand> commands; private List<ReceiveCommand> commands;
private StringBuilder advertiseError; private StringBuilder advertiseError;
/** If {@link BasePackPushConnection#CAPABILITY_REPORT_STATUS} is enabled. */
protected boolean reportStatus;
/** If {@link BasePackPushConnection#CAPABILITY_SIDE_BAND_64K} is enabled. */ /** If {@link BasePackPushConnection#CAPABILITY_SIDE_BAND_64K} is enabled. */
protected boolean sideBand; private boolean sideBand;
/** Lock around the received pack file, while updating refs. */ /** Lock around the received pack file, while updating refs. */
private PackLock packLock; private PackLock packLock;
@ -872,9 +869,7 @@ protected void recvCommands() throws IOException {
/** Enable capabilities based on a previously read capabilities line. */ /** Enable capabilities based on a previously read capabilities line. */
protected void enableCapabilities() { protected void enableCapabilities() {
reportStatus = enabledCapabilities.contains(CAPABILITY_REPORT_STATUS); sideBand = isCapabilityEnabled(CAPABILITY_SIDE_BAND_64K);
sideBand = enabledCapabilities.contains(CAPABILITY_SIDE_BAND_64K);
if (sideBand) { if (sideBand) {
OutputStream out = rawOut; OutputStream out = rawOut;
@ -886,6 +881,17 @@ protected void enableCapabilities() {
} }
} }
/**
* Check if the peer requested a capability.
*
* @param name
* protocol name identifying the capability.
* @return true if the peer requested the capability to be enabled.
*/
protected boolean isCapabilityEnabled(String name) {
return enabledCapabilities.contains(name);
}
/** @return true if a pack is expected based on the list of commands. */ /** @return true if a pack is expected based on the list of commands. */
protected boolean needPack() { protected boolean needPack() {
for (final ReceiveCommand cmd : commands) { for (final ReceiveCommand cmd : commands) {

View File

@ -43,6 +43,8 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_REPORT_STATUS;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -63,6 +65,9 @@ public class ReceivePack extends BaseReceivePack {
/** Hook to report on the commands after execution. */ /** Hook to report on the commands after execution. */
private PostReceiveHook postReceive; private PostReceiveHook postReceive;
/** If {@link BasePackPushConnection#CAPABILITY_REPORT_STATUS} is enabled. */
private boolean reportStatus;
private boolean echoCommandFailures; private boolean echoCommandFailures;
/** /**
@ -162,8 +167,14 @@ public void receive(final InputStream input, final OutputStream output,
} }
} }
@Override
protected void enableCapabilities() {
reportStatus = isCapabilityEnabled(CAPABILITY_REPORT_STATUS);
super.enableCapabilities();
}
private void service() throws IOException { private void service() throws IOException {
if (biDirectionalPipe) { if (isBiDirectionalPipe()) {
sendAdvertisedRefs(new PacketLineOutRefAdvertiser(pckOut)); sendAdvertisedRefs(new PacketLineOutRefAdvertiser(pckOut));
pckOut.flush(); pckOut.flush();
} else } else