Mercurial > jhg
changeset 172:87f40938c9b2
Configuration handling out of HgLookup (bad idea to use URL to pass keys)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 25 Mar 2011 00:13:37 +0100 |
parents | 2c3e96674e2a |
children | 4bf061a7c001 |
files | cmdline/org/tmatesoft/hg/console/Outgoing.java src/org/tmatesoft/hg/repo/HgLookup.java src/org/tmatesoft/hg/repo/HgRemoteRepository.java |
diffstat | 3 files changed, 14 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- 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();
--- 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); } }
--- 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<Nodeid> heads() { - return Collections.emptyList(); + return Collections.singletonList(Nodeid.fromAscii("71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d")); +// return Collections.emptyList(); } public List<Nodeid> between(Nodeid base, Nodeid tip) {