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
stable-2.0
Dave Borowitz 13 years ago
parent
commit
cc37cb777e
  1. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AbstractAdvertiseRefsHook.java
  2. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java
  3. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java
  4. 1294
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
  5. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
  6. 1136
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/AbstractAdvertiseRefsHook.java

@ -63,7 +63,7 @@ public abstract class AbstractAdvertiseRefsHook implements AdvertiseRefsHook {
uploadPack.getRepository(), uploadPack.getRevWalk())); uploadPack.getRepository(), uploadPack.getRevWalk()));
} }
public void advertiseRefs(ReceivePack receivePack) public void advertiseRefs(BaseReceivePack receivePack)
throws ServiceMayNotContinueException { throws ServiceMayNotContinueException {
Map<String, Ref> refs = getAdvertisedRefs(receivePack.getRepository(), Map<String, Ref> refs = getAdvertisedRefs(receivePack.getRepository(),
receivePack.getRevWalk()); receivePack.getRevWalk());

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java

@ -53,14 +53,14 @@ public interface AdvertiseRefsHook {
* <p> * <p>
* The method implementations do nothing to preserve the default behavior; see * The method implementations do nothing to preserve the default behavior; see
* {@link UploadPack#setAdvertisedRefs(java.util.Map)} and * {@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 static final AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() {
public void advertiseRefs(UploadPack uploadPack) { public void advertiseRefs(UploadPack uploadPack) {
// Do nothing. // Do nothing.
} }
public void advertiseRefs(ReceivePack receivePack) { public void advertiseRefs(BaseReceivePack receivePack) {
// Do nothing. // Do nothing.
} }
}; };
@ -81,11 +81,11 @@ public interface AdvertiseRefsHook {
* Advertise refs for receive-pack. * Advertise refs for receive-pack.
* *
* @param receivePack instance on which to call * @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. * if necessary.
* @throws ServiceMayNotContinueException * @throws ServiceMayNotContinueException
* abort; the message will be sent to the user. * abort; the message will be sent to the user.
*/ */
public void advertiseRefs(ReceivePack receivePack) public void advertiseRefs(BaseReceivePack receivePack)
throws ServiceMayNotContinueException; throws ServiceMayNotContinueException;
} }

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java

@ -51,8 +51,8 @@ import java.util.List;
* Hooks are run in the order passed to the constructor. A hook may inspect or * 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 * modify the results of the previous hooks in the chain by calling
* {@link UploadPack#getAdvertisedRefs()}, or * {@link UploadPack#getAdvertisedRefs()}, or
* {@link ReceivePack#getAdvertisedRefs()} or * {@link BaseReceivePack#getAdvertisedRefs()} or
* {@link ReceivePack#getAdvertisedObjects()}. * {@link BaseReceivePack#getAdvertisedObjects()}.
*/ */
public class AdvertiseRefsHookChain implements AdvertiseRefsHook { public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
private final AdvertiseRefsHook[] hooks; private final AdvertiseRefsHook[] hooks;
@ -79,7 +79,7 @@ public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
return new AdvertiseRefsHookChain(newHooks, i); return new AdvertiseRefsHookChain(newHooks, i);
} }
public void advertiseRefs(ReceivePack rp) public void advertiseRefs(BaseReceivePack rp)
throws ServiceMayNotContinueException { throws ServiceMayNotContinueException {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
hooks[i].advertiseRefs(rp); hooks[i].advertiseRefs(rp);

1294
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

File diff suppressed because it is too large Load Diff

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java

@ -54,7 +54,7 @@ import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefUpdate;
/** /**
* A command being processed by {@link ReceivePack}. * A command being processed by {@link BaseReceivePack}.
* <p> * <p>
* This command instance roughly translates to the server side representation of * This command instance roughly translates to the server side representation of
* the {@link RemoteRefUpdate} created by the client. * the {@link RemoteRefUpdate} created by the client.
@ -158,7 +158,7 @@ public class ReceiveCommand {
private String message; private String message;
/** /**
* Create a new command for {@link ReceivePack}. * Create a new command for {@link BaseReceivePack}.
* *
* @param oldId * @param oldId
* the old object id; must not be null. Use * 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 * @param oldId
* the old object id; must not be null. Use * the old object id; must not be null. Use
@ -273,7 +273,7 @@ public class ReceiveCommand {
* receive-pack session. * receive-pack session.
* @since 2.0 * @since 2.0
*/ */
public void execute(final ReceivePack rp) { public void execute(final BaseReceivePack rp) {
try { try {
final RefUpdate ru = rp.getRepository().updateRef(getRefName()); final RefUpdate ru = rp.getRepository().updateRef(getRefName());
ru.setRefLogIdent(rp.getRefLogIdent()); ru.setRefLogIdent(rp.getRefLogIdent());

1136
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save