Update JGit to 0.11.3.219-gefad732

Change-Id: I3d01be0b55a99b37c279cdf73182e635bfd1755e
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2011-04-04 13:34:58 -04:00
parent 66827cf7e4
commit 04e7cfe8f0
2 changed files with 21 additions and 30 deletions

View File

@ -30,22 +30,21 @@ import com.google.inject.Injector;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.google.inject.assistedinject.FactoryProvider; import com.google.inject.assistedinject.FactoryProvider;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig; import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.SshConfigSessionFactory; import org.eclipse.jgit.transport.RemoteSession;
import org.eclipse.jgit.transport.SshSessionFactory; import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.QuotedString; import org.eclipse.jgit.util.QuotedString;
import org.eclipse.jgit.util.io.StreamCopyThread;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -69,7 +68,7 @@ public class PushReplication implements ReplicationQueue {
// Install our own factory which always runs in batch mode, as we // Install our own factory which always runs in batch mode, as we
// have no UI available for interactive prompting. // have no UI available for interactive prompting.
// //
SshSessionFactory.setInstance(new SshConfigSessionFactory() { SshSessionFactory.setInstance(new JschConfigSessionFactory() {
@Override @Override
protected void configure(OpenSshConfig.Host hc, Session session) { protected void configure(OpenSshConfig.Host hc, Session session) {
// Default configuration is batch mode. // Default configuration is batch mode.
@ -218,7 +217,7 @@ public class PushReplication implements ReplicationQueue {
private void replicateProject(final URIish replicateURI, final String head) { private void replicateProject(final URIish replicateURI, final String head) {
SshSessionFactory sshFactory = SshSessionFactory.getInstance(); SshSessionFactory sshFactory = SshSessionFactory.getInstance();
Session sshSession; RemoteSession sshSession;
String projectPath = QuotedString.BOURNE.quote(replicateURI.getPath()); String projectPath = QuotedString.BOURNE.quote(replicateURI.getPath());
if (!usingSSH(replicateURI)) { if (!usingSSH(replicateURI)) {
@ -234,30 +233,22 @@ public class PushReplication implements ReplicationQueue {
+ QuotedString.BOURNE.quote(head); + QuotedString.BOURNE.quote(head);
try { try {
sshSession = sshSession = sshFactory.getSession(replicateURI, null, FS.DETECTED, 0);
sshFactory.getSession(replicateURI.getUser(), replicateURI.getPass(), Process proc = sshSession.exec(cmd, 0);
replicateURI.getHost(), replicateURI.getPort(), null, FS.DETECTED); proc.getOutputStream().close();
sshSession.connect(); StreamCopyThread out = new StreamCopyThread(proc.getInputStream(), errStream);
StreamCopyThread err = new StreamCopyThread(proc.getErrorStream(), errStream);
Channel channel = sshSession.openChannel("exec"); out.start();
((ChannelExec) channel).setCommand(cmd); err.start();
try {
channel.setInputStream(null); proc.waitFor();
out.halt();
((ChannelExec) channel).setErrStream(errStream); err.halt();
} catch (InterruptedException interrupted) {
channel.connect(); // Don't wait, drop out immediately.
while (!channel.isClosed()) {
try {
final int delay = 50;
Thread.sleep(delay);
} catch (InterruptedException e) {
}
} }
channel.disconnect();
sshSession.disconnect(); sshSession.disconnect();
} catch (JSchException e) { } catch (IOException e) {
log.error("Communication error when trying to replicate to: " log.error("Communication error when trying to replicate to: "
+ replicateURI.toString() + "\n" + "Error reported: " + replicateURI.toString() + "\n" + "Error reported: "
+ e.getMessage() + "\n" + "Error in communication: " + e.getMessage() + "\n" + "Error in communication: "
@ -279,7 +270,7 @@ public class PushReplication implements ReplicationQueue {
} }
@Override @Override
public void write(final int b) throws IOException { public synchronized void write(final int b) throws IOException {
if (b == '\r') { if (b == '\r') {
return; return;
} }

View File

@ -46,7 +46,7 @@ limitations under the License.
</issueManagement> </issueManagement>
<properties> <properties>
<jgitVersion>0.11.3.113-ga490afe</jgitVersion> <jgitVersion>0.11.3.219-gefad732</jgitVersion>
<gwtormVersion>1.1.4</gwtormVersion> <gwtormVersion>1.1.4</gwtormVersion>
<gwtjsonrpcVersion>1.2.3</gwtjsonrpcVersion> <gwtjsonrpcVersion>1.2.3</gwtjsonrpcVersion>
<gwtexpuiVersion>1.2.2</gwtexpuiVersion> <gwtexpuiVersion>1.2.2</gwtexpuiVersion>