Просмотр исходного кода

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>
tags/v5.6.0.201911271000-m3
Masaya Suzuki 4 лет назад
Родитель
Сommit
3e9a5f993b

+ 1
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java Просмотреть файл

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

parser.addCommand(cmd);
parser.addCommand(line);

+ 1
- 1
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);
rp.setAdvertiseRefsHook(new AdvertiseRefsHook() {
@Override
public void advertiseRefs(BaseReceivePack rp2)
public void advertiseRefs(ReceivePack rp2)
throws ServiceMayNotContinueException {
rp.setAdvertisedRefs(rp.getRepository().getAllRefs(),
null);

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.junit.Test;

/** Tests for base receive-pack utilities. */
public class BaseReceivePackTest {
/** Tests for receive-pack utilities. */
public class ReceivePackTest {
@Test
public void parseCommand() throws Exception {
String o = "0000000000000000000000000000000000000000";
String n = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
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("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
cmd.getNewId().name());
@@ -76,7 +76,7 @@ public class BaseReceivePackTest {

private void assertParseCommandFails(String input) {
try {
BaseReceivePack.parseCommand(input);
ReceivePack.parseCommand(input);
fail();
} catch (PackProtocolException e) {
// Expected.

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/transport/AbstractAdvertiseRefsHook.java Просмотреть файл

@@ -67,7 +67,7 @@ public abstract class AbstractAdvertiseRefsHook implements AdvertiseRefsHook {

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

+ 4
- 4
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.
* <p>
* The method implementations do nothing to preserve the default behavior; see
* {@link UploadPack#setAdvertisedRefs(java.util.Map)} and
* 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)}.
*/
AdvertiseRefsHook DEFAULT = new AdvertiseRefsHook() {
@@ -62,7 +62,7 @@ public interface AdvertiseRefsHook {
}

@Override
public void advertiseRefs(BaseReceivePack receivePack) {
public void advertiseRefs(ReceivePack receivePack) {
// Do nothing.
}
};
@@ -90,6 +90,6 @@ public interface AdvertiseRefsHook {
* @throws org.eclipse.jgit.transport.ServiceMayNotContinueException
* abort; the message will be sent to the user.
*/
void advertiseRefs(BaseReceivePack receivePack)
void advertiseRefs(ReceivePack receivePack)
throws ServiceMayNotContinueException;
}

+ 2
- 2
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
* {@link org.eclipse.jgit.transport.UploadPack#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 {
private final AdvertiseRefsHook[] hooks;
@@ -82,7 +82,7 @@ public class AdvertiseRefsHookChain implements AdvertiseRefsHook {

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

+ 0
- 1997
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java Просмотреть файл

@@ -43,7 +43,7 @@

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 java.io.EOFException;

+ 4
- 4
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
* {@link org.eclipse.jgit.transport.BaseReceivePack}.
* {@link org.eclipse.jgit.transport.ReceivePack}.
* <p>
* This command instance roughly translates to the server side representation of
* the {@link org.eclipse.jgit.transport.RemoteRefUpdate} created by the client.
@@ -290,7 +290,7 @@ public class ReceiveCommand {

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

/**
* Create a new command for
* {@link org.eclipse.jgit.transport.BaseReceivePack}.
* {@link org.eclipse.jgit.transport.ReceivePack}.
*
* @param oldId
* the old object id; must not be null. Use
@@ -770,7 +770,7 @@ public class ReceiveCommand {
* receive-pack session.
* @since 2.0
*/
public void execute(BaseReceivePack rp) {
public void execute(ReceivePack rp) {
try {
String expTarget = getOldSymref();
boolean detach = getNewSymref() != null

+ 1922
- 88
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


Загрузка…
Отмена
Сохранить