# HG changeset patch # User Artem Tikhomirov # Date 1366207570 -7200 # Node ID 36e36b92674770779c8f8db95d75c4197047be63 # Parent f97e81d131909c8bbc695b8b3b6bd6ea71539a0e Provide means to read user-specific configuration, with no specific repository selected diff -r f97e81d13190 -r 36e36b926747 src/org/tmatesoft/hg/internal/Internals.java --- a/src/org/tmatesoft/hg/internal/Internals.java Wed Apr 17 16:02:52 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/Internals.java Wed Apr 17 16:06:10 2013 +0200 @@ -293,10 +293,11 @@ } /** + * User-specific configuration, from system-wide and user home locations, without any repository-specific data. + * * @see http://www.selenic.com/mercurial/hgrc.5.html */ - public ConfigFile readConfiguration() throws IOException { - SessionContext sessionCtx = repo.getSessionContext(); + public static ConfigFile readConfiguration(SessionContext sessionCtx) throws IOException { ConfigFile configFile = new ConfigFile(sessionCtx); File hgInstallRoot = findHgInstallRoot(sessionCtx); // may be null // @@ -335,11 +336,21 @@ configFile.addLocation(new File("/etc/mercurial/hgrc")); configFile.addLocation(new File(System.getenv("HOME"), ".hgrc")); } + return configFile; + } + + /** + * Repository-specific configuration + * @see http://www.selenic.com/mercurial/hgrc.5.html + */ + public ConfigFile readConfiguration() throws IOException { + ConfigFile configFile = readConfiguration(repo.getSessionContext()); // last one, overrides anything else // /.hg/hgrc configFile.addLocation(getFileFromRepoDir("hgrc")); return configFile; } + private static List getWindowsConfigFilesPerInstall(File hgInstallDir) { File f = new File(hgInstallDir, "Mercurial.ini"); diff -r f97e81d13190 -r 36e36b926747 src/org/tmatesoft/hg/repo/HgRepoConfig.java --- a/src/org/tmatesoft/hg/repo/HgRepoConfig.java Wed Apr 17 16:02:52 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepoConfig.java Wed Apr 17 16:06:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012 TMate Software Ltd + * Copyright (c) 2011-2013 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,12 +26,17 @@ import org.tmatesoft.hg.util.Pair; /** - * Repository-specific configuration. + * Repository configuration. * + * @see http://www.selenic.com/mercurial/hgrc.5.html * @author Artem Tikhomirov * @author TMate Software Ltd. */ public final class HgRepoConfig /*implements RepoChangeListener, perhaps, also RepoChangeNotifier? */{ + // TODO [1.2+] The name HgRepoConfig is unfortunate, we could've used this class not only for + // repository configuration but system-wide/global configuration, or user configuration (without repo), too. + // Perhaps, rename and deprecate? + /*ease access for inner classes*/ final ConfigFile config; /*package-local*/HgRepoConfig(ConfigFile configFile) { diff -r f97e81d13190 -r 36e36b926747 src/org/tmatesoft/hg/repo/HgRepository.java --- a/src/org/tmatesoft/hg/repo/HgRepository.java Wed Apr 17 16:02:52 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Wed Apr 17 16:06:10 2013 +0200 @@ -324,6 +324,10 @@ } + /** + * Repository-specific configuration. + * @return access to configuration options, never null + */ public HgRepoConfig getConfiguration() /* XXX throws HgInvalidControlFileException? Description of the exception suggests it is only for files under ./hg/*/ { if (repoConfig == null) { try {