comparison src/org/tmatesoft/hg/core/HgUpdateConfigCommand.java @ 382:82336b7c54f4

Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 10 Feb 2012 13:56:24 +0100
parents 9fb990c8a724
children 9c9c442b5f2e
comparison
equal deleted inserted replaced
381:6e37c7168585 382:82336b7c54f4
24 import java.util.Map; 24 import java.util.Map;
25 25
26 import org.tmatesoft.hg.internal.ConfigFile; 26 import org.tmatesoft.hg.internal.ConfigFile;
27 import org.tmatesoft.hg.internal.Experimental; 27 import org.tmatesoft.hg.internal.Experimental;
28 import org.tmatesoft.hg.internal.Internals; 28 import org.tmatesoft.hg.internal.Internals;
29 import org.tmatesoft.hg.repo.HgInternals;
29 import org.tmatesoft.hg.repo.HgRepository; 30 import org.tmatesoft.hg.repo.HgRepository;
30 31
31 /** 32 /**
32 * WORK IN PROGRESS, DO NOT USE 33 * WORK IN PROGRESS, DO NOT USE
33 * 34 *
35 * @author TMate Software Ltd. 36 * @author TMate Software Ltd.
36 */ 37 */
37 @Experimental(reason="Investigating approaches to alter Hg configuration files") 38 @Experimental(reason="Investigating approaches to alter Hg configuration files")
38 public final class HgUpdateConfigCommand extends HgAbstractCommand<HgUpdateConfigCommand> { 39 public final class HgUpdateConfigCommand extends HgAbstractCommand<HgUpdateConfigCommand> {
39 40
40 private final HgRepository repo;
41 private final File configFile; 41 private final File configFile;
42 42
43 private Map<String,List<String>> toRemove; 43 private Map<String,List<String>> toRemove;
44 private Map<String,Map<String,String>> toSet; 44 private Map<String,Map<String,String>> toSet;
45 45
46 private HgUpdateConfigCommand(HgRepository hgRepo, File configurationFile) { 46 private HgUpdateConfigCommand(File configurationFile) {
47 repo = hgRepo;
48 configFile = configurationFile; 47 configFile = configurationFile;
49 } 48 }
50 49
51 public static HgUpdateConfigCommand forRepository(HgRepository hgRepo) { 50 public static HgUpdateConfigCommand forRepository(HgRepository hgRepo) {
52 return new HgUpdateConfigCommand(hgRepo, new File(".hg/hgrc")); 51 // XXX HgRepository to implement SessionContextProvider (with getContext())?
52 return new HgUpdateConfigCommand(new File(HgInternals.getRepositoryDir(hgRepo), "hgrc"));
53 } 53 }
54 54
55 public static HgUpdateConfigCommand forUser(HgRepository hgRepo) { 55 public static HgUpdateConfigCommand forUser(SessionContext ctx) {
56 return new HgUpdateConfigCommand(null, Internals.getUserConfigurationFileToWrite()); 56 return new HgUpdateConfigCommand(Internals.getUserConfigurationFileToWrite(ctx));
57 } 57 }
58 58
59 public static HgUpdateConfigCommand forInstallation() { 59 public static HgUpdateConfigCommand forInstallation(SessionContext ctx) {
60 return new HgUpdateConfigCommand(null, Internals.getInstallationConfigurationFileToWrite()); 60 return new HgUpdateConfigCommand(Internals.getInstallationConfigurationFileToWrite(ctx));
61 } 61 }
62 62
63 /** 63 /**
64 * Remove a property altogether 64 * Remove a property altogether
65 * @return <code>this</code> for convenience 65 * @return <code>this</code> for convenience