Browse Source

transport: Merge BaseReceivePack into ReceivePack

Move the BaseReceivePack implementation back into ReceivePack. This is a
backward-incompatible change. For example, BaseReceivePack.FirstLine no
longer exists and cannot be referenced.  However, most of the code
should just work by replacing BaseReceivePack with ReceivePack.

Although this is an API change, it only affects callers using JGit as a
server, and there are very few of those in the wild.

Change-Id: I1ce92869435d5eebb7d671be44561e69c6233134
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
next
Masaya Suzuki 5 years ago committed by David Pursehouse
parent
commit
3e9a5f993b
  1. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
  3. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackTest.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AbstractAdvertiseRefsHook.java
  5. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHook.java
  6. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AdvertiseRefsHookChain.java
  7. 1997
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
  8. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java
  9. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
  10. 2008
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java

@ -145,7 +145,7 @@ public class PushCertificateParserTest {
ObjectId newId = ObjectId newId =
ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
String line = oldId.name() + " " + newId.name() + " refs/heads/master"; String line = oldId.name() + " " + newId.name() + " refs/heads/master";
ReceiveCommand cmd = BaseReceivePack.parseCommand(line); ReceiveCommand cmd = ReceivePack.parseCommand(line);
parser.addCommand(cmd); parser.addCommand(cmd);
parser.addCommand(line); parser.addCommand(line);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java

@ -174,7 +174,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
ReceivePack rp = super.createReceivePack(dst); ReceivePack rp = super.createReceivePack(dst);
rp.setAdvertiseRefsHook(new AdvertiseRefsHook() { rp.setAdvertiseRefsHook(new AdvertiseRefsHook() {
@Override @Override
public void advertiseRefs(BaseReceivePack rp2) public void advertiseRefs(ReceivePack rp2)
throws ServiceMayNotContinueException { throws ServiceMayNotContinueException {
rp.setAdvertisedRefs(rp.getRepository().getAllRefs(), rp.setAdvertisedRefs(rp.getRepository().getAllRefs(),
null); null);

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BaseReceivePackTest.java → org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackTest.java

@ -49,14 +49,14 @@ import org.eclipse.jgit.errors.PackProtocolException;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.junit.Test; import org.junit.Test;
/** Tests for base receive-pack utilities. */ /** Tests for receive-pack utilities. */
public class BaseReceivePackTest { public class ReceivePackTest {
@Test @Test
public void parseCommand() throws Exception { public void parseCommand() throws Exception {
String o = "0000000000000000000000000000000000000000"; String o = "0000000000000000000000000000000000000000";
String n = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String n = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String r = "refs/heads/master"; String r = "refs/heads/master";
ReceiveCommand cmd = BaseReceivePack.parseCommand(o + " " + n + " " + r); ReceiveCommand cmd = ReceivePack.parseCommand(o + " " + n + " " + r);
assertEquals(ObjectId.zeroId(), cmd.getOldId()); assertEquals(ObjectId.zeroId(), cmd.getOldId());
assertEquals("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", assertEquals("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
cmd.getNewId().name()); cmd.getNewId().name());
@ -76,7 +76,7 @@ public class BaseReceivePackTest {
private void assertParseCommandFails(String input) { private void assertParseCommandFails(String input) {
try { try {
BaseReceivePack.parseCommand(input); ReceivePack.parseCommand(input);
fail(); fail();
} catch (PackProtocolException e) { } catch (PackProtocolException e) {
// Expected. // Expected.

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

@ -67,7 +67,7 @@ public abstract class AbstractAdvertiseRefsHook implements AdvertiseRefsHook {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void advertiseRefs(BaseReceivePack receivePack) public void advertiseRefs(ReceivePack 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

@ -51,8 +51,8 @@ public interface AdvertiseRefsHook {
/** /**
* A simple hook that advertises the default refs. * A simple hook that advertises the default refs.
* <p> * <p>
* The method implementations do nothing to preserve the default behavior; see * The method implementations do nothing to preserve the default behavior;
* {@link UploadPack#setAdvertisedRefs(java.util.Map)} and * see {@link UploadPack#setAdvertisedRefs(java.util.Map)} and
* {@link ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}. * {@link ReceivePack#setAdvertisedRefs(java.util.Map,java.util.Set)}.
*/ */
AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() { AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() {
@ -62,7 +62,7 @@ public interface AdvertiseRefsHook {
} }
@Override @Override
public void advertiseRefs(BaseReceivePack receivePack) { public void advertiseRefs(ReceivePack receivePack) {
// Do nothing. // Do nothing.
} }
}; };
@ -90,6 +90,6 @@ public interface AdvertiseRefsHook {
* @throws org.eclipse.jgit.transport.ServiceMayNotContinueException * @throws org.eclipse.jgit.transport.ServiceMayNotContinueException
* abort; the message will be sent to the user. * abort; the message will be sent to the user.
*/ */
void advertiseRefs(BaseReceivePack receivePack) void advertiseRefs(ReceivePack receivePack)
throws ServiceMayNotContinueException; throws ServiceMayNotContinueException;
} }

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

@ -53,7 +53,7 @@ import java.util.List;
* 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 org.eclipse.jgit.transport.UploadPack#getAdvertisedRefs()}, or * {@link org.eclipse.jgit.transport.UploadPack#getAdvertisedRefs()}, or
* {@link org.eclipse.jgit.transport.ReceivePack#getAdvertisedRefs()} or * {@link org.eclipse.jgit.transport.ReceivePack#getAdvertisedRefs()} or
* {@link org.eclipse.jgit.transport.BaseReceivePack#getAdvertisedObjects()}. * {@link org.eclipse.jgit.transport.ReceivePack#getAdvertisedObjects()}.
*/ */
public class AdvertiseRefsHookChain implements AdvertiseRefsHook { public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
private final AdvertiseRefsHook[] hooks; private final AdvertiseRefsHook[] hooks;
@ -82,7 +82,7 @@ public class AdvertiseRefsHookChain implements AdvertiseRefsHook {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void advertiseRefs(BaseReceivePack rp) public void advertiseRefs(ReceivePack 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);

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

File diff suppressed because it is too large Load Diff

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

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static org.eclipse.jgit.transport.BaseReceivePack.parseCommand; import static org.eclipse.jgit.transport.ReceivePack.parseCommand;
import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_PUSH_CERT; import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_PUSH_CERT;
import java.io.EOFException; import java.io.EOFException;

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

@ -65,7 +65,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
/** /**
* A command being processed by * A command being processed by
* {@link org.eclipse.jgit.transport.BaseReceivePack}. * {@link org.eclipse.jgit.transport.ReceivePack}.
* <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 org.eclipse.jgit.transport.RemoteRefUpdate} created by the client. * the {@link org.eclipse.jgit.transport.RemoteRefUpdate} created by the client.
@ -290,7 +290,7 @@ public class ReceiveCommand {
/** /**
* Create a new command for * Create a new command for
* {@link org.eclipse.jgit.transport.BaseReceivePack}. * {@link org.eclipse.jgit.transport.ReceivePack}.
* *
* @param oldId * @param oldId
* the expected old object id; must not be null. Use * the expected old object id; must not be null. Use
@ -334,7 +334,7 @@ public class ReceiveCommand {
/** /**
* Create a new command for * Create a new command for
* {@link org.eclipse.jgit.transport.BaseReceivePack}. * {@link org.eclipse.jgit.transport.ReceivePack}.
* *
* @param oldId * @param oldId
* the old object id; must not be null. Use * the old object id; must not be null. Use
@ -770,7 +770,7 @@ public class ReceiveCommand {
* receive-pack session. * receive-pack session.
* @since 2.0 * @since 2.0
*/ */
public void execute(BaseReceivePack rp) { public void execute(ReceivePack rp) {
try { try {
String expTarget = getOldSymref(); String expTarget = getOldSymref();
boolean detach = getNewSymref() != null boolean detach = getNewSymref() != null

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

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