Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/Internals.java @ 494:2743641f2f12
Defect: use of 0 as configuration value for mapio boundary results in every file being memmap-ed
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Thu, 18 Oct 2012 19:51:07 +0200 | 
| parents | ba36f66c32b4 | 
| children | d2f6ab541330 | 
| rev | line source | 
|---|---|
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 1 /* | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 2 * Copyright (c) 2011-2012 TMate Software Ltd | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 3 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 4 * This program is free software; you can redistribute it and/or modify | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 5 * it under the terms of the GNU General Public License as published by | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 6 * the Free Software Foundation; version 2 of the License. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 7 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 8 * This program is distributed in the hope that it will be useful, | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 11 * GNU General Public License for more details. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 12 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 13 * For information on how to redistribute this software under | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 14 * the terms of a license other than GNU General Public License | 
| 102 
a3a2e5deb320
Updated contact address to support@hg4j.com
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
83diff
changeset | 15 * contact TMate Software at support@hg4j.com | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 16 */ | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 17 package org.tmatesoft.hg.internal; | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 18 | 
| 456 
909306e412e2
Refactor LogFacility and SessionContext, better API for both
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 19 import static org.tmatesoft.hg.util.LogFacility.Severity.Error; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 20 | 
| 202 
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
150diff
changeset | 21 import java.io.File; | 
| 
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
150diff
changeset | 22 import java.io.IOException; | 
| 411 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 23 import java.nio.charset.Charset; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 24 import java.util.ArrayList; | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 25 import java.util.Arrays; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 26 import java.util.Collections; | 
| 407 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 27 import java.util.Iterator; | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 28 import java.util.LinkedHashSet; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 29 import java.util.List; | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 30 import java.util.StringTokenizer; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 31 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 32 import org.tmatesoft.hg.core.SessionContext; | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 33 import org.tmatesoft.hg.repo.HgDataFile; | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 34 import org.tmatesoft.hg.repo.HgRuntimeException; | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 35 import org.tmatesoft.hg.repo.HgRepoConfig.ExtensionsSection; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 36 import org.tmatesoft.hg.repo.HgRepository; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 37 import org.tmatesoft.hg.util.PathRewrite; | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 38 | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 39 /** | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 40 * Fields/members that shall not be visible | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 41 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 42 * @author Artem Tikhomirov | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 43 * @author TMate Software Ltd. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 44 */ | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 45 public final class Internals { | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 46 | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 47 /** | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 48 * Allows to specify Mercurial installation directory to detect installation-wide configurations. | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 49 * Without this property set, hg4j would attempt to deduce this value locating hg executable. | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 50 */ | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 51 public static final String CFG_PROPERTY_HG_INSTALL_ROOT = "hg4j.hg.install_root"; | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 52 | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 53 /** | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 54 * Tells repository not to cache files/revlogs | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 55 * XXX perhaps, need to respect this property not only for data files, but for manifest and changelog as well? | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 56 * (@see HgRepository#getChangelog and #getManifest()) | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 57 */ | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 58 public static final String CFG_PROPERTY_REVLOG_STREAM_CACHE = "hg4j.repo.disable_revlog_cache"; | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 59 | 
| 411 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 60 /** | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 61 * Name of charset to use when translating Unicode filenames to Mercurial storage paths, string, | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 62 * to resolve with {@link Charset#forName(String)}. | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 63 * E.g. <code>"cp1251"</code> or <code>"Latin-1"</code>. | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 64 * | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 65 * <p>Mercurial uses system encoding when mangling storage paths. Default value | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 66 * based on 'file.encoding' Java system property is usually fine here, however | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 67 * in certain scenarios it may be desirable to force a different one, and this | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 68 * property is exactly for this purpose. | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 69 * | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 70 * <p>E.g. Eclipse defaults to project encoding (Launch config, Common page) when launching an application, | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 71 * and if your project happen to use anything but filesystem default (say, UTF8 on cp1251 system), | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 72 * native storage paths won't match | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 73 */ | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 74 public static final String CFG_PROPERTY_FS_FILENAME_ENCODING = "hg.fs.filename.encoding"; | 
| 411 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 75 | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 76 private List<Filter.Factory> filterFactories; | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 77 private final HgRepository repo; | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 78 private final File repoDir; | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 79 private final boolean isCaseSensitiveFileSystem; | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 80 private final boolean shallCacheRevlogsInRepo; | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 81 private final DataAccessProvider dataAccess; | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 82 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 83 @SuppressWarnings("unused") | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 84 private final int requiresFlags; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 85 | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 86 private final PathRewrite dataPathHelper; // access to file storage area (usually under .hg/store/data/), with filenames mangled | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 87 private final PathRewrite repoPathHelper; // access to system files (under .hg/store if requires has 'store' flag) | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 88 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 89 public Internals(HgRepository hgRepo, File hgDir) throws HgRuntimeException { | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 90 repo = hgRepo; | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 91 repoDir = hgDir; | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 92 isCaseSensitiveFileSystem = !runningOnWindows(); | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 93 SessionContext ctx = repo.getSessionContext(); | 
| 456 
909306e412e2
Refactor LogFacility and SessionContext, better API for both
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 94 shallCacheRevlogsInRepo = new PropertyMarshal(ctx).getBoolean(CFG_PROPERTY_REVLOG_STREAM_CACHE, true); | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 95 dataAccess = new DataAccessProvider(ctx); | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 96 RepoInitializer repoInit = new RepoInitializer().initRequiresFromFile(repoDir); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 97 requiresFlags = repoInit.getRequires(); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 98 dataPathHelper = repoInit.buildDataFilesHelper(getContext()); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 99 repoPathHelper = repoInit.buildStoreFilesHelper(); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 100 } | 
| 295 
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
292diff
changeset | 101 | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 102 public boolean isInvalid() { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 103 return !repoDir.exists() || !repoDir.isDirectory(); | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 104 } | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 105 | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 106 /** | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 107 * Access files under ".hg/". | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 108 * File not necessarily exists, this method is merely a factory for Files at specific, configuration-dependent location. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 109 * | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 110 * @param name shall be normalized path | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 111 */ | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 112 public File getFileFromRepoDir(String name) { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 113 return new File(repoDir, name); | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 114 } | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 115 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 116 /** | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 117 * Access files under ".hg/store/" or ".hg/" depending on use of 'store' in requires. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 118 * File not necessarily exists, this method is merely a factory for Files at specific, configuration-dependent location. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 119 * | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 120 * @param name shall be normalized path | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 121 */ | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 122 public File getFileFromStoreDir(String name) { | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 123 CharSequence location = repoPathHelper.rewrite(name); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 124 return new File(repoDir, location.toString()); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 125 } | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 126 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 127 /** | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 128 * Access files under ".hg/store/data", ".hg/store/dh/" or ".hg/data" according to settings in requires file. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 129 * File not necessarily exists, this method is merely a factory for Files at specific, configuration-dependent location. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 130 * | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 131 * @param name shall be normalized path, without .i or .d suffixes | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 132 */ | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 133 public File getFileFromDataDir(CharSequence path) { | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 134 CharSequence storagePath = dataPathHelper.rewrite(path); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 135 return new File(repoDir, storagePath.toString()); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 136 } | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 137 | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 138 public SessionContext getContext() { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 139 return repo.getSessionContext(); | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 140 } | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 141 | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 142 public HgRepository getRepo() { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 143 return repo; | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 144 } | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 145 | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 146 public DataAccessProvider getDataAccess() { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 147 return dataAccess; | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 148 } | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 149 | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 150 public PathRewrite buildNormalizePathRewrite() { | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 151 if (runningOnWindows()) { | 
| 409 
0f5696623512
Support glob path pattern rewrite to facilitate use of globs with Windows path separator
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
407diff
changeset | 152 return new WinToNixPathRewrite(); | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 153 } else { | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 154 return new PathRewrite.Empty(); // or strip leading slash, perhaps? | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 155 } | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 156 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 157 | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 158 public List<Filter.Factory> getFilters() { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 159 if (filterFactories == null) { | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 160 filterFactories = new ArrayList<Filter.Factory>(); | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 161 ExtensionsSection cfg = repo.getConfiguration().getExtensions(); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 162 if (cfg.isEnabled("eol")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 163 NewlineFilter.Factory ff = new NewlineFilter.Factory(); | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 164 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 165 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 166 } | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 167 if (cfg.isEnabled("keyword")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 168 KeywordFilter.Factory ff = new KeywordFilter.Factory(); | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 169 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 170 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 171 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 172 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 173 return filterFactories; | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 174 } | 
| 202 
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
150diff
changeset | 175 | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 176 public boolean isCaseSensitiveFileSystem() { | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 177 return isCaseSensitiveFileSystem; | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 178 } | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 179 | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 180 public EncodingHelper buildFileNameEncodingHelper() { | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 181 SessionContext ctx = repo.getSessionContext(); | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 182 return new EncodingHelper(getFileEncoding(ctx), ctx); | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 183 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 184 | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 185 /*package-local*/ static Charset getFileEncoding(SessionContext ctx) { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 186 Object altEncoding = ctx.getConfigurationProperty(CFG_PROPERTY_FS_FILENAME_ENCODING, null); | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 187 Charset cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 188 if (altEncoding == null) { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 189 cs = Charset.defaultCharset(); | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 190 } else { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 191 try { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 192 cs = Charset.forName(altEncoding.toString()); | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 193 } catch (IllegalArgumentException ex) { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 194 // both IllegalCharsetNameException and UnsupportedCharsetException are subclasses of IAE, too | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 195 // not severe enough to throw an exception, imo. Just record the fact it's bad ad we ignore it | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 196 ctx.getLog().dump(Internals.class, Error, ex, String.format("Bad configuration value for filename encoding %s", altEncoding)); | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 197 cs = Charset.defaultCharset(); | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 198 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 199 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 200 return cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 201 } | 
| 493 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 202 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 203 /** | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 204 * Access to mangled name of a file in repository storage, may come handy for debug. | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 205 * @return mangled path of the repository file | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 206 */ | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 207 public CharSequence getStoragePath(HgDataFile df) { | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 208 return dataPathHelper.rewrite(df.getPath().toString()); | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 209 } | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 210 | 
| 202 
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
150diff
changeset | 211 | 
| 292 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 212 public static boolean runningOnWindows() { | 
| 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 213 return System.getProperty("os.name").indexOf("Windows") != -1; | 
| 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 214 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 215 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 216 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 217 * @param fsHint optional hint pointing to filesystem of interest (generally, it's possible to mount | 
| 413 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 218 * filesystems with different capabilities and repository's capabilities would depend on which fs it resides) | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 219 * @return <code>true</code> if executable files deserve tailored handling | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 220 */ | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 221 public static boolean checkSupportsExecutables(File fsHint) { | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 222 // *.exe are not executables for Mercurial | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 223 return !runningOnWindows(); | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 224 } | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 225 | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 226 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 227 * @param fsHint optional hint pointing to filesystem of interest (generally, it's possible to mount | 
| 413 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 228 * filesystems with different capabilities and repository's capabilities would depend on which fs it resides) | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 229 * @return <code>true</code> if filesystem knows what symbolic links are | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 230 */ | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 231 public static boolean checkSupportsSymlinks(File fsHint) { | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 232 // Windows supports soft symbolic links starting from Vista | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 233 // However, as of Mercurial 2.1.1, no support for this functionality | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 234 // XXX perhaps, makes sense to override with a property a) to speed up when no links are in use b) investigate how this runs windows | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 235 return !runningOnWindows(); | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 236 } | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 237 | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 238 | 
| 
7f27122011c3
Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 239 /** | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 240 * For Unix, returns installation root, which is the parent directory of the hg executable (or symlink) being run. | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 241 * For Windows, it's Mercurial installation directory itself | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 242 * @param ctx | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 243 */ | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 244 private static File findHgInstallRoot(SessionContext ctx) { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 245 // let clients to override Hg install location | 
| 456 
909306e412e2
Refactor LogFacility and SessionContext, better API for both
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 246 String p = (String) ctx.getConfigurationProperty(CFG_PROPERTY_HG_INSTALL_ROOT, null); | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 247 if (p != null) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 248 return new File(p); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 249 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 250 StringTokenizer st = new StringTokenizer(System.getenv("PATH"), System.getProperty("path.separator"), false); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 251 final boolean runsOnWin = runningOnWindows(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 252 while (st.hasMoreTokens()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 253 String pe = st.nextToken(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 254 File execCandidate = new File(pe, runsOnWin ? "hg.exe" : "hg"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 255 if (execCandidate.exists() && execCandidate.isFile()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 256 File execDir = execCandidate.getParentFile(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 257 // e.g. on Unix runs "/shared/tools/bin/hg", directory of interest is "/shared/tools/" | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 258 return runsOnWin ? execDir : execDir.getParentFile(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 259 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 260 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 261 return null; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 262 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 263 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 264 /** | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 265 * @see http://www.selenic.com/mercurial/hgrc.5.html | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 266 */ | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 267 public ConfigFile readConfiguration() throws IOException { | 
| 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 268 SessionContext sessionCtx = repo.getSessionContext(); | 
| 483 
e31e85cf4d4c
Handle include and unset directives in config files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
456diff
changeset | 269 ConfigFile configFile = new ConfigFile(sessionCtx); | 
| 
e31e85cf4d4c
Handle include and unset directives in config files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
456diff
changeset | 270 File hgInstallRoot = findHgInstallRoot(sessionCtx); // may be null | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 271 // | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 272 if (runningOnWindows()) { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 273 if (hgInstallRoot != null) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 274 for (File f : getWindowsConfigFilesPerInstall(hgInstallRoot)) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 275 configFile.addLocation(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 276 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 277 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 278 LinkedHashSet<String> locations = new LinkedHashSet<String>(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 279 locations.add(System.getenv("USERPROFILE")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 280 locations.add(System.getenv("HOME")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 281 locations.remove(null); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 282 for (String loc : locations) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 283 File location = new File(loc); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 284 configFile.addLocation(new File(location, "Mercurial.ini")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 285 configFile.addLocation(new File(location, ".hgrc")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 286 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 287 } else { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 288 if (hgInstallRoot != null) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 289 File d = new File(hgInstallRoot, "etc/mercurial/hgrc.d/"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 290 if (d.isDirectory() && d.canRead()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 291 for (File f : listConfigFiles(d)) { | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 292 configFile.addLocation(f); | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 293 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 294 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 295 configFile.addLocation(new File(hgInstallRoot, "etc/mercurial/hgrc")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 296 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 297 // same, but with absolute paths | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 298 File d = new File("/etc/mercurial/hgrc.d/"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 299 if (d.isDirectory() && d.canRead()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 300 for (File f : listConfigFiles(d)) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 301 configFile.addLocation(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 302 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 303 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 304 configFile.addLocation(new File("/etc/mercurial/hgrc")); | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 305 configFile.addLocation(new File(System.getenv("HOME"), ".hgrc")); | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 306 } | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 307 // last one, overrides anything else | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 308 // <repo>/.hg/hgrc | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 309 configFile.addLocation(getFileFromRepoDir("hgrc")); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 310 return configFile; | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 311 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 312 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 313 private static List<File> getWindowsConfigFilesPerInstall(File hgInstallDir) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 314 File f = new File(hgInstallDir, "Mercurial.ini"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 315 if (f.exists()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 316 return Collections.singletonList(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 317 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 318 f = new File(hgInstallDir, "hgrc.d/"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 319 if (f.canRead() && f.isDirectory()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 320 return listConfigFiles(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 321 } | 
| 418 
528b6780a8bd
A bit of FIXME cleanup (mostly degraded to TODO post 1.0), comments and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
415diff
changeset | 322 // TODO post-1.0 query registry, e.g. with | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 323 // Runtime.exec("reg query HKLM\Software\Mercurial") | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 324 // | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 325 f = new File("C:\\Mercurial\\Mercurial.ini"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 326 if (f.exists()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 327 return Collections.singletonList(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 328 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 329 return Collections.emptyList(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 330 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 331 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 332 private static List<File> listConfigFiles(File dir) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 333 assert dir.canRead(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 334 assert dir.isDirectory(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 335 final File[] allFiles = dir.listFiles(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 336 // File is Comparable, lexicographically by default | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 337 Arrays.sort(allFiles); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 338 ArrayList<File> rv = new ArrayList<File>(allFiles.length); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 339 for (File f : allFiles) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 340 if (f.getName().endsWith(".rc")) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 341 rv.add(f); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 342 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 343 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 344 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 345 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 346 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 347 public static File getInstallationConfigurationFileToWrite(SessionContext ctx) { | 
| 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 348 File hgInstallRoot = findHgInstallRoot(ctx); // may be null | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 349 // choice of which hgrc to pick here is according to my own pure discretion | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 350 if (hgInstallRoot != null) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 351 // use this location only if it's writable | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 352 File cfg = new File(hgInstallRoot, runningOnWindows() ? "Mercurial.ini" : "etc/mercurial/hgrc"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 353 if (cfg.canWrite() || cfg.getParentFile().canWrite()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 354 return cfg; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 355 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 356 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 357 // fallback | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 358 if (runningOnWindows()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 359 if (hgInstallRoot == null) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 360 return new File("C:\\Mercurial\\Mercurial.ini"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 361 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 362 // yes, we tried this file already (above) and found it non-writable | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 363 // let caller fail with can't write | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 364 return new File(hgInstallRoot, "Mercurial.ini"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 365 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 366 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 367 return new File("/etc/mercurial/hgrc"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 368 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 369 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 370 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 371 public static File getUserConfigurationFileToWrite(SessionContext ctx) { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 372 LinkedHashSet<String> locations = new LinkedHashSet<String>(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 373 final boolean runsOnWindows = runningOnWindows(); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 374 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 375 locations.add(System.getenv("USERPROFILE")); | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 376 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 377 locations.add(System.getenv("HOME")); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 378 locations.remove(null); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 379 for (String loc : locations) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 380 File location = new File(loc); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 381 File rv = new File(location, ".hgrc"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 382 if (rv.exists() && rv.canWrite()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 383 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 384 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 385 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 386 rv = new File(location, "Mercurial.ini"); | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 387 if (rv.exists() && rv.canWrite()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 388 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 389 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 390 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 391 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 392 // fallback to default, let calling code fail with Exception if can't write | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 393 return new File(System.getProperty("user.home"), ".hgrc"); | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 394 } | 
| 388 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 395 | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 396 public boolean shallCacheRevlogs() { | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 397 return shallCacheRevlogsInRepo; | 
| 
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
382diff
changeset | 398 } | 
| 407 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 399 | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 400 public static <T> CharSequence join(Iterable<T> col, CharSequence separator) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 401 if (col == null) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 402 return String.valueOf(col); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 403 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 404 Iterator<T> it = col.iterator(); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 405 if (!it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 406 return "[]"; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 407 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 408 String v = String.valueOf(it.next()); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 409 StringBuilder sb = new StringBuilder(v); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 410 while (it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 411 sb.append(separator); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 412 v = String.valueOf(it.next()); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 413 sb.append(v); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 414 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 415 return sb; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 416 } | 
| 420 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 417 | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 418 /** | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 419 * keep an eye on all long to int downcasts to get a chance notice the lost of data | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 420 * Use if there's even subtle chance there might be loss | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 421 * (ok not to use if there's no way for l to be greater than int) | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 422 */ | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 423 public static int ltoi(long l) { | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 424 int i = (int) l; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 425 assert ((long) i) == l : "Loss of data!"; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 426 return i; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 427 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 428 } | 
