Mercurial > hg4j
annotate cmdline/org/tmatesoft/hg/console/Remote.java @ 604:c3505001a42a
Use nodeid reverse lookup speedup cache for #isKnown, if available
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 06 May 2013 18:53:04 +0200 |
parents | e31e85cf4d4c |
children |
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 /* |
483
e31e85cf4d4c
Handle include and unset directives in config files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
2 * Copyright (c) 2011-2012 TMate Software Ltd |
74
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; |
156
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
21 import java.io.IOException; |
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
|
22 import java.io.InputStream; |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
23 import java.io.OutputStream; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
24 import java.net.HttpURLConnection; |
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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 |
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.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
|
34 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
|
35 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
|
36 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
|
37 |
483
e31e85cf4d4c
Handle include and unset directives in config files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
38 import org.tmatesoft.hg.internal.BasicSessionContext; |
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
|
39 import org.tmatesoft.hg.internal.ConfigFile; |
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
|
40 |
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
|
41 /** |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
69
diff
changeset
|
42 * WORK IN PROGRESS, DO NOT USE |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
69
diff
changeset
|
43 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
69
diff
changeset
|
44 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
69
diff
changeset
|
45 * @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
|
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 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
|
48 |
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 /* |
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 * @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
|
51 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
|
52 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
|
53 // 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
|
54 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
|
55 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
|
56 cmd=branchmap |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
57 cmd=between needs argument pairs, with first element in the pair to be head(!), second to be root of the branch ( |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
58 i.e. (newer-older), not (older-newer) as one might expect. Returned list of nodes comes in reversed order (from newer |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
59 to older) as well |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
60 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
61 cmd=branches&nodes=d6d2a630f4a6d670c90a5ca909150f2b426ec88f+ |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
62 head, root, first parent, second parent |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
63 received: d6d2a630f4a6d670c90a5ca909150f2b426ec88f dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
64 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
65 Sequence, for actual state with merged/closed branch, where 157:d5268ca7715b8d96204fc62abc632e8f55761547 is merge revision of 156 and 53 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
66 >branches, 170:71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
67 71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d d5268ca7715b8d96204fc62abc632e8f55761547 643ddec3be36246fc052cf22ece503fa60cafe22 a6f39e595b2b54f56304470269a936ead77f5725 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
68 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
69 >branches, 156:643ddec3be36246fc052cf22ece503fa60cafe22 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
70 643ddec3be36246fc052cf22ece503fa60cafe22 ade65afe0906febafbf8a2e41002052e0e446471 08754fce5778a3409476ecdb3cec6b5172c34367 40d04c4f771ebbd599eb229145252732a596740a |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
71 >branches, 53:a6f39e595b2b54f56304470269a936ead77f5725 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
72 a6f39e595b2b54f56304470269a936ead77f5725 a6f39e595b2b54f56304470269a936ead77f5725 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 30bd389788464287cee22ccff54c330a4b715de5 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
73 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
74 >branches, 84:08754fce5778a3409476ecdb3cec6b5172c34367 (p1:82) |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
75 08754fce5778a3409476ecdb3cec6b5172c34367 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
76 >branches, 83:40d04c4f771ebbd599eb229145252732a596740a (p1:80) |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
77 40d04c4f771ebbd599eb229145252732a596740a dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
78 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
79 >branches, 51:9429c7bd1920fab164a9d2b621d38d57bcb49ae0 (wrap-data-access branch) |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
80 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
81 >branches, 52:30bd389788464287cee22ccff54c330a4b715de5 (p1:50) |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
82 30bd389788464287cee22ccff54c330a4b715de5 dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
83 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
84 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
85 cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-d5268ca7715b8d96204fc62abc632e8f55761547+40d04c4f771ebbd599eb229145252732a596740a-dbd663faec1f0175619cf7668bddc6350548b8d6 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
86 8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028 dd525ca65de8e78cb133919de57ea0a6e6454664 1d0654be1466d522994f8bead510e360fbeb8d79 c17a08095e4420202ac1b2d939ef6d5f8bebb569 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
87 4222b04f34ee885bc1ad547c7ef330e18a51afc1 5f9635c016819b322ae05a91b3378621b538c933 c677e159391925a50b9a23f557426b2246bc9c5d 0d279bcc44427cb5ae2f3407c02f21187ccc8aea e21df6259f8374ac136767321e837c0c6dd21907 b01500fe2604c2c7eadf44349cce9f438484474b 865bf07f381ff7d1b742453568def92576af80b6 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
88 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
89 Between two subsequent revisions (i.e. direct child in remote of a local root) |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
90 cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
91 empty result |
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
|
92 */ |
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 public static void main(String[] args) throws Exception { |
483
e31e85cf4d4c
Handle include and unset directives in config files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
94 ConfigFile cfg = new ConfigFile(new BasicSessionContext(null)); |
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
|
95 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
|
96 String svnkitServer = cfg.getSection("paths").get("svnkit"); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
97 // URL url = new URL(svnkitServer + "?cmd=branches&nodes=30bd389788464287cee22ccff54c330a4b715de5"); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
98 // URL url = new URL(svnkitServer + "?cmd=between"); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
99 URL url = new URL(svnkitServer + "?cmd=changegroup&roots=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d"); |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
100 // URL url = new URL("http://localhost:8000/" + "?cmd=between"); |
167
86f9581f4301
Write down results of changegroup (or any other BundleFormat) wireprotocol command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
156
diff
changeset
|
101 // URL url = new URL(svnkitServer + "?cmd=stream_out"); |
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
|
102 |
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 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
|
104 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
|
105 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
|
106 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
|
107 } |
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 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
|
109 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
|
110 } |
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 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
|
112 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
|
113 } |
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
|
114 } |
156
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
115 // Hack to get Base64-encoded credentials |
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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 // |
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
|
121 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
|
122 HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
123 // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
124 urlConnection.setRequestProperty("User-Agent", "jhg/0.1.0"); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
125 urlConnection.setRequestProperty("Accept", "application/mercurial-0.1"); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
126 urlConnection.setRequestProperty("Authorization", "Basic " + authInfo); |
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
|
127 urlConnection.setSSLSocketFactory(sslContext.getSocketFactory()); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
128 // byte[] body = "pairs=f5aed108754e817d2ca374d1a4f6daf1218dcc91-9429c7bd1920fab164a9d2b621d38d57bcb49ae0".getBytes(); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
129 // urlConnection.setRequestMethod("POST"); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
130 // urlConnection.setRequestProperty("Content-Length", String.valueOf(body.length)); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
131 // urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
132 // urlConnection.setDoOutput(true); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
133 // urlConnection.setDoInput(true); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
134 urlConnection.connect(); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
135 // OutputStream os = urlConnection.getOutputStream(); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
136 // os.write(body); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
137 // os.flush(); |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
138 // os.close(); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
167
diff
changeset
|
139 System.out.println("Query:" + url.getQuery()); |
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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 } |
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
|
145 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
|
146 InputStream is = urlConnection.getInputStream(); |
156
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
147 // |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
148 // dump(is, -1); // simple dump, any cmd |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
149 writeBundle(is, false, "HG10GZ"); // cmd=changegroup |
167
86f9581f4301
Write down results of changegroup (or any other BundleFormat) wireprotocol command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
156
diff
changeset
|
150 //writeBundle(is, true, "" or "HG10UN"); |
156
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
151 // |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
152 urlConnection.disconnect(); |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
153 // |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
154 } |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
155 |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
156 private static void dump(InputStream is, int limit) throws IOException { |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
157 int b; |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
158 while ((b =is.read()) != -1) { |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
159 System.out.print((char) b); |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
160 if (limit != -1) { |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
161 if (--limit < 0) { |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
162 break; |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
163 } |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
164 } |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
165 } |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
166 System.out.println(); |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
167 } |
643ddec3be36
Investigate pull/clone functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
168 |
167
86f9581f4301
Write down results of changegroup (or any other BundleFormat) wireprotocol command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
156
diff
changeset
|
169 private static void writeBundle(InputStream is, boolean decompress, String header) throws IOException { |
86f9581f4301
Write down results of changegroup (or any other BundleFormat) wireprotocol command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
156
diff
changeset
|
170 InputStream zipStream = decompress ? new InflaterInputStream(is) : is; |
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
|
171 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
|
172 FileOutputStream fos = new FileOutputStream(tf); |
167
86f9581f4301
Write down results of changegroup (or any other BundleFormat) wireprotocol command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
156
diff
changeset
|
173 fos.write(header.getBytes()); |
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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
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
|
179 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
|
180 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
|
181 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
|
182 } |
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
|
183 } |