Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgRemoteRepository.java @ 295:981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Sep 2011 05:35:32 +0200 |
parents | 9fb50c04f03c |
children | dfb8405d996f |
comparison
equal
deleted
inserted
replaced
294:32890bab7209 | 295:981f9f50bb6c |
---|---|
46 import javax.net.ssl.TrustManager; | 46 import javax.net.ssl.TrustManager; |
47 import javax.net.ssl.X509TrustManager; | 47 import javax.net.ssl.X509TrustManager; |
48 | 48 |
49 import org.tmatesoft.hg.core.HgBadArgumentException; | 49 import org.tmatesoft.hg.core.HgBadArgumentException; |
50 import org.tmatesoft.hg.core.HgBadStateException; | 50 import org.tmatesoft.hg.core.HgBadStateException; |
51 import org.tmatesoft.hg.core.HgInvalidFileException; | |
51 import org.tmatesoft.hg.core.HgRemoteConnectionException; | 52 import org.tmatesoft.hg.core.HgRemoteConnectionException; |
52 import org.tmatesoft.hg.core.Nodeid; | 53 import org.tmatesoft.hg.core.Nodeid; |
54 import org.tmatesoft.hg.core.SessionContext; | |
53 | 55 |
54 /** | 56 /** |
55 * WORK IN PROGRESS, DO NOT USE | 57 * WORK IN PROGRESS, DO NOT USE |
56 * | 58 * |
57 * @see http://mercurial.selenic.com/wiki/WireProtocol | 59 * @see http://mercurial.selenic.com/wiki/WireProtocol |
64 private final URL url; | 66 private final URL url; |
65 private final SSLContext sslContext; | 67 private final SSLContext sslContext; |
66 private final String authInfo; | 68 private final String authInfo; |
67 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); | 69 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); |
68 private HgLookup lookupHelper; | 70 private HgLookup lookupHelper; |
69 | 71 private final SessionContext sessionContext; |
70 HgRemoteRepository(URL url) throws HgBadArgumentException { | 72 |
71 if (url == null) { | 73 HgRemoteRepository(SessionContext ctx, URL url) throws HgBadArgumentException { |
74 if (url == null || ctx == null) { | |
72 throw new IllegalArgumentException(); | 75 throw new IllegalArgumentException(); |
73 } | 76 } |
74 this.url = url; | 77 this.url = url; |
78 sessionContext = ctx; | |
75 if ("https".equals(url.getProtocol())) { | 79 if ("https".equals(url.getProtocol())) { |
76 try { | 80 try { |
77 sslContext = SSLContext.getInstance("SSL"); | 81 sslContext = SSLContext.getInstance("SSL"); |
78 class TrustEveryone implements X509TrustManager { | 82 class TrustEveryone implements X509TrustManager { |
79 public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { | 83 public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
320 * | 324 * |
321 * according to latter, bundleformat data is sent through zlib | 325 * according to latter, bundleformat data is sent through zlib |
322 * (there's no header like HG10?? with the server output, though, | 326 * (there's no header like HG10?? with the server output, though, |
323 * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat) | 327 * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat) |
324 */ | 328 */ |
325 public HgBundle getChanges(List<Nodeid> roots) throws HgRemoteConnectionException { | 329 public HgBundle getChanges(List<Nodeid> roots) throws HgRemoteConnectionException, HgInvalidFileException { |
326 List<Nodeid> _roots = roots.isEmpty() ? Collections.singletonList(Nodeid.NULL) : roots; | 330 List<Nodeid> _roots = roots.isEmpty() ? Collections.singletonList(Nodeid.NULL) : roots; |
327 StringBuilder sb = new StringBuilder(20 + _roots.size() * 41); | 331 StringBuilder sb = new StringBuilder(20 + _roots.size() * 41); |
328 sb.append("roots="); | 332 sb.append("roots="); |
329 for (Nodeid n : _roots) { | 333 for (Nodeid n : _roots) { |
330 sb.append(n.toString()); | 334 sb.append(n.toString()); |
359 return getClass().getSimpleName() + '[' + getLocation() + ']'; | 363 return getClass().getSimpleName() + '[' + getLocation() + ']'; |
360 } | 364 } |
361 | 365 |
362 private HgLookup getLookupHelper() { | 366 private HgLookup getLookupHelper() { |
363 if (lookupHelper == null) { | 367 if (lookupHelper == null) { |
364 lookupHelper = new HgLookup(); | 368 lookupHelper = new HgLookup(sessionContext); |
365 } | 369 } |
366 return lookupHelper; | 370 return lookupHelper; |
367 } | 371 } |
368 | 372 |
369 private HttpURLConnection setupConnection(URLConnection urlConnection) { | 373 private HttpURLConnection setupConnection(URLConnection urlConnection) { |