Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/Internals.java @ 631:8a5cdcb27b8f
AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Thu, 30 May 2013 15:24:17 +0200 | 
| parents | 6526d8adbc0f | 
| children | a8ce405da1f5 | 
| 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> | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 107 * Present default value for this option is <b>FALSE</b>, and will be changed in future, once | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 108 * tests prove support is fully functional (likely in v1.2). | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 109 * | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 110 * @since 1.1 | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 111 */ | 
| 
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
579diff
changeset | 112 public static final String CFG_PROPERTY_PATCH_MERGE = "hg4j.repo.merge_revlog_patches"; | 
| 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 | 113 | 
| 
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 | 114 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 | 115 | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 116 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 | 117 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 | 118 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 | 119 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 | 120 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 | 121 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 | 122 | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 123 private final int requiresFlags; | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 124 | 
| 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 | 125 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 | 126 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 | 127 | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 128 private final boolean shallMergePatches; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 129 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 | 130 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 131 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 | 132 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 | 133 repoDir = hgDir; | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 134 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 | 135 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 | 136 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 | 137 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 | 138 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 | 139 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 | 140 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 | 141 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 | 142 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 | 143 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 | 144 streamProvider = new RevlogStreamFactory(this, shallCacheRevlogsInRepo); | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 145 shallMergePatches = pm.getBoolean(Internals.CFG_PROPERTY_PATCH_MERGE, false); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 146 } | 
| 295 
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
292diff
changeset | 147 | 
| 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 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 | 149 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 | 150 } | 
| 
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 | 151 | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 152 public File getRepositoryFile(HgRepositoryFiles f) { | 
| 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 | 153 return f.residesUnderRepositoryRoot() ? getFileFromRepoDir(f.getName()) : new File(repo.getWorkingDir(), f.getName()); | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 154 } | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 155 | 
| 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 | 156 /** | 
| 
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 | 157 * Access files under ".hg/". | 
| 
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
490diff
changeset | 158 * 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 | 159 * | 
| 
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 | 160 * @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 | 161 */ | 
| 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 | 162 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 | 163 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 | 164 } | 
| 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 | 165 | 
| 
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 | 166 /** | 
| 
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 | 167 * 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 | 168 * 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 | 169 * | 
| 
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 | 170 * @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 | 171 */ | 
| 
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 | 172 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 | 173 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 | 174 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 | 175 } | 
| 
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 /** | 
| 
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 * 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 | 179 * 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 | 180 * | 
| 
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 | 181 * @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 | 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 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 | 184 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 | 185 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 | 186 } | 
| 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 | 187 | 
| 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 | 188 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 | 189 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 | 190 } | 
| 
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 | 191 | 
| 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 | 192 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 | 193 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 | 194 } | 
| 
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 | 195 | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 196 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 | 197 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 | 198 } | 
| 
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 | 199 | 
| 
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 | 200 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 | 201 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 | 202 } | 
| 
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 | 203 | 
| 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 | 204 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 | 205 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 | 206 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 | 207 } 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 | 208 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 | 209 } | 
| 
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 | 210 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 211 | 
| 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 | 212 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 | 213 if (filterFactories == null) { | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 214 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 | 215 ExtensionsSection cfg = repo.getConfiguration().getExtensions(); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 216 if (cfg.isEnabled("eol")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 217 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 | 218 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 219 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 220 } | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 221 if (cfg.isEnabled("keyword")) { | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 222 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 | 223 ff.initialize(repo); | 
| 114 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 224 filterFactories.add(ff); | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 225 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 226 } | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 227 return filterFactories; | 
| 
46291ec605a0
Filters to read and initialize according to configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 228 } | 
| 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 | 229 | 
| 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 | 230 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 | 231 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 | 232 } | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 233 | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 234 public EncodingHelper buildFileNameEncodingHelper() { | 
| 539 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 235 return new EncodingHelper(getFilenameEncoding(), repo.getSessionContext()); | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 236 } | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 237 | 
| 559 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 238 public boolean fncacheInUse() { | 
| 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 239 return (getRequiresFlags() & RequiresFile.FNCACHE) != 0; | 
| 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 240 } | 
| 
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
539diff
changeset | 241 | 
| 539 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 242 /*package-local*/ Charset getFilenameEncoding() { | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 243 return getFileEncoding(getSessionContext()); | 
| 412 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 244 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 245 | 
| 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 | 246 /*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 | 247 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 | 248 Charset cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 249 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 | 250 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 | 251 } else { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 252 try { | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 253 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 | 254 } 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 | 255 // 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 | 256 // 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 | 257 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 | 258 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 | 259 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 260 } | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 261 return cs; | 
| 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
411diff
changeset | 262 } | 
| 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 | 263 | 
| 
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 | 264 /** | 
| 
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 | 265 * 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 | 266 * @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 | 267 */ | 
| 
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 | 268 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 | 269 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 | 270 } | 
| 
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 | 271 | 
| 539 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 272 public int getRequiresFlags() { | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 273 return requiresFlags; | 
| 
9edfd5a223b8
Commit: handle empty repository case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
530diff
changeset | 274 } | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 275 | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 276 boolean shallMergePatches() { | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 277 return shallMergePatches; | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 278 } | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 279 | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 280 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 | 281 // 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 | 282 // 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 | 283 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 | 284 } | 
| 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 285 | 
| 292 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 286 public static boolean runningOnWindows() { | 
| 
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
202diff
changeset | 287 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 | 288 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 289 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 290 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 291 * @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 | 292 * 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 | 293 * @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 | 294 */ | 
| 
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 | 295 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 | 296 // *.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 | 297 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 | 298 } | 
| 
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 | 299 | 
| 
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 | 300 /** | 
| 419 
7f136a3fa671
Clean javadoc to fix obvious warnings
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
418diff
changeset | 301 * @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 | 302 * 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 | 303 * @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 | 304 */ | 
| 
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 | 305 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 | 306 // 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 | 307 // 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 | 308 // 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 | 309 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 | 310 } | 
| 
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 | 311 | 
| 
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 | 312 | 
| 
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 | 313 /** | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 314 * 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 | 315 * 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 | 316 * @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 | 317 */ | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 318 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 | 319 // 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 | 320 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 | 321 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 | 322 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 | 323 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 324 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 | 325 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 | 326 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 | 327 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 | 328 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 | 329 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 | 330 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 | 331 // 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 | 332 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 | 333 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 334 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 335 return null; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 336 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 337 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 338 /** | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 339 * 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 | 340 * @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 | 341 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
621diff
changeset | 342 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 | 343 ConfigFile configFile = new ConfigFile(sessionCtx); | 
| 
e31e85cf4d4c
Handle include and unset directives in config files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
456diff
changeset | 344 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 | 345 // | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 346 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 | 347 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 | 348 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 | 349 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 | 350 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 351 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 352 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 | 353 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 | 354 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 | 355 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 | 356 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 | 357 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 | 358 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 | 359 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 | 360 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 361 } else { | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 362 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 | 363 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 | 364 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 | 365 for (File f : listConfigFiles(d)) { | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 366 configFile.addLocation(f); | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 367 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 368 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 369 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 | 370 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 371 // 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 | 372 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 | 373 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 | 374 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 | 375 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 | 376 } | 
| 351 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 377 } | 
| 
5abba41751e6
Read extra predefined locations with mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
331diff
changeset | 378 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 | 379 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 | 380 } | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 381 return configFile; | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 382 } | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 383 | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 384 /** | 
| 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 385 * 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 | 386 * @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 | 387 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
621diff
changeset | 388 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 | 389 ConfigFile configFile = readConfiguration(repo.getSessionContext()); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 390 // last one, overrides anything else | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 391 // <repo>/.hg/hgrc | 
| 490 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
483diff
changeset | 392 configFile.addLocation(getFileFromRepoDir("hgrc")); | 
| 331 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 393 return configFile; | 
| 
a37ce7145c3f
Access to repository configuration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
295diff
changeset | 394 } | 
| 579 
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
559diff
changeset | 395 | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 396 /*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 | 397 return implAccess; | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 398 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 399 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 400 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 | 401 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 | 402 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 | 403 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 | 404 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 405 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 | 406 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 | 407 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 | 408 } | 
| 608 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
591diff
changeset | 409 // 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 | 410 // 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 | 411 // | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 412 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 | 413 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 | 414 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 | 415 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 416 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 | 417 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 418 | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 419 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 | 420 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 | 421 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 | 422 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 | 423 // 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 | 424 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 | 425 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 | 426 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 | 427 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 | 428 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 | 429 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 430 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 431 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 432 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 433 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 434 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 | 435 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 | 436 // 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 | 437 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 | 438 // 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 | 439 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 | 440 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 | 441 return cfg; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 442 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 443 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 444 // fallback | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 445 if (runningOnWindows()) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 446 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 | 447 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 | 448 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 449 // 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 | 450 // 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 | 451 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 | 452 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 453 } else { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 454 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 | 455 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 456 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 457 | 
| 382 
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
379diff
changeset | 458 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 | 459 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 | 460 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 | 461 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 462 locations.add(System.getenv("USERPROFILE")); | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 463 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 464 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 | 465 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 | 466 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 | 467 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 | 468 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 | 469 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 | 470 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 471 } | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 472 if (runsOnWindows) { | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 473 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 | 474 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 | 475 return rv; | 
| 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 476 } | 
| 378 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 477 } | 
| 
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
351diff
changeset | 478 } | 
| 379 
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
378diff
changeset | 479 // 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 | 480 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 | 481 } | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 482 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 483 public RevlogStream createManifestStream() { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 484 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 | 485 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 | 486 } | 
| 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 | 487 | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 488 public RevlogStream createChangelogStream() { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 489 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 | 490 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 | 491 } | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 492 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 493 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 | 494 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 | 495 } | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 496 | 
| 526 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 497 // marker method | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 498 public static IllegalStateException notImplemented() { | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 499 return new IllegalStateException("Not implemented"); | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 500 } | 
| 
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
525diff
changeset | 501 | 
| 525 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 502 public static Internals getInstance(HgRepository repo) { | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 503 return HgInternals.getImplementationRepo(repo); | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 504 } | 
| 
0be5be8d57e9
Repository checkout support, first iteration
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
504diff
changeset | 505 | 
| 407 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 506 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 | 507 if (col == null) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 508 return String.valueOf(col); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 509 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 510 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 | 511 if (!it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 512 return "[]"; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 513 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 514 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 | 515 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 | 516 while (it.hasNext()) { | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 517 sb.append(separator); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 518 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 | 519 sb.append(v); | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 520 } | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 521 return sb; | 
| 
30922c728341
Better multiline log printout; options to tune default log output
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
388diff
changeset | 522 } | 
| 420 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 523 | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 524 /** | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 525 * 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 | 526 * 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 | 527 * (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 | 528 */ | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 529 public static int ltoi(long l) { | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 530 int i = (int) l; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 531 assert ((long) i) == l : "Loss of data!"; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 532 return i; | 
| 
6c22bdc0bdfd
Respect long offsets in revlogs
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
419diff
changeset | 533 } | 
| 591 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 534 | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 535 // 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 | 536 public interface ImplAccess { | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 537 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 | 538 public RevlogStream getManifestStream(); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 539 public RevlogStream getChangelogStream(); | 
| 
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
584diff
changeset | 540 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 541 } | 
