diff src/org/tmatesoft/hg/core/HgUpdateConfigCommand.java @ 483:e31e85cf4d4c

Handle include and unset directives in config files
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 07 Aug 2012 19:14:53 +0200
parents 31a89587eb04
children b3c16d1aede0
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgUpdateConfigCommand.java	Tue Aug 07 14:27:13 2012 +0200
+++ b/src/org/tmatesoft/hg/core/HgUpdateConfigCommand.java	Tue Aug 07 19:14:53 2012 +0200
@@ -43,21 +43,24 @@
 	private Map<String,List<String>> toRemove;
 	private Map<String,Map<String,String>> toSet;
 
-	private HgUpdateConfigCommand(File configurationFile) {
+	private final SessionContext sessionCtx;
+
+	private HgUpdateConfigCommand(SessionContext sessionContext, File configurationFile) {
+		sessionCtx = sessionContext;
 		configFile = configurationFile;
 	}
 	
 	public static HgUpdateConfigCommand forRepository(HgRepository hgRepo) {
 		// XXX HgRepository to implement SessionContextProvider (with getContext())?
-		return new HgUpdateConfigCommand(new File(HgInternals.getRepositoryDir(hgRepo), "hgrc"));
+		return new HgUpdateConfigCommand(HgInternals.getContext(hgRepo), new File(HgInternals.getRepositoryDir(hgRepo), "hgrc"));
 	}
 	
 	public static HgUpdateConfigCommand forUser(SessionContext ctx) {
-		return new HgUpdateConfigCommand(Internals.getUserConfigurationFileToWrite(ctx));
+		return new HgUpdateConfigCommand(ctx, Internals.getUserConfigurationFileToWrite(ctx));
 	}
 	
 	public static HgUpdateConfigCommand forInstallation(SessionContext ctx) {
-		return new HgUpdateConfigCommand(Internals.getInstallationConfigurationFileToWrite(ctx));
+		return new HgUpdateConfigCommand(ctx, Internals.getInstallationConfigurationFileToWrite(ctx));
 	}
 	
 	/**
@@ -118,7 +121,7 @@
 	 */
 	public void execute() throws HgException {
 		try {
-			ConfigFile cfg = new ConfigFile();
+			ConfigFile cfg = new ConfigFile(sessionCtx);
 			cfg.addLocation(configFile);
 			if (toRemove != null) {
 				for (Map.Entry<String,List<String>> s : toRemove.entrySet()) {