Mercurial > jhg
diff cmdline/org/tmatesoft/hg/console/Remote.java @ 156:643ddec3be36
Investigate pull/clone functionality
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 02 Mar 2011 01:06:09 +0100 |
parents | 6b55f10ef54b |
children | 86f9581f4301 |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Remote.java Thu Feb 24 22:18:03 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Remote.java Wed Mar 02 01:06:09 2011 +0100 @@ -18,7 +18,9 @@ import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.net.HttpURLConnection; import java.net.URL; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -56,7 +58,9 @@ ConfigFile cfg = new Internals().newConfigFile(); cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); String svnkitServer = cfg.getSection("paths").get("svnkit"); - URL url = new URL(svnkitServer + "?cmd=changegroup&roots=a78c980749e3ccebb47138b547e9b644a22797a9"); +// URL url = new URL(svnkitServer + "?cmd=changegroup&roots=a78c980749e3ccebb47138b547e9b644a22797a9"); +// URL url = new URL("http://localhost:8000/" + "?cmd=stream_out"); + URL url = new URL(svnkitServer + "?cmd=stream_out"); SSLContext sslContext = SSLContext.getInstance("SSL"); class TrustEveryone implements X509TrustManager { @@ -70,7 +74,7 @@ return new X509Certificate[0]; } } - // + // Hack to get Base64-encoded credentials Preferences tempNode = Preferences.userRoot().node("xxx"); tempNode.putByteArray("xxx", url.getUserInfo().getBytes()); String authInfo = tempNode.get("xxx", null); @@ -90,11 +94,28 @@ } System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength()); InputStream is = urlConnection.getInputStream(); -// int b; -// while ((b =is.read()) != -1) { -// System.out.print((char) b); -// } -// System.out.println(); + // + dump(is, -1); // simple dump, any cmd +// writeBundle(is); // cmd=changegroup + // + urlConnection.disconnect(); + // + } + + private static void dump(InputStream is, int limit) throws IOException { + int b; + while ((b =is.read()) != -1) { + System.out.print((char) b); + if (limit != -1) { + if (--limit < 0) { + break; + } + } + } + System.out.println(); + } + + private static void writeBundle(InputStream is) throws IOException { InflaterInputStream zipStream = new InflaterInputStream(is); File tf = File.createTempFile("hg-bundle-", null); FileOutputStream fos = new FileOutputStream(tf); @@ -106,8 +127,5 @@ fos.close(); zipStream.close(); System.out.println(tf); - - urlConnection.disconnect(); - // } }