Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/Internals.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Sun, 03 Aug 2014 18:09:00 +0200 | 
| parents | a62079bc422b | 
| children | 
| rev | line source | 
|---|---|
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 1 /* | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 2 * Copyright (c) 2011-2013 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; | 
| 411 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 22 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 | 23 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 | 24 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 | 25 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 | 26 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 | 27 import java.util.LinkedHashSet; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 28 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 | 29 import java.util.StringTokenizer; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 30 | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
621diff
changeset | 31 import org.tmatesoft.hg.core.HgIOException; | 
| 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; | 
| 525 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 34 import org.tmatesoft.hg.repo.HgInternals; | 
| 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; | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 37 import org.tmatesoft.hg.repo.HgRepositoryFiles; | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 38 import org.tmatesoft.hg.repo.HgRepositoryLock; | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 39 import org.tmatesoft.hg.repo.HgRuntimeException; | 
| 610 
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
608diff
changeset | 40 import org.tmatesoft.hg.util.LogFacility; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 41 import org.tmatesoft.hg.util.Path; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 42 import org.tmatesoft.hg.util.PathRewrite; | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 43 | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 44 /** | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 45 * Fields/members that shall not be visible | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 46 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 47 * @author Artem Tikhomirov | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 48 * @author TMate Software Ltd. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 49 */ | 
| 501 
d2f6ab541330
Change the way extensions are accessed (with ExtensionsManager now), add preliminary Rebase extension support
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
493diff
changeset | 50 public final class Internals implements SessionContext.Source { | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 51 | 
| 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 * 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 | 54 * 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 | 55 */ | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 56 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 | 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 /** | 
| 
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 | 59 * 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 | 60 * 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 | 61 * (@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 | 62 */ | 
| 
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 | 63 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 | 64 | 
| 411 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 65 /** | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 66 * 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 | 67 * 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 | 68 * 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 | 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>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 | 71 * 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 | 72 * 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 | 73 * 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 | 74 * | 
| 
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
409diff
changeset | 75 * <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 | 76 * 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 | 77 * 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 | 78 */ | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 79 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 | 80 | 
| 504 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 81 /** | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 82 * Timeout, in seconds, to acquire filesystem {@link HgRepositoryLock lock}. | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 83 * | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 84 * Mercurial provides 'ui.timeout' in hgrc (defaults to 600 seconds) to specify how long | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 85 * it shall try to acquire a lock for storage or working directory prior to fail. | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 86 * | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 87 * This configuration property allows to override timeout value from Mercurial's configuration | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 88 * file and use Hg4J-specific value instead. | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 89 * | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 90 * Integer value, use negative for attempts to acquire lock until success, and zero to try once and fail immediately. | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 91 */ | 
| 
bf352ce2b97f
Allow to override lock timeout from within Hg4J
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
501diff
changeset | 92 public static final String CFG_PROPERTY_FS_LOCK_TIMEOUT = "hg4j.fs.lock.timeout"; | 
| 584 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 93 | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 94 /** | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 95 * Alternative, more effective approach to build revision text from revlog patches - collect all the | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 96 * patches one by one, starting at revision next to base, and apply against each other to get | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 97 * one final patch, which in turned is applied to base revision. | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 98 * <p> | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 99 * Original approach is to apply each patch to a previous revision, so that with base revision | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 100 * of 1M and three patches, each altering just a tiny fraction | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 101 * of the origin, with latter approach we consume 1M (original) + 1M (first patch applied) + 1M (second | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 102 * patch applied) + 1M (third patch applied). | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 103 * <p> | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 104 * Alternative approach, controlled with this option, first combines these there patches into one, | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 105 * and only then applies it to base revision, eliminating 2 intermediate elements. | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 106 * <p> | 
| 663 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 107 * Since 1.2, default value for this option is <em>TRUE</em>, (was <code>false</code> in <b>Hg4J 1.1</b>) | 
| 584 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 108 * | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 109 * @since 1.1 | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 110 */ | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 111 public static final String CFG_PROPERTY_PATCH_MERGE = "hg4j.repo.merge_revlog_patches"; | 
| 663 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 112 | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 113 /** | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 114 * Phases were introduced in Mercurial 2.1. Unless there's <code>phaseroots</code> file in the | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 115 * repository's storage area, <b>Hg4J</b> pretends phases are not enabled and doesn't update | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 116 * phase information on commit/push/pull. If, however, it's desired to keep phase information, | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 117 * this option may be set to <code>true</code>, and <code>phaseroots</code> file gets updated | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 118 * along with repository changes. | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 119 * | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 120 * <p>Default value: <code>false</code> | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 121 * @since 1.2 | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 122 */ | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 123 public static final String CFG_PROPERTY_CREATE_PHASEROOTS = "hg4j.repo.create_phaseroots"; | 
| 530 
0f6fa88e2162
Towards commit command: refactor clone, extract pieces to reuse. Describe a defect discovered when bundle has few patches with 0,0 parents
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
526diff
changeset | 124 | 
| 
0f6fa88e2162
Towards commit command: refactor clone, extract pieces to reuse. Describe a defect discovered when bundle has few patches with 0,0 parents
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
526diff
changeset | 125 public static final int REVLOGV1_RECORD_SIZE = 64; | 
| 
0f6fa88e2162
Towards commit command: refactor clone, extract pieces to reuse. Describe a defect discovered when bundle has few patches with 0,0 parents
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
526diff
changeset | 126 | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 127 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 | 128 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 | 129 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 | 130 private final boolean isCaseSensitiveFileSystem; | 
| 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 | 131 private final DataAccessProvider dataAccess; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 132 private final ImplAccess implAccess; | 
| 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 | 133 | 
| 
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 private final int requiresFlags; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 135 | 
| 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 | 136 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 | 137 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 | 138 | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 139 private final boolean shallMergePatches; | 
| 663 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 140 private final boolean shallWritePhaseroots; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 141 private final RevlogStreamFactory streamProvider; | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 142 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 143 public Internals(HgRepository hgRepo, File hgDir, ImplAccess implementationAccess) 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 | 144 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 | 145 repoDir = hgDir; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 146 implAccess = implementationAccess; | 
| 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 | 147 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 | 148 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 | 149 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 | 150 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 | 151 requiresFlags = repoInit.getRequires(); | 
| 501 
d2f6ab541330
Change the way extensions are accessed (with ExtensionsManager now), add preliminary Rebase extension support
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
493diff
changeset | 152 dataPathHelper = repoInit.buildDataFilesHelper(getSessionContext()); | 
| 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 | 153 repoPathHelper = repoInit.buildStoreFilesHelper(); | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 154 final PropertyMarshal pm = new PropertyMarshal(ctx); | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 155 boolean shallCacheRevlogsInRepo = pm.getBoolean(CFG_PROPERTY_REVLOG_STREAM_CACHE, true); | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 156 streamProvider = new RevlogStreamFactory(this, shallCacheRevlogsInRepo); | 
| 643 
a8ce405da1f5
v1.2 line of dev: update versions, use patch merge code by default
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
628diff
changeset | 157 shallMergePatches = pm.getBoolean(Internals.CFG_PROPERTY_PATCH_MERGE, true); | 
| 663 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 158 shallWritePhaseroots = pm.getBoolean(Internals.CFG_PROPERTY_CREATE_PHASEROOTS, false); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 159 } | 
| 295 
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
292diff
changeset | 160 | 
| 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 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 | 162 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 | 163 } | 
| 
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 | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 165 public File getRepositoryFile(HgRepositoryFiles f) { | 
| 647 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 166 switch (f.getHome()) { | 
| 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 167 case Store : return getFileFromStoreDir(f.getName()); | 
| 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 168 case Repo : return getFileFromRepoDir(f.getName()); | 
| 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 169 default : return new File(repo.getWorkingDir(), f.getName()); | 
| 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 170 } | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 171 } | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 172 | 
| 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 | 173 /** | 
| 
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 | 174 * Access files under ".hg/". | 
| 647 
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
643diff
changeset | 175 * File not necessarily exists, this method is merely a factory for {@link File files} at specific, configuration-dependent location. | 
| 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 | 176 * | 
| 
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 | 177 * @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 | 178 */ | 
| 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 | 179 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 | 180 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 | 181 } | 
| 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 | 182 | 
| 
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 | 183 /** | 
| 
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 | 184 * 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 | 185 * 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 | 186 * | 
| 
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 | 187 * @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 | 188 */ | 
| 
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 | 189 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 | 190 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 | 191 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 | 192 } | 
| 
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 | 193 | 
| 
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 | 194 /** | 
| 
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 | 195 * 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 | 196 * 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 | 197 * | 
| 
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 | 198 * @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 | 199 */ | 
| 
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 | 200 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 | 201 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 | 202 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 | 203 } | 
| 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 | 204 | 
| 501 
d2f6ab541330
Change the way extensions are accessed (with ExtensionsManager now), add preliminary Rebase extension support
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
493diff
changeset | 205 public SessionContext getSessionContext() { | 
| 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 | 206 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 | 207 } | 
| 
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 | 208 | 
| 610 
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
608diff
changeset | 209 public LogFacility getLog() { | 
| 
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
608diff
changeset | 210 return getSessionContext().getLog(); | 
| 
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
608diff
changeset | 211 } | 
| 
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
608diff
changeset | 212 | 
| 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 | 213 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 | 214 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 | 215 } | 
| 
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 | 216 | 
| 
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 | 217 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 | 218 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 | 219 } | 
| 
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 | 220 | 
| 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 | 221 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 | 222 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 | 223 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 | 224 } 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 | 225 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 | 226 } | 
| 
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 | 227 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 228 | 
| 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 | 229 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 | 230 if (filterFactories == null) { | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 231 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 | 232 ExtensionsSection cfg = repo.getConfiguration().getExtensions(); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 233 if (cfg.isEnabled("eol")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 234 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 | 235 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 236 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 237 } | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 238 if (cfg.isEnabled("keyword")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 239 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 | 240 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 241 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 242 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 243 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 244 return filterFactories; | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 245 } | 
| 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 | 246 | 
| 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 | 247 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 | 248 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 | 249 } | 
| 667 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 250 | 
| 559 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 251 public boolean fncacheInUse() { | 
| 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 252 return (getRequiresFlags() & RequiresFile.FNCACHE) != 0; | 
| 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 253 } | 
| 667 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 254 | 
| 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 255 public EncodingHelper buildFileNameEncodingHelper() { | 
| 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 256 return new EncodingHelper(getFileEncoding(getSessionContext()), repo); | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 257 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 258 | 
| 667 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 259 public static EncodingHelper buildFileNameEncodingHelper(SessionContext.Source ctx) { | 
| 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 260 return new EncodingHelper(getFileEncoding(ctx.getSessionContext()), ctx); | 
| 
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
663diff
changeset | 261 } | 
| 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 | 262 /*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 | 263 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 | 264 Charset cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 265 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 | 266 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 | 267 } else { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 268 try { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 269 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 | 270 } 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 | 271 // 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 | 272 // 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 | 273 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 | 274 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 | 275 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 276 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 277 return cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 278 } | 
| 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 | 279 | 
| 
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 | 280 /** | 
| 
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 | 281 * 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 | 282 * @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 | 283 */ | 
| 
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 | 284 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 | 285 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 | 286 } | 
| 
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 | 287 | 
| 539 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 288 public int getRequiresFlags() { | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 289 return requiresFlags; | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 290 } | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 291 | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 292 boolean shallMergePatches() { | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 293 return shallMergePatches; | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 294 } | 
| 663 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 295 | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 296 boolean shallCreatePhaseroots() { | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 297 return shallWritePhaseroots; | 
| 
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
647diff
changeset | 298 } | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 299 | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 300 RevlogChangeMonitor getRevlogTracker(File f) { | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 301 // TODO decide whether to use one monitor per multiple files or | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 302 // an instance per file; and let SessionContext pass alternative implementation) | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 303 return new RevlogChangeMonitor(f); | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 304 } | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 305 | 
| 292 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 306 public static boolean runningOnWindows() { | 
| 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 307 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 | 308 } | 
| 713 
661e77dc88ba
Mac support: respect Mac alternatives of command-line arguments for common unix tools
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
711diff
changeset | 309 public static boolean runningOnMac() { | 
| 
661e77dc88ba
Mac support: respect Mac alternatives of command-line arguments for common unix tools
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
711diff
changeset | 310 return System.getProperty("os.name").indexOf("Mac") != -1; | 
| 
661e77dc88ba
Mac support: respect Mac alternatives of command-line arguments for common unix tools
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
711diff
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 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 314 * @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 | 315 * 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 | 316 * @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 | 317 */ | 
| 
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 | 318 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 | 319 // *.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 | 320 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 | 321 } | 
| 
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 | 322 | 
| 
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 | 323 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 324 * @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 | 325 * 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 | 326 * @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 | 327 */ | 
| 
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 | 328 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 | 329 // 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 | 330 // 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 | 331 // 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 | 332 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 | 333 } | 
| 
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 | 334 | 
| 
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 | 335 | 
| 
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 | 336 /** | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 337 * 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 | 338 * 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 | 339 * @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 | 340 */ | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 341 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 | 342 // 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 | 343 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 | 344 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 | 345 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 | 346 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 347 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 | 348 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 | 349 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 | 350 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 | 351 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 | 352 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 | 353 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 | 354 // 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 | 355 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 | 356 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 357 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 358 return null; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 359 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 360 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 361 /** | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 362 * User-specific configuration, from system-wide and user home locations, without any repository-specific data. | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 363 * @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 | 364 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
621diff
changeset | 365 public static ConfigFile readConfiguration(SessionContext sessionCtx) throws HgIOException { | 
| 483 
e31e85cf4d4c
Handle include and unset directives in config files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
456diff
changeset | 366 ConfigFile configFile = new ConfigFile(sessionCtx); | 
| 
e31e85cf4d4c
Handle include and unset directives in config files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
456diff
changeset | 367 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 | 368 // | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 369 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 | 370 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 | 371 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 | 372 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 | 373 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 374 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 375 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 | 376 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 | 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 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 | 382 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 | 383 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 384 } else { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 385 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 | 386 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 | 387 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 | 388 for (File f : listConfigFiles(d)) { | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 389 configFile.addLocation(f); | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 390 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
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 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 | 393 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 394 // 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 | 395 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 | 396 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 | 397 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 | 398 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 | 399 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 400 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 401 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 | 402 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 | 403 } | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 404 return configFile; | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 405 } | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 406 | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 407 /** | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 408 * Repository-specific configuration | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 409 * @see http://www.selenic.com/mercurial/hgrc.5.html | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 410 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
621diff
changeset | 411 public ConfigFile readConfiguration() throws HgIOException { | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 412 ConfigFile configFile = readConfiguration(repo.getSessionContext()); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 413 // last one, overrides anything else | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 414 // <repo>/.hg/hgrc | 
| 711 
a62079bc422b
Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
705diff
changeset | 415 configFile.addLocation(getRepositoryFile(HgRepositoryFiles.RepoConfig)); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 416 return configFile; | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 417 } | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 418 | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 419 /*package-local*/ImplAccess getImplAccess() { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 420 return implAccess; | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 421 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 422 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 423 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 | 424 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 | 425 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 | 426 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 | 427 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 428 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 | 429 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 | 430 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 | 431 } | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 432 // TODO [post-1.1] 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 | 433 // 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 | 434 // | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 435 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 | 436 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 | 437 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 | 438 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 439 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 | 440 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 441 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 442 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 | 443 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 | 444 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 | 445 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 | 446 // 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 | 447 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 | 448 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 | 449 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 | 450 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 | 451 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 | 452 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 453 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 454 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 455 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 456 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 457 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 | 458 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 | 459 // 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 | 460 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 | 461 // 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 | 462 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 | 463 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 | 464 return cfg; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 465 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 466 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 467 // fallback | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 468 if (runningOnWindows()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 469 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 | 470 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 | 471 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 472 // 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 | 473 // 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 | 474 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 | 475 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 476 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 477 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 | 478 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 479 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 480 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 481 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 | 482 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 | 483 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 | 484 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 485 locations.add(System.getenv("USERPROFILE")); | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 486 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 487 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 | 488 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 | 489 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 | 490 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 | 491 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 | 492 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 | 493 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 494 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 495 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 496 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 | 497 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 | 498 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 499 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 500 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 501 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 502 // 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 | 503 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 | 504 } | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 505 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 506 public RevlogStream createManifestStream() { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 507 File manifestFile = getFileFromStoreDir("00manifest.i"); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 508 return streamProvider.create(manifestFile); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 509 } | 
| 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 | 510 | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 511 public RevlogStream createChangelogStream() { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 512 File chlogFile = getFileFromStoreDir("00changelog.i"); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 513 return streamProvider.create(chlogFile); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 514 } | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 515 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 516 public RevlogStream resolveStoreFile(Path path) { | 
| 621 
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
610diff
changeset | 517 return streamProvider.getStoreFile(path, false); | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 518 } | 
| 705 
b4242b7e7dfe
Merge command: implement conflict resolution alternatives
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
667diff
changeset | 519 | 
| 
b4242b7e7dfe
Merge command: implement conflict resolution alternatives
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
667diff
changeset | 520 public Transaction.Factory getTransactionFactory() { | 
| 
b4242b7e7dfe
Merge command: implement conflict resolution alternatives
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
667diff
changeset | 521 return new COWTransaction.Factory(); | 
| 
b4242b7e7dfe
Merge command: implement conflict resolution alternatives
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
667diff
changeset | 522 } | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 523 | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 524 // marker method | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 525 public static IllegalStateException notImplemented() { | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 526 return new IllegalStateException("Not implemented"); | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 527 } | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 528 | 
| 525 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 529 public static Internals getInstance(HgRepository repo) { | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 530 return HgInternals.getImplementationRepo(repo); | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 531 } | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 532 | 
| 407 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 533 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 | 534 if (col == null) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 535 return String.valueOf(col); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 536 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 537 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 | 538 if (!it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 539 return "[]"; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 540 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 541 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 | 542 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 | 543 while (it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 544 sb.append(separator); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 545 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 | 546 sb.append(v); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 547 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 548 return sb; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 549 } | 
| 420 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 550 | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 551 /** | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 552 * 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 | 553 * 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 | 554 * (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 | 555 */ | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 556 public static int ltoi(long l) { | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 557 int i = (int) l; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 558 assert ((long) i) == l : "Loss of data!"; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 559 return i; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 560 } | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 561 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 562 // access implementation details (fields, methods) of oth.repo package | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 563 public interface ImplAccess { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 564 public RevlogStream getStream(HgDataFile df); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 565 public RevlogStream getManifestStream(); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 566 public RevlogStream getChangelogStream(); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 567 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 568 } | 
