comparison 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
comparison
equal deleted inserted replaced
171:2c3e96674e2a 172:87f40938c9b2
16 */ 16 */
17 package org.tmatesoft.hg.console; 17 package org.tmatesoft.hg.console;
18 18
19 import static org.tmatesoft.hg.core.Nodeid.NULL; 19 import static org.tmatesoft.hg.core.Nodeid.NULL;
20 20
21 import java.io.File;
22 import java.net.MalformedURLException;
21 import java.net.URL; 23 import java.net.URL;
22 import java.util.Collection; 24 import java.util.Collection;
23 import java.util.LinkedList; 25 import java.util.LinkedList;
24 import java.util.List; 26 import java.util.List;
25 27
26 import org.tmatesoft.hg.core.HgException; 28 import org.tmatesoft.hg.core.HgException;
27 import org.tmatesoft.hg.core.Nodeid; 29 import org.tmatesoft.hg.core.Nodeid;
30 import org.tmatesoft.hg.internal.ConfigFile;
31 import org.tmatesoft.hg.internal.Internals;
28 import org.tmatesoft.hg.repo.HgChangelog; 32 import org.tmatesoft.hg.repo.HgChangelog;
29 import org.tmatesoft.hg.repo.HgLookup; 33 import org.tmatesoft.hg.repo.HgLookup;
30 import org.tmatesoft.hg.repo.HgRemoteRepository; 34 import org.tmatesoft.hg.repo.HgRemoteRepository;
31 import org.tmatesoft.hg.repo.HgRemoteRepository.RemoteBranch; 35 import org.tmatesoft.hg.repo.HgRemoteRepository.RemoteBranch;
32 import org.tmatesoft.hg.repo.HgRepository; 36 import org.tmatesoft.hg.repo.HgRepository;
46 HgRepository hgRepo = cmdLineOpts.findRepository(); 50 HgRepository hgRepo = cmdLineOpts.findRepository();
47 if (hgRepo.isInvalid()) { 51 if (hgRepo.isInvalid()) {
48 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); 52 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
49 return; 53 return;
50 } 54 }
51 HgRemoteRepository hgRemote = new HgLookup().detect(new URL("hg4j-gc")); 55 String key = "hg4j-gc";
56 ConfigFile cfg = new Internals().newConfigFile();
57 cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc"));
58 String server = cfg.getSection("paths").get(key);
59 if (server == null) {
60 throw new HgException(String.format("Can't find server %s specification in the config", key));
61 }
62 HgRemoteRepository hgRemote = new HgLookup().detect(new URL(server));
52 63
53 HgChangelog.ParentWalker pw = hgRepo.getChangelog().new ParentWalker(); 64 HgChangelog.ParentWalker pw = hgRepo.getChangelog().new ParentWalker();
54 pw.init(); 65 pw.init();
55 66
56 List<Nodeid> commonKnown = findCommonWithRemote(pw, hgRemote); 67 List<Nodeid> commonKnown = findCommonWithRemote(pw, hgRemote);