Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/Internals.java @ 351:5abba41751e6
Read extra predefined locations with mercurial configuration files
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 30 Nov 2011 04:39:50 +0100 |
parents | a37ce7145c3f |
children | 9fb990c8a724 |
comparison
equal
deleted
inserted
replaced
350:33eaed1ad130 | 351:5abba41751e6 |
---|---|
115 return System.getProperty("os.name").indexOf("Windows") != -1; | 115 return System.getProperty("os.name").indexOf("Windows") != -1; |
116 } | 116 } |
117 | 117 |
118 public ConfigFile readConfiguration(HgRepository hgRepo, File repoRoot) throws IOException { | 118 public ConfigFile readConfiguration(HgRepository hgRepo, File repoRoot) throws IOException { |
119 ConfigFile configFile = new ConfigFile(); | 119 ConfigFile configFile = new ConfigFile(); |
120 // FIXME use Unix/Win location according to runningOnWindows | 120 if (runningOnWindows()) { |
121 // FIXME read install-dir | |
122 // | |
123 // XXX perhaps, makes sense to compare getenv(USERPROFILE) and getenv(HOME) and use | |
124 // them if set (and use both if their values do not match). Only if both not set, rely to user.home? | |
125 configFile.addLocation(new File(System.getProperty("user.home"), "Mercurial.ini")); | |
126 } else { | |
127 // FIXME read from install-root | |
128 // | |
129 File d = new File("/etc/mercurial/hgrc.d/"); | |
130 if (d.isDirectory()) { | |
131 for (File f : d.listFiles()) { | |
132 // XXX in fact, need to sort in alphabetical order | |
133 if (f.getName().endsWith(".rc")) { | |
134 configFile.addLocation(f); | |
135 } | |
136 } | |
137 } | |
138 configFile.addLocation(new File("/etc/mercurial/hgrc")); | |
139 } | |
121 configFile.addLocation(new File(System.getProperty("user.home"), ".hgrc")); | 140 configFile.addLocation(new File(System.getProperty("user.home"), ".hgrc")); |
122 // last one, overrides anything else | 141 // last one, overrides anything else |
123 // <repo>/.hg/hgrc | 142 // <repo>/.hg/hgrc |
124 configFile.addLocation(new File(repoRoot, "hgrc")); | 143 configFile.addLocation(new File(repoRoot, "hgrc")); |
125 return configFile; | 144 return configFile; |