# HG changeset patch # User Artem Tikhomirov # Date 1301008417 -3600 # Node ID 87f40938c9b2947517f8485a38fe816db4f35206 # Parent 2c3e96674e2a8a3aacf46a941bb940e13faf43d7 Configuration handling out of HgLookup (bad idea to use URL to pass keys) diff -r 2c3e96674e2a -r 87f40938c9b2 cmdline/org/tmatesoft/hg/console/Outgoing.java --- a/cmdline/org/tmatesoft/hg/console/Outgoing.java Fri Mar 25 00:05:52 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Outgoing.java Fri Mar 25 00:13:37 2011 +0100 @@ -18,6 +18,8 @@ import static org.tmatesoft.hg.core.Nodeid.NULL; +import java.io.File; +import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; import java.util.LinkedList; @@ -25,6 +27,8 @@ import org.tmatesoft.hg.core.HgException; import org.tmatesoft.hg.core.Nodeid; +import org.tmatesoft.hg.internal.ConfigFile; +import org.tmatesoft.hg.internal.Internals; import org.tmatesoft.hg.repo.HgChangelog; import org.tmatesoft.hg.repo.HgLookup; import org.tmatesoft.hg.repo.HgRemoteRepository; @@ -48,7 +52,14 @@ System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); return; } - HgRemoteRepository hgRemote = new HgLookup().detect(new URL("hg4j-gc")); + String key = "hg4j-gc"; + ConfigFile cfg = new Internals().newConfigFile(); + cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); + String server = cfg.getSection("paths").get(key); + if (server == null) { + throw new HgException(String.format("Can't find server %s specification in the config", key)); + } + HgRemoteRepository hgRemote = new HgLookup().detect(new URL(server)); HgChangelog.ParentWalker pw = hgRepo.getChangelog().new ParentWalker(); pw.init(); diff -r 2c3e96674e2a -r 87f40938c9b2 src/org/tmatesoft/hg/repo/HgLookup.java --- a/src/org/tmatesoft/hg/repo/HgLookup.java Fri Mar 25 00:05:52 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgLookup.java Fri Mar 25 00:13:37 2011 +0100 @@ -18,13 +18,10 @@ import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; import org.tmatesoft.hg.core.HgException; -import org.tmatesoft.hg.internal.ConfigFile; import org.tmatesoft.hg.internal.DataAccessProvider; -import org.tmatesoft.hg.internal.Internals; /** * Utility methods to find Mercurial repository at a given location @@ -81,21 +78,6 @@ if (Boolean.FALSE.booleanValue()) { throw HgRepository.notImplemented(); } - if (url.getProtocol() == null) { - // try configuration keys - String key = url.getHost(); - ConfigFile cfg = new Internals().newConfigFile(); - cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc")); - String server = cfg.getSection("paths").get(key); - if (server == null) { - throw new HgException(String.format("Can't find server %s specification in the config", key)); - } - try { - url = new URL(server); - } catch (MalformedURLException ex) { - throw new HgException(ex); - } - } return new HgRemoteRepository(url); } } diff -r 2c3e96674e2a -r 87f40938c9b2 src/org/tmatesoft/hg/repo/HgRemoteRepository.java --- a/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Fri Mar 25 00:05:52 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Fri Mar 25 00:13:37 2011 +0100 @@ -38,7 +38,8 @@ } public List heads() { - return Collections.emptyList(); + return Collections.singletonList(Nodeid.fromAscii("71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d")); +// return Collections.emptyList(); } public List between(Nodeid base, Nodeid tip) {