Mercurial > hg4j
diff 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 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Wed Apr 13 19:55:59 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Thu Apr 14 00:47:04 2011 +0200 @@ -65,6 +65,7 @@ private final SSLContext sslContext; private final String authInfo; private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); + private HgLookup lookupHelper; HgRemoteRepository(URL url) throws HgBadArgumentException { if (url == null) { @@ -301,8 +302,19 @@ } } - // WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about. - // perhaps, shall be named 'changegroup' + /* + * WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about. + * + * Perhaps, shall be named 'changegroup' + + * Changegroup: + * http://mercurial.selenic.com/wiki/Merge + * http://mercurial.selenic.com/wiki/WireProtocol + * + * according to latter, bundleformat data is sent through zlib + * (there's no header like HG10?? with the server output, though, + * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat) + */ public HgBundle getChanges(List<Nodeid> roots) throws HgException { StringBuilder sb = new StringBuilder(20 + roots.size() * 41); sb.append("roots="); @@ -322,13 +334,20 @@ dumpResponseHeader(u, c); } File tf = writeBundle(c.getInputStream(), false, "HG10GZ" /*didn't see any other that zip*/); - return new HgLookup().loadBundle(tf); + return getLookupHelper().loadBundle(tf); } catch (MalformedURLException ex) { throw new HgException(ex); } catch (IOException ex) { throw new HgException(ex); } } + + private HgLookup getLookupHelper() { + if (lookupHelper == null) { + lookupHelper = new HgLookup(); + } + return lookupHelper; + } private HttpURLConnection setupConnection(URLConnection urlConnection) { urlConnection.setRequestProperty("User-Agent", "hg4j/0.5.0");