# HG changeset patch # User Artem Tikhomirov # Date 1322624390 -3600 # Node ID 5abba41751e65db91bbc45e7ae76123291b2a0a7 # Parent 33eaed1ad130257cfea0e01b5d2c9625924516ca Read extra predefined locations with mercurial configuration files diff -r 33eaed1ad130 -r 5abba41751e6 src/org/tmatesoft/hg/internal/Internals.java --- a/src/org/tmatesoft/hg/internal/Internals.java Tue Nov 29 03:46:17 2011 +0100 +++ b/src/org/tmatesoft/hg/internal/Internals.java Wed Nov 30 04:39:50 2011 +0100 @@ -117,7 +117,26 @@ public ConfigFile readConfiguration(HgRepository hgRepo, File repoRoot) throws IOException { ConfigFile configFile = new ConfigFile(); - // FIXME use Unix/Win location according to runningOnWindows + if (runningOnWindows()) { + // FIXME read install-dir + // + // XXX perhaps, makes sense to compare getenv(USERPROFILE) and getenv(HOME) and use + // them if set (and use both if their values do not match). Only if both not set, rely to user.home? + configFile.addLocation(new File(System.getProperty("user.home"), "Mercurial.ini")); + } else { + // FIXME read from install-root + // + File d = new File("/etc/mercurial/hgrc.d/"); + if (d.isDirectory()) { + for (File f : d.listFiles()) { + // XXX in fact, need to sort in alphabetical order + if (f.getName().endsWith(".rc")) { + configFile.addLocation(f); + } + } + } + configFile.addLocation(new File("/etc/mercurial/hgrc")); + } configFile.addLocation(new File(System.getProperty("user.home"), ".hgrc")); // last one, overrides anything else // /.hg/hgrc