Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Remote.java @ 179:da426c2fe1ec
Support for changegroup wire command
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 06 Apr 2011 02:50:26 +0200 |
| parents | 62665d8f0686 |
| children | 981f9f50bb6c |
comparison
equal
deleted
inserted
replaced
| 178:62665d8f0686 | 179:da426c2fe1ec |
|---|---|
| 93 public static void main(String[] args) throws Exception { | 93 public static void main(String[] args) throws Exception { |
| 94 ConfigFile cfg = new Internals().newConfigFile(); | 94 ConfigFile cfg = new Internals().newConfigFile(); |
| 95 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); | 95 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); |
| 96 String svnkitServer = cfg.getSection("paths").get("svnkit"); | 96 String svnkitServer = cfg.getSection("paths").get("svnkit"); |
| 97 // URL url = new URL(svnkitServer + "?cmd=branches&nodes=30bd389788464287cee22ccff54c330a4b715de5"); | 97 // URL url = new URL(svnkitServer + "?cmd=branches&nodes=30bd389788464287cee22ccff54c330a4b715de5"); |
| 98 URL url = new URL(svnkitServer + "?cmd=between"); | 98 // URL url = new URL(svnkitServer + "?cmd=between"); |
| 99 // URL url = new URL(svnkitServer + "?cmd=changegroup&roots=" + Nodeid.NULL.toString()); | 99 URL url = new URL(svnkitServer + "?cmd=changegroup&roots=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d"); |
| 100 // URL url = new URL("http://localhost:8000/" + "?cmd=between"); | 100 // URL url = new URL("http://localhost:8000/" + "?cmd=between"); |
| 101 // URL url = new URL(svnkitServer + "?cmd=stream_out"); | 101 // URL url = new URL(svnkitServer + "?cmd=stream_out"); |
| 102 | 102 |
| 103 SSLContext sslContext = SSLContext.getInstance("SSL"); | 103 SSLContext sslContext = SSLContext.getInstance("SSL"); |
| 104 class TrustEveryone implements X509TrustManager { | 104 class TrustEveryone implements X509TrustManager { |
| 123 // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); | 123 // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); |
| 124 urlConnection.setRequestProperty("User-Agent", "jhg/0.1.0"); | 124 urlConnection.setRequestProperty("User-Agent", "jhg/0.1.0"); |
| 125 urlConnection.setRequestProperty("Accept", "application/mercurial-0.1"); | 125 urlConnection.setRequestProperty("Accept", "application/mercurial-0.1"); |
| 126 urlConnection.setRequestProperty("Authorization", "Basic " + authInfo); | 126 urlConnection.setRequestProperty("Authorization", "Basic " + authInfo); |
| 127 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); | 127 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); |
| 128 byte[] body = "pairs=f5aed108754e817d2ca374d1a4f6daf1218dcc91-9429c7bd1920fab164a9d2b621d38d57bcb49ae0".getBytes(); | 128 // byte[] body = "pairs=f5aed108754e817d2ca374d1a4f6daf1218dcc91-9429c7bd1920fab164a9d2b621d38d57bcb49ae0".getBytes(); |
| 129 urlConnection.setRequestMethod("POST"); | 129 // urlConnection.setRequestMethod("POST"); |
| 130 urlConnection.setRequestProperty("Content-Length", String.valueOf(body.length)); | 130 // urlConnection.setRequestProperty("Content-Length", String.valueOf(body.length)); |
| 131 urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); | 131 // urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
| 132 urlConnection.setDoOutput(true); | 132 // urlConnection.setDoOutput(true); |
| 133 urlConnection.setDoInput(true); | 133 // urlConnection.setDoInput(true); |
| 134 // urlConnection.connect(); | 134 urlConnection.connect(); |
| 135 OutputStream os = urlConnection.getOutputStream(); | 135 // OutputStream os = urlConnection.getOutputStream(); |
| 136 os.write(body); | 136 // os.write(body); |
| 137 os.flush(); | 137 // os.flush(); |
| 138 os.close(); | 138 // os.close(); |
| 139 System.out.println("Query:" + url.getQuery()); | 139 System.out.println("Query:" + url.getQuery()); |
| 140 System.out.println("Response headers:"); | 140 System.out.println("Response headers:"); |
| 141 final Map<String, List<String>> headerFields = urlConnection.getHeaderFields(); | 141 final Map<String, List<String>> headerFields = urlConnection.getHeaderFields(); |
| 142 for (String s : headerFields.keySet()) { | 142 for (String s : headerFields.keySet()) { |
| 143 System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s)); | 143 System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s)); |
| 144 } | 144 } |
| 145 System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength()); | 145 System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength()); |
| 146 InputStream is = urlConnection.getInputStream(); | 146 InputStream is = urlConnection.getInputStream(); |
| 147 // | 147 // |
| 148 dump(is, -1); // simple dump, any cmd | 148 // dump(is, -1); // simple dump, any cmd |
| 149 // writeBundle(is, false, "HG10GZ"); // cmd=changegroup | 149 writeBundle(is, false, "HG10GZ"); // cmd=changegroup |
| 150 //writeBundle(is, true, "" or "HG10UN"); | 150 //writeBundle(is, true, "" or "HG10UN"); |
| 151 // | 151 // |
| 152 urlConnection.disconnect(); | 152 urlConnection.disconnect(); |
| 153 // | 153 // |
| 154 } | 154 } |
