Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgRemoteRepository.java @ 186:44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 14 Apr 2011 00:47:04 +0200 |
| parents | ec1820f64d2b |
| children | 9b99d27aeddc |
comparison
equal
deleted
inserted
replaced
| 185:c6fa4dbfc458 | 186:44a34baabea0 |
|---|---|
| 63 | 63 |
| 64 private final URL url; | 64 private final URL url; |
| 65 private final SSLContext sslContext; | 65 private final SSLContext sslContext; |
| 66 private final String authInfo; | 66 private final String authInfo; |
| 67 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); | 67 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); |
| 68 private HgLookup lookupHelper; | |
| 68 | 69 |
| 69 HgRemoteRepository(URL url) throws HgBadArgumentException { | 70 HgRemoteRepository(URL url) throws HgBadArgumentException { |
| 70 if (url == null) { | 71 if (url == null) { |
| 71 throw new IllegalArgumentException(); | 72 throw new IllegalArgumentException(); |
| 72 } | 73 } |
| 299 } catch (IOException ex) { | 300 } catch (IOException ex) { |
| 300 throw new HgException(ex); | 301 throw new HgException(ex); |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 | 304 |
| 304 // WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about. | 305 /* |
| 305 // perhaps, shall be named 'changegroup' | 306 * WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about. |
| 307 * | |
| 308 * Perhaps, shall be named 'changegroup' | |
| 309 | |
| 310 * Changegroup: | |
| 311 * http://mercurial.selenic.com/wiki/Merge | |
| 312 * http://mercurial.selenic.com/wiki/WireProtocol | |
| 313 * | |
| 314 * according to latter, bundleformat data is sent through zlib | |
| 315 * (there's no header like HG10?? with the server output, though, | |
| 316 * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat) | |
| 317 */ | |
| 306 public HgBundle getChanges(List<Nodeid> roots) throws HgException { | 318 public HgBundle getChanges(List<Nodeid> roots) throws HgException { |
| 307 StringBuilder sb = new StringBuilder(20 + roots.size() * 41); | 319 StringBuilder sb = new StringBuilder(20 + roots.size() * 41); |
| 308 sb.append("roots="); | 320 sb.append("roots="); |
| 309 for (Nodeid n : roots) { | 321 for (Nodeid n : roots) { |
| 310 sb.append(n.toString()); | 322 sb.append(n.toString()); |
| 320 c.connect(); | 332 c.connect(); |
| 321 if (debug) { | 333 if (debug) { |
| 322 dumpResponseHeader(u, c); | 334 dumpResponseHeader(u, c); |
| 323 } | 335 } |
| 324 File tf = writeBundle(c.getInputStream(), false, "HG10GZ" /*didn't see any other that zip*/); | 336 File tf = writeBundle(c.getInputStream(), false, "HG10GZ" /*didn't see any other that zip*/); |
| 325 return new HgLookup().loadBundle(tf); | 337 return getLookupHelper().loadBundle(tf); |
| 326 } catch (MalformedURLException ex) { | 338 } catch (MalformedURLException ex) { |
| 327 throw new HgException(ex); | 339 throw new HgException(ex); |
| 328 } catch (IOException ex) { | 340 } catch (IOException ex) { |
| 329 throw new HgException(ex); | 341 throw new HgException(ex); |
| 330 } | 342 } |
| 343 } | |
| 344 | |
| 345 private HgLookup getLookupHelper() { | |
| 346 if (lookupHelper == null) { | |
| 347 lookupHelper = new HgLookup(); | |
| 348 } | |
| 349 return lookupHelper; | |
| 331 } | 350 } |
| 332 | 351 |
| 333 private HttpURLConnection setupConnection(URLConnection urlConnection) { | 352 private HttpURLConnection setupConnection(URLConnection urlConnection) { |
| 334 urlConnection.setRequestProperty("User-Agent", "hg4j/0.5.0"); | 353 urlConnection.setRequestProperty("User-Agent", "hg4j/0.5.0"); |
| 335 urlConnection.addRequestProperty("Accept", "application/mercurial-0.1"); | 354 urlConnection.addRequestProperty("Accept", "application/mercurial-0.1"); |
