Browse Source

Factor a base class out of ReceivePack

We are working on a publish/subscribe based git protocol, and we want to
reuse several parts of the ReceivePack-like code for reading commands
and processing a pack. In this new implementation, the connection
management will be very different, in particular, there may be multiple
packs received on a single open connection. So, hoist out as much as we
can from ReceivePack, mostly just leaving behind the single-connection
version in that class.

Change-Id: I5567aad6ae77951f73f59c1f91996d934ea88334
tags/v2.0.0.201206130900-r
Dave Borowitz 12 years ago
parent
commit
cc37cb777e

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/transport/AbstractAdvertiseRefsHook.java View File

@@ -63,7 +63,7 @@ public abstract class AbstractAdvertiseRefsHook implements AdvertiseRefsHook {
uploadPack.getRepository(), uploadPack.getRevWalk()));
}

public void advertiseRefs(ReceivePack receivePack)
public void advertiseRefs(BaseReceivePack receivePack)
throws ServiceMayNotContinueException {
Map<String, Ref> refs = getAdvertisedRefs(receivePack.getRepository(),
receivePack.getRevWalk());

+ 4
- 4
org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java View File

@@ -53,14 +53,14 @@ public interface AdvertiseRefsHook {
* <p>
* The method implementations do nothing to preserve the default behavior; see
* {@link UploadPack#setAdvertisedRefs(java.util.Map)} and
* {@link ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}.
* {@link BaseReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}.
*/
public static final AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() {
public void advertiseRefs(UploadPack uploadPack) {
// Do nothing.
}

public void advertiseRefs(ReceivePack receivePack) {
public void advertiseRefs(BaseReceivePack receivePack) {
// Do nothing.
}
};
@@ -81,11 +81,11 @@ public interface AdvertiseRefsHook {
* Advertise refs for receive-pack.
*
* @param receivePack instance on which to call
* {@link ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}
* {@link BaseReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}
* if necessary.
* @throws ServiceMayNotContinueException
* abort; the message will be sent to the user.
*/
public void advertiseRefs(ReceivePack receivePack)
public void advertiseRefs(BaseReceivePack receivePack)
throws ServiceMayNotContinueException;
}

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java View File

@@ -51,8 +51,8 @@ import java.util.List;
* Hooks are run in the order passed to the constructor. A hook may inspect or
* modify the results of the previous hooks in the chain by calling
* {@link UploadPack#getAdvertisedRefs()}, or
* {@link ReceivePack#getAdvertisedRefs()} or
* {@link ReceivePack#getAdvertisedObjects()}.
* {@link BaseReceivePack#getAdvertisedRefs()} or
* {@link BaseReceivePack#getAdvertisedObjects()}.
*/
public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
private final AdvertiseRefsHook[] hooks;
@@ -79,7 +79,7 @@ public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
return new AdvertiseRefsHookChain(newHooks, i);
}

public void advertiseRefs(ReceivePack rp)
public void advertiseRefs(BaseReceivePack rp)
throws ServiceMayNotContinueException {
for (int i = 0; i < count; i++)
hooks[i].advertiseRefs(rp);

+ 1294
- 0
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
File diff suppressed because it is too large
View File


+ 4
- 4
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java View File

@@ -54,7 +54,7 @@ import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;

/**
* A command being processed by {@link ReceivePack}.
* A command being processed by {@link BaseReceivePack}.
* <p>
* This command instance roughly translates to the server side representation of
* the {@link RemoteRefUpdate} created by the client.
@@ -158,7 +158,7 @@ public class ReceiveCommand {
private String message;

/**
* Create a new command for {@link ReceivePack}.
* Create a new command for {@link BaseReceivePack}.
*
* @param oldId
* the old object id; must not be null. Use
@@ -184,7 +184,7 @@ public class ReceiveCommand {
}

/**
* Create a new command for {@link ReceivePack}.
* Create a new command for {@link BaseReceivePack}.
*
* @param oldId
* the old object id; must not be null. Use
@@ -273,7 +273,7 @@ public class ReceiveCommand {
* receive-pack session.
* @since 2.0
*/
public void execute(final ReceivePack rp) {
public void execute(final BaseReceivePack rp) {
try {
final RefUpdate ru = rp.getRepository().updateRef(getRefName());
ru.setRefLogIdent(rp.getRefLogIdent());

+ 16
- 1120
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
File diff suppressed because it is too large
View File


Loading…
Cancel
Save