Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/Internals.java @ 579:36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 16:06:10 +0200 |
parents | 6ca3d0c5b4bc |
children | ed243b668502 |
comparison
equal
deleted
inserted
replaced
578:f97e81d13190 | 579:36e36b926747 |
---|---|
291 } | 291 } |
292 return null; | 292 return null; |
293 } | 293 } |
294 | 294 |
295 /** | 295 /** |
296 * User-specific configuration, from system-wide and user home locations, without any repository-specific data. | |
297 * | |
296 * @see http://www.selenic.com/mercurial/hgrc.5.html | 298 * @see http://www.selenic.com/mercurial/hgrc.5.html |
297 */ | 299 */ |
298 public ConfigFile readConfiguration() throws IOException { | 300 public static ConfigFile readConfiguration(SessionContext sessionCtx) throws IOException { |
299 SessionContext sessionCtx = repo.getSessionContext(); | |
300 ConfigFile configFile = new ConfigFile(sessionCtx); | 301 ConfigFile configFile = new ConfigFile(sessionCtx); |
301 File hgInstallRoot = findHgInstallRoot(sessionCtx); // may be null | 302 File hgInstallRoot = findHgInstallRoot(sessionCtx); // may be null |
302 // | 303 // |
303 if (runningOnWindows()) { | 304 if (runningOnWindows()) { |
304 if (hgInstallRoot != null) { | 305 if (hgInstallRoot != null) { |
333 } | 334 } |
334 } | 335 } |
335 configFile.addLocation(new File("/etc/mercurial/hgrc")); | 336 configFile.addLocation(new File("/etc/mercurial/hgrc")); |
336 configFile.addLocation(new File(System.getenv("HOME"), ".hgrc")); | 337 configFile.addLocation(new File(System.getenv("HOME"), ".hgrc")); |
337 } | 338 } |
339 return configFile; | |
340 } | |
341 | |
342 /** | |
343 * Repository-specific configuration | |
344 * @see http://www.selenic.com/mercurial/hgrc.5.html | |
345 */ | |
346 public ConfigFile readConfiguration() throws IOException { | |
347 ConfigFile configFile = readConfiguration(repo.getSessionContext()); | |
338 // last one, overrides anything else | 348 // last one, overrides anything else |
339 // <repo>/.hg/hgrc | 349 // <repo>/.hg/hgrc |
340 configFile.addLocation(getFileFromRepoDir("hgrc")); | 350 configFile.addLocation(getFileFromRepoDir("hgrc")); |
341 return configFile; | 351 return configFile; |
342 } | 352 } |
353 | |
343 | 354 |
344 private static List<File> getWindowsConfigFilesPerInstall(File hgInstallDir) { | 355 private static List<File> getWindowsConfigFilesPerInstall(File hgInstallDir) { |
345 File f = new File(hgInstallDir, "Mercurial.ini"); | 356 File f = new File(hgInstallDir, "Mercurial.ini"); |
346 if (f.exists()) { | 357 if (f.exists()) { |
347 return Collections.singletonList(f); | 358 return Collections.singletonList(f); |