Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/Internals.java @ 378:9fb990c8a724
Investigate approaches to alter Mercurial configuration files
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 09 Feb 2012 04:15:17 +0100 |
| parents | 5abba41751e6 |
| children | fa2be7a05af6 |
comparison
equal
deleted
inserted
replaced
| 377:86f049e6bcae | 378:9fb990c8a724 |
|---|---|
| 120 if (runningOnWindows()) { | 120 if (runningOnWindows()) { |
| 121 // FIXME read install-dir | 121 // FIXME read install-dir |
| 122 // | 122 // |
| 123 // XXX perhaps, makes sense to compare getenv(USERPROFILE) and getenv(HOME) and use | 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? | 124 // them if set (and use both if their values do not match). Only if both not set, rely to user.home? |
| 125 // Also respect #getUserConfigurationFileToWrite() below | |
| 125 configFile.addLocation(new File(System.getProperty("user.home"), "Mercurial.ini")); | 126 configFile.addLocation(new File(System.getProperty("user.home"), "Mercurial.ini")); |
| 126 } else { | 127 } else { |
| 127 // FIXME read from install-root | 128 // FIXME read from install-root |
| 128 // | 129 // |
| 129 File d = new File("/etc/mercurial/hgrc.d/"); | 130 File d = new File("/etc/mercurial/hgrc.d/"); |
| 141 // last one, overrides anything else | 142 // last one, overrides anything else |
| 142 // <repo>/.hg/hgrc | 143 // <repo>/.hg/hgrc |
| 143 configFile.addLocation(new File(repoRoot, "hgrc")); | 144 configFile.addLocation(new File(repoRoot, "hgrc")); |
| 144 return configFile; | 145 return configFile; |
| 145 } | 146 } |
| 147 | |
| 148 /** | |
| 149 * @return | |
| 150 */ | |
| 151 public static File getInstallationConfigurationFileToWrite() { | |
| 152 // TODO Auto-generated method stub | |
| 153 // FIXME find out install-root | |
| 154 throw new UnsupportedOperationException(); | |
| 155 } | |
| 156 | |
| 157 /** | |
| 158 * @return | |
| 159 */ | |
| 160 public static File getUserConfigurationFileToWrite() { | |
| 161 final File rv = new File(System.getProperty("user.home"), ".hgrc"); | |
| 162 if (rv.exists() && rv.canWrite()) { | |
| 163 return rv; | |
| 164 } | |
| 165 if (runningOnWindows()) { | |
| 166 // try another well-known location | |
| 167 // TODO comment above regarding USERPROFILE and HOME variables applies here as well | |
| 168 File f = new File(System.getProperty("user.home"), "Mercurial.ini"); | |
| 169 if (f.exists() && f.canWrite()) { | |
| 170 return f; | |
| 171 } | |
| 172 } | |
| 173 // fallback to default value | |
| 174 return rv; | |
| 175 } | |
| 146 } | 176 } |
