Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Remote.java @ 171:2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 25 Mar 2011 00:05:52 +0100 |
parents | 86f9581f4301 |
children | e10225daface |
comparison
equal
deleted
inserted
replaced
170:71ddbf8603e8 | 171:2c3e96674e2a |
---|---|
18 | 18 |
19 import java.io.File; | 19 import java.io.File; |
20 import java.io.FileOutputStream; | 20 import java.io.FileOutputStream; |
21 import java.io.IOException; | 21 import java.io.IOException; |
22 import java.io.InputStream; | 22 import java.io.InputStream; |
23 import java.net.HttpURLConnection; | |
24 import java.net.URL; | 23 import java.net.URL; |
25 import java.security.cert.CertificateException; | 24 import java.security.cert.CertificateException; |
26 import java.security.cert.X509Certificate; | 25 import java.security.cert.X509Certificate; |
27 import java.util.List; | 26 import java.util.List; |
28 import java.util.Map; | 27 import java.util.Map; |
32 import javax.net.ssl.HttpsURLConnection; | 31 import javax.net.ssl.HttpsURLConnection; |
33 import javax.net.ssl.SSLContext; | 32 import javax.net.ssl.SSLContext; |
34 import javax.net.ssl.TrustManager; | 33 import javax.net.ssl.TrustManager; |
35 import javax.net.ssl.X509TrustManager; | 34 import javax.net.ssl.X509TrustManager; |
36 | 35 |
37 import org.tmatesoft.hg.core.Nodeid; | |
38 import org.tmatesoft.hg.internal.ConfigFile; | 36 import org.tmatesoft.hg.internal.ConfigFile; |
39 import org.tmatesoft.hg.internal.Internals; | 37 import org.tmatesoft.hg.internal.Internals; |
40 | 38 |
41 /** | 39 /** |
42 * WORK IN PROGRESS, DO NOT USE | 40 * WORK IN PROGRESS, DO NOT USE |
52 cmd=capabilities gives lookup ...subset and 3 compress methods | 50 cmd=capabilities gives lookup ...subset and 3 compress methods |
53 // lookup changegroupsubset unbundle=HG10GZ,HG10BZ,HG10UN | 51 // lookup changegroupsubset unbundle=HG10GZ,HG10BZ,HG10UN |
54 cmd=heads gives space-separated list of nodeids (or just one) | 52 cmd=heads gives space-separated list of nodeids (or just one) |
55 nodeids are in hex (printable) format, need to convert fromAscii() | 53 nodeids are in hex (printable) format, need to convert fromAscii() |
56 cmd=branchmap | 54 cmd=branchmap |
55 cmd=between needs argument pairs, with first element in the pair to be head(!), second to be root of the branch ( | |
56 i.e. (newer-older), not (older-newer) as one might expect. Returned list of nodes comes in reversed order (from newer | |
57 to older) as well | |
58 | |
59 cmd=branches&nodes=d6d2a630f4a6d670c90a5ca909150f2b426ec88f+ | |
60 head, root, first parent, second parent | |
61 received: d6d2a630f4a6d670c90a5ca909150f2b426ec88f dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |
62 | |
63 Sequence, for actual state with merged/closed branch, where 157:d5268ca7715b8d96204fc62abc632e8f55761547 is merge revision of 156 and 53 | |
64 >branches, 170:71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d | |
65 71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d d5268ca7715b8d96204fc62abc632e8f55761547 643ddec3be36246fc052cf22ece503fa60cafe22 a6f39e595b2b54f56304470269a936ead77f5725 | |
66 | |
67 >branches, 156:643ddec3be36246fc052cf22ece503fa60cafe22 | |
68 643ddec3be36246fc052cf22ece503fa60cafe22 ade65afe0906febafbf8a2e41002052e0e446471 08754fce5778a3409476ecdb3cec6b5172c34367 40d04c4f771ebbd599eb229145252732a596740a | |
69 >branches, 53:a6f39e595b2b54f56304470269a936ead77f5725 | |
70 a6f39e595b2b54f56304470269a936ead77f5725 a6f39e595b2b54f56304470269a936ead77f5725 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 30bd389788464287cee22ccff54c330a4b715de5 | |
71 | |
72 >branches, 84:08754fce5778a3409476ecdb3cec6b5172c34367 (p1:82) | |
73 08754fce5778a3409476ecdb3cec6b5172c34367 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |
74 >branches, 83:40d04c4f771ebbd599eb229145252732a596740a (p1:80) | |
75 40d04c4f771ebbd599eb229145252732a596740a dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |
76 | |
77 >branches, 51:9429c7bd1920fab164a9d2b621d38d57bcb49ae0 (wrap-data-access branch) | |
78 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |
79 >branches, 52:30bd389788464287cee22ccff54c330a4b715de5 (p1:50) | |
80 30bd389788464287cee22ccff54c330a4b715de5 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |
81 | |
82 | |
83 cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-d5268ca7715b8d96204fc62abc632e8f55761547+40d04c4f771ebbd599eb229145252732a596740a-dbd663faec1f0175619cf7668bddc6350548b8d6 | |
84 8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028 dd525ca65de8e78cb133919de57ea0a6e6454664 1d0654be1466d522994f8bead510e360fbeb8d79 c17a08095e4420202ac1b2d939ef6d5f8bebb569 | |
85 4222b04f34ee885bc1ad547c7ef330e18a51afc1 5f9635c016819b322ae05a91b3378621b538c933 c677e159391925a50b9a23f557426b2246bc9c5d 0d279bcc44427cb5ae2f3407c02f21187ccc8aea e21df6259f8374ac136767321e837c0c6dd21907 b01500fe2604c2c7eadf44349cce9f438484474b 865bf07f381ff7d1b742453568def92576af80b6 | |
86 | |
87 Between two subsequent revisions (i.e. direct child in remote of a local root) | |
88 cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028 | |
89 empty result | |
57 */ | 90 */ |
58 public static void main(String[] args) throws Exception { | 91 public static void main(String[] args) throws Exception { |
59 ConfigFile cfg = new Internals().newConfigFile(); | 92 ConfigFile cfg = new Internals().newConfigFile(); |
60 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); | 93 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); |
61 String svnkitServer = cfg.getSection("paths").get("svnkit"); | 94 String svnkitServer = cfg.getSection("paths").get("svnkit"); |
62 URL url = new URL(svnkitServer + "?cmd=changegroup&roots=" + Nodeid.NULL.toString()); | 95 // URL url = new URL(svnkitServer + "?cmd=branches&nodes=30bd389788464287cee22ccff54c330a4b715de5"); |
96 URL url = new URL(svnkitServer + "?cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028"); | |
97 // URL url = new URL(svnkitServer + "?cmd=changegroup&roots=" + Nodeid.NULL.toString()); | |
63 // URL url = new URL("http://localhost:8000/" + "?cmd=stream_out"); | 98 // URL url = new URL("http://localhost:8000/" + "?cmd=stream_out"); |
64 // URL url = new URL(svnkitServer + "?cmd=stream_out"); | 99 // URL url = new URL(svnkitServer + "?cmd=stream_out"); |
65 | 100 |
66 SSLContext sslContext = SSLContext.getInstance("SSL"); | 101 SSLContext sslContext = SSLContext.getInstance("SSL"); |
67 class TrustEveryone implements X509TrustManager { | 102 class TrustEveryone implements X509TrustManager { |
86 urlConnection.addRequestProperty("User-Agent", "jhg/0.1.0"); | 121 urlConnection.addRequestProperty("User-Agent", "jhg/0.1.0"); |
87 urlConnection.addRequestProperty("Accept", "application/mercurial-0.1"); | 122 urlConnection.addRequestProperty("Accept", "application/mercurial-0.1"); |
88 urlConnection.addRequestProperty("Authorization", "Basic " + authInfo); | 123 urlConnection.addRequestProperty("Authorization", "Basic " + authInfo); |
89 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); | 124 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); |
90 urlConnection.connect(); | 125 urlConnection.connect(); |
126 System.out.println("Query:" + url.getQuery()); | |
91 System.out.println("Response headers:"); | 127 System.out.println("Response headers:"); |
92 final Map<String, List<String>> headerFields = urlConnection.getHeaderFields(); | 128 final Map<String, List<String>> headerFields = urlConnection.getHeaderFields(); |
93 for (String s : headerFields.keySet()) { | 129 for (String s : headerFields.keySet()) { |
94 System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s)); | 130 System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s)); |
95 } | 131 } |
96 System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength()); | 132 System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength()); |
97 InputStream is = urlConnection.getInputStream(); | 133 InputStream is = urlConnection.getInputStream(); |
98 // | 134 // |
99 // dump(is, -1); // simple dump, any cmd | 135 dump(is, -1); // simple dump, any cmd |
100 writeBundle(is, false, "HG10GZ"); // cmd=changegroup | 136 // writeBundle(is, false, "HG10GZ"); // cmd=changegroup |
101 //writeBundle(is, true, "" or "HG10UN"); | 137 //writeBundle(is, true, "" or "HG10UN"); |
102 // | 138 // |
103 urlConnection.disconnect(); | 139 urlConnection.disconnect(); |
104 // | 140 // |
105 } | 141 } |