annotate cmdline/org/tmatesoft/hg/console/Remote.java @ 155:a4ec5e087017

Dedicated location for various test data
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 24 Feb 2011 22:18:03 +0100
parents 6b55f10ef54b
children 643ddec3be36
rev   line source
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
2 * Copyright (c) 2011 TMate Software Ltd
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
4 * This program is free software; you can redistribute it and/or modify
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
5 * it under the terms of the GNU General Public License as published by
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
6 * the Free Software Foundation; version 2 of the License.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
8 * This program is distributed in the hope that it will be useful,
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
13 * For information on how to redistribute this software under
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
15 * contact TMate Software at support@hg4j.com
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
17 package org.tmatesoft.hg.console;
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.io.File;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 import java.io.FileOutputStream;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 import java.io.InputStream;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import java.net.URL;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.security.cert.CertificateException;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import java.security.cert.X509Certificate;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import java.util.List;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import java.util.Map;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import java.util.prefs.Preferences;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import java.util.zip.InflaterInputStream;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import javax.net.ssl.HttpsURLConnection;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import javax.net.ssl.SSLContext;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 import javax.net.ssl.TrustManager;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 import javax.net.ssl.X509TrustManager;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 import org.tmatesoft.hg.internal.ConfigFile;
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
36 import org.tmatesoft.hg.internal.Internals;
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 /**
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
39 * WORK IN PROGRESS, DO NOT USE
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
40 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
41 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 69
diff changeset
42 * @author TMate Software Ltd.
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 */
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 public class Remote {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 /*
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 * @see http://mercurial.selenic.com/wiki/WireProtocol
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 cmd=branches gives 4 nodeids (head, root, first parent, second parent) per line (few lines possible, per branch, perhaps?)
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 cmd=capabilities gives lookup ...subset and 3 compress methods
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 // lookup changegroupsubset unbundle=HG10GZ,HG10BZ,HG10UN
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 cmd=heads gives space-separated list of nodeids (or just one)
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 nodeids are in hex (printable) format, need to convert fromAscii()
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53 cmd=branchmap
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 */
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 public static void main(String[] args) throws Exception {
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
56 ConfigFile cfg = new Internals().newConfigFile();
69
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc"));
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 String svnkitServer = cfg.getSection("paths").get("svnkit");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 URL url = new URL(svnkitServer + "?cmd=changegroup&roots=a78c980749e3ccebb47138b547e9b644a22797a9");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 SSLContext sslContext = SSLContext.getInstance("SSL");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 class TrustEveryone implements X509TrustManager {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 System.out.println("checkClientTrusted " + authType);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 System.out.println("checkServerTrusted" + authType);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 public X509Certificate[] getAcceptedIssuers() {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 return new X509Certificate[0];
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 //
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 Preferences tempNode = Preferences.userRoot().node("xxx");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 tempNode.putByteArray("xxx", url.getUserInfo().getBytes());
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 String authInfo = tempNode.get("xxx", null);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 tempNode.removeNode();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 //
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 sslContext.init(null, new TrustManager[] { new TrustEveryone() }, null);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 urlConnection.addRequestProperty("User-Agent", "jhg/0.1.0");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 urlConnection.addRequestProperty("Accept", "application/mercurial-0.1");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 urlConnection.addRequestProperty("Authorization", "Basic " + authInfo);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 urlConnection.connect();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 System.out.println("Response headers:");
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 final Map<String, List<String>> headerFields = urlConnection.getHeaderFields();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 for (String s : headerFields.keySet()) {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s));
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength());
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 InputStream is = urlConnection.getInputStream();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 // int b;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 // while ((b =is.read()) != -1) {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 // System.out.print((char) b);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 // }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 // System.out.println();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 InflaterInputStream zipStream = new InflaterInputStream(is);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 File tf = File.createTempFile("hg-bundle-", null);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100 FileOutputStream fos = new FileOutputStream(tf);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 int r;
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 byte[] buf = new byte[8*1024];
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 while ((r = zipStream.read(buf)) != -1) {
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
104 fos.write(buf, 0, r);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 fos.close();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 zipStream.close();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108 System.out.println(tf);
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
109
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
110 urlConnection.disconnect();
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 //
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112 }
5a69397f0f99 Discovery utility for Hg network protocol finally in the repo, with quick-n-dirty ConfigFile impl that helps to hide auth info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
113 }