Mercurial > hg4j
diff cmdline/org/tmatesoft/hg/console/Outgoing.java @ 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 | a8df7162ec75 |
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();