Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/Internals.java @ 617:65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 15 May 2013 20:10:09 +0200 |
parents | 5c68567b3645 |
children | 99ad1e3a4e4d |
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:
525
diff
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:
83
diff
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:
425
diff
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:
150
diff
changeset
|
21 import java.io.File; |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
150
diff
changeset
|
22 import java.io.IOException; |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
409
diff
changeset
|
23 import java.nio.charset.Charset; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
24 import java.util.ArrayList; |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
25 import java.util.Arrays; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
26 import java.util.Collections; |
407
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
27 import java.util.Iterator; |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
28 import java.util.LinkedHashSet; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
29 import java.util.List; |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
30 import java.util.StringTokenizer; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
31 |
382
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
379
diff
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:
490
diff
changeset
|
33 import org.tmatesoft.hg.repo.HgDataFile; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
504
diff
changeset
|
34 import org.tmatesoft.hg.repo.HgInternals; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
35 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
36 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:
102
diff
changeset
|
37 import org.tmatesoft.hg.repo.HgRepository; |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
38 import org.tmatesoft.hg.repo.HgRepositoryFiles; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
39 import org.tmatesoft.hg.repo.HgRepositoryLock; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
40 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:
608
diff
changeset
|
41 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:
584
diff
changeset
|
42 import org.tmatesoft.hg.util.Path; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 import org.tmatesoft.hg.util.PathRewrite; |
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 /** |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 * Fields/members that shall not be visible |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 * @author TMate Software Ltd. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 */ |
501
d2f6ab541330
Change the way extensions are accessed (with ExtensionsManager now), add preliminary Rebase extension support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
51 public final class Internals implements SessionContext.Source { |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 |
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:
382
diff
changeset
|
53 /** |
b015f3918120
Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
382
diff
changeset
|
54 * 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:
382
diff
changeset
|
55 * 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:
382
diff
changeset
|
56 */ |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
57 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:
382
diff
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:
382
diff
changeset
|
59 /** |
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:
382
diff
changeset
|
60 * 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:
382
diff
changeset
|
61 * 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:
382
diff
changeset
|
62 * (@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:
382
diff
changeset
|
63 */ |
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:
382
diff
changeset
|
64 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:
378
diff
changeset
|
65 |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
409
diff
changeset
|
66 /** |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
409
diff
changeset
|
67 * 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:
409
diff
changeset
|
68 * 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:
409
diff
changeset
|
69 * 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:
409
diff
changeset
|
70 * |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
409
diff
changeset
|
71 * <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:
409
diff
changeset
|
72 * 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:
409
diff
changeset
|
73 * 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:
409
diff
changeset
|
74 * 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:
409
diff
changeset
|
75 * |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
409
diff
changeset
|
76 * <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:
409
diff
changeset
|
77 * 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:
409
diff
changeset
|
78 * 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:
409
diff
changeset
|
79 */ |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
80 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:
409
diff
changeset
|
81 |
504
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
82 /** |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
83 * 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:
501
diff
changeset
|
84 * |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
85 * 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:
501
diff
changeset
|
86 * 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:
501
diff
changeset
|
87 * |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
88 * 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:
501
diff
changeset
|
89 * file and use Hg4J-specific value instead. |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
90 * |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
91 * 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:
501
diff
changeset
|
92 */ |
bf352ce2b97f
Allow to override lock timeout from within Hg4J
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
93 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:
579
diff
changeset
|
94 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
95 /** |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
96 * 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:
579
diff
changeset
|
97 * 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:
579
diff
changeset
|
98 * 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:
579
diff
changeset
|
99 * <p> |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
100 * 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:
579
diff
changeset
|
101 * 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:
579
diff
changeset
|
102 * 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:
579
diff
changeset
|
103 * patch applied) + 1M (third patch applied). |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
104 * <p> |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
105 * 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:
579
diff
changeset
|
106 * 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:
579
diff
changeset
|
107 * <p> |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
108 * 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:
579
diff
changeset
|
109 * 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:
579
diff
changeset
|
110 * |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
111 * @since 1.1 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
112 */ |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
579
diff
changeset
|
113 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:
526
diff
changeset
|
114 |
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:
526
diff
changeset
|
115 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:
526
diff
changeset
|
116 |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
117 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:
483
diff
changeset
|
118 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:
483
diff
changeset
|
119 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:
382
diff
changeset
|
120 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:
483
diff
changeset
|
121 private final DataAccessProvider dataAccess; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
122 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:
490
diff
changeset
|
123 |
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:
490
diff
changeset
|
124 private final int requiresFlags; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
125 |
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:
490
diff
changeset
|
126 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:
490
diff
changeset
|
127 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:
490
diff
changeset
|
128 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
129 private final boolean shallMergePatches; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
130 private final RevlogStreamFactory streamProvider; |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
131 |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
132 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:
483
diff
changeset
|
133 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:
483
diff
changeset
|
134 repoDir = hgDir; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
135 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:
382
diff
changeset
|
136 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:
483
diff
changeset
|
137 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:
483
diff
changeset
|
138 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:
490
diff
changeset
|
139 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:
490
diff
changeset
|
140 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:
493
diff
changeset
|
141 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:
490
diff
changeset
|
142 repoPathHelper = repoInit.buildStoreFilesHelper(); |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
143 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:
591
diff
changeset
|
144 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:
584
diff
changeset
|
145 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:
591
diff
changeset
|
146 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:
102
diff
changeset
|
147 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
148 |
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:
483
diff
changeset
|
149 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:
483
diff
changeset
|
150 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:
483
diff
changeset
|
151 } |
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:
483
diff
changeset
|
152 |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
153 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:
608
diff
changeset
|
154 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:
525
diff
changeset
|
155 } |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
156 |
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:
490
diff
changeset
|
157 /** |
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:
490
diff
changeset
|
158 * 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:
490
diff
changeset
|
159 * 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:
490
diff
changeset
|
160 * |
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:
490
diff
changeset
|
161 * @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:
490
diff
changeset
|
162 */ |
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:
483
diff
changeset
|
163 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:
483
diff
changeset
|
164 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:
483
diff
changeset
|
165 } |
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:
490
diff
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:
490
diff
changeset
|
167 /** |
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:
490
diff
changeset
|
168 * 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:
490
diff
changeset
|
169 * 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:
490
diff
changeset
|
170 * |
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:
490
diff
changeset
|
171 * @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:
490
diff
changeset
|
172 */ |
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:
490
diff
changeset
|
173 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:
490
diff
changeset
|
174 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:
490
diff
changeset
|
175 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:
490
diff
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:
490
diff
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:
490
diff
changeset
|
178 /** |
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:
490
diff
changeset
|
179 * 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:
490
diff
changeset
|
180 * 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:
490
diff
changeset
|
181 * |
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:
490
diff
changeset
|
182 * @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:
490
diff
changeset
|
183 */ |
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
184 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:
490
diff
changeset
|
185 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:
490
diff
changeset
|
186 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:
490
diff
changeset
|
187 } |
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:
483
diff
changeset
|
188 |
501
d2f6ab541330
Change the way extensions are accessed (with ExtensionsManager now), add preliminary Rebase extension support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
189 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:
483
diff
changeset
|
190 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:
483
diff
changeset
|
191 } |
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:
483
diff
changeset
|
192 |
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:
608
diff
changeset
|
193 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:
608
diff
changeset
|
194 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:
608
diff
changeset
|
195 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
196 |
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:
483
diff
changeset
|
197 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:
483
diff
changeset
|
198 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:
483
diff
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:
483
diff
changeset
|
200 |
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:
483
diff
changeset
|
201 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:
483
diff
changeset
|
202 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:
483
diff
changeset
|
203 } |
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:
483
diff
changeset
|
204 |
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:
382
diff
changeset
|
205 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:
382
diff
changeset
|
206 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:
407
diff
changeset
|
207 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:
382
diff
changeset
|
208 } 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:
382
diff
changeset
|
209 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:
382
diff
changeset
|
210 } |
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:
382
diff
changeset
|
211 } |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
212 |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
483
diff
changeset
|
213 public List<Filter.Factory> getFilters() { |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
214 if (filterFactories == null) { |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
215 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:
483
diff
changeset
|
216 ExtensionsSection cfg = repo.getConfiguration().getExtensions(); |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
217 if (cfg.isEnabled("eol")) { |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
218 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:
483
diff
changeset
|
219 ff.initialize(repo); |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
220 filterFactories.add(ff); |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
221 } |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
222 if (cfg.isEnabled("keyword")) { |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
223 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:
483
diff
changeset
|
224 ff.initialize(repo); |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
225 filterFactories.add(ff); |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
226 } |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
227 } |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
228 return filterFactories; |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
229 } |
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:
150
diff
changeset
|
230 |
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:
382
diff
changeset
|
231 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:
382
diff
changeset
|
232 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:
382
diff
changeset
|
233 } |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
234 |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
235 public EncodingHelper buildFileNameEncodingHelper() { |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
236 return new EncodingHelper(getFilenameEncoding(), repo.getSessionContext()); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
237 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
238 |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
239 public boolean fncacheInUse() { |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
240 return (getRequiresFlags() & RequiresFile.FNCACHE) != 0; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
241 } |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
242 |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
243 /*package-local*/ Charset getFilenameEncoding() { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
244 return getFileEncoding(getSessionContext()); |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
245 } |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
246 |
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:
483
diff
changeset
|
247 /*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:
483
diff
changeset
|
248 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:
411
diff
changeset
|
249 Charset cs; |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
250 if (altEncoding == null) { |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
251 cs = Charset.defaultCharset(); |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
252 } else { |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
253 try { |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
254 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:
411
diff
changeset
|
255 } catch (IllegalArgumentException ex) { |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
256 // 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:
411
diff
changeset
|
257 // 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:
483
diff
changeset
|
258 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:
411
diff
changeset
|
259 cs = Charset.defaultCharset(); |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
260 } |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
261 } |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
262 return cs; |
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
263 } |
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:
490
diff
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:
490
diff
changeset
|
265 /** |
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:
490
diff
changeset
|
266 * 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:
490
diff
changeset
|
267 * @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:
490
diff
changeset
|
268 */ |
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:
490
diff
changeset
|
269 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:
490
diff
changeset
|
270 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:
490
diff
changeset
|
271 } |
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:
490
diff
changeset
|
272 |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
273 public int getRequiresFlags() { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
274 return requiresFlags; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
275 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
276 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
277 boolean shallMergePatches() { |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
278 return shallMergePatches; |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
279 } |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
280 |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
281 RevlogChangeMonitor getRevlogTracker(File f) { |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
282 // 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:
591
diff
changeset
|
283 // 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:
591
diff
changeset
|
284 return new RevlogChangeMonitor(f); |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
285 } |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
286 |
292
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
287 public static boolean runningOnWindows() { |
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
288 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:
202
diff
changeset
|
289 } |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
290 |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
291 /** |
419
7f136a3fa671
Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
418
diff
changeset
|
292 * @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:
388
diff
changeset
|
293 * 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:
388
diff
changeset
|
294 * @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:
388
diff
changeset
|
295 */ |
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:
388
diff
changeset
|
296 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:
388
diff
changeset
|
297 // *.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:
388
diff
changeset
|
298 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:
388
diff
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:
388
diff
changeset
|
300 |
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:
388
diff
changeset
|
301 /** |
419
7f136a3fa671
Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
418
diff
changeset
|
302 * @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:
388
diff
changeset
|
303 * 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:
388
diff
changeset
|
304 * @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:
388
diff
changeset
|
305 */ |
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:
388
diff
changeset
|
306 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:
388
diff
changeset
|
307 // 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:
388
diff
changeset
|
308 // 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:
388
diff
changeset
|
309 // 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:
388
diff
changeset
|
310 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:
388
diff
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:
388
diff
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:
388
diff
changeset
|
313 |
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:
388
diff
changeset
|
314 /** |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
315 * 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:
378
diff
changeset
|
316 * 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:
379
diff
changeset
|
317 * @param ctx |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
318 */ |
382
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
379
diff
changeset
|
319 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:
378
diff
changeset
|
320 // let clients to override Hg install location |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
321 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:
378
diff
changeset
|
322 if (p != null) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
323 return new File(p); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
324 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
325 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:
378
diff
changeset
|
326 final boolean runsOnWin = runningOnWindows(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
327 while (st.hasMoreTokens()) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
328 String pe = st.nextToken(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
329 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:
378
diff
changeset
|
330 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:
378
diff
changeset
|
331 File execDir = execCandidate.getParentFile(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
332 // 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:
378
diff
changeset
|
333 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:
378
diff
changeset
|
334 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
335 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
336 return null; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
337 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
338 |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
339 /** |
579
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
340 * User-specific configuration, from system-wide and user home locations, without any repository-specific data. |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
341 * |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
342 * @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:
378
diff
changeset
|
343 */ |
579
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
344 public static ConfigFile readConfiguration(SessionContext sessionCtx) throws IOException { |
483
e31e85cf4d4c
Handle include and unset directives in config files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
345 ConfigFile configFile = new ConfigFile(sessionCtx); |
e31e85cf4d4c
Handle include and unset directives in config files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
346 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:
378
diff
changeset
|
347 // |
351
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
348 if (runningOnWindows()) { |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
349 if (hgInstallRoot != null) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
350 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:
378
diff
changeset
|
351 configFile.addLocation(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
352 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
353 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
354 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:
378
diff
changeset
|
355 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:
378
diff
changeset
|
356 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:
378
diff
changeset
|
357 locations.remove(null); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
358 for (String loc : locations) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
359 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:
378
diff
changeset
|
360 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:
378
diff
changeset
|
361 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:
378
diff
changeset
|
362 } |
351
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
363 } else { |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
364 if (hgInstallRoot != null) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
365 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:
378
diff
changeset
|
366 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:
378
diff
changeset
|
367 for (File f : listConfigFiles(d)) { |
351
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
368 configFile.addLocation(f); |
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
369 } |
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
370 } |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
371 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:
378
diff
changeset
|
372 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
373 // 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:
378
diff
changeset
|
374 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:
378
diff
changeset
|
375 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:
378
diff
changeset
|
376 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:
378
diff
changeset
|
377 configFile.addLocation(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
378 } |
351
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
379 } |
5abba41751e6
Read extra predefined locations with mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
331
diff
changeset
|
380 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:
378
diff
changeset
|
381 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:
331
diff
changeset
|
382 } |
579
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
383 return configFile; |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
384 } |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
385 |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
386 /** |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
387 * Repository-specific configuration |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
388 * @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:
559
diff
changeset
|
389 */ |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
390 public ConfigFile readConfiguration() throws IOException { |
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
391 ConfigFile configFile = readConfiguration(repo.getSessionContext()); |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
392 // last one, overrides anything else |
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
393 // <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:
483
diff
changeset
|
394 configFile.addLocation(getFileFromRepoDir("hgrc")); |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
395 return configFile; |
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
396 } |
579
36e36b926747
Provide means to read user-specific configuration, with no specific repository selected
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
397 |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
398 /*package-local*/ImplAccess getImplAccess() { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
399 return implAccess; |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
400 } |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
401 |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
402 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:
378
diff
changeset
|
403 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:
378
diff
changeset
|
404 if (f.exists()) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
405 return Collections.singletonList(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
406 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
407 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:
378
diff
changeset
|
408 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:
378
diff
changeset
|
409 return listConfigFiles(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
410 } |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
411 // 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:
378
diff
changeset
|
412 // 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:
378
diff
changeset
|
413 // |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
414 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:
378
diff
changeset
|
415 if (f.exists()) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
416 return Collections.singletonList(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
417 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
418 return Collections.emptyList(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
419 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
420 |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
421 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:
378
diff
changeset
|
422 assert dir.canRead(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
423 assert dir.isDirectory(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
424 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:
378
diff
changeset
|
425 // 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:
378
diff
changeset
|
426 Arrays.sort(allFiles); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
427 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:
378
diff
changeset
|
428 for (File f : allFiles) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
429 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:
378
diff
changeset
|
430 rv.add(f); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
431 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
432 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
433 return rv; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
434 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
435 |
382
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
379
diff
changeset
|
436 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:
379
diff
changeset
|
437 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:
378
diff
changeset
|
438 // 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:
378
diff
changeset
|
439 if (hgInstallRoot != null) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
440 // 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:
378
diff
changeset
|
441 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:
378
diff
changeset
|
442 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:
378
diff
changeset
|
443 return cfg; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
444 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
445 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
446 // fallback |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
447 if (runningOnWindows()) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
448 if (hgInstallRoot == null) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
449 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:
378
diff
changeset
|
450 } else { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
451 // 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:
378
diff
changeset
|
452 // 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:
378
diff
changeset
|
453 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:
378
diff
changeset
|
454 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
455 } else { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
456 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:
378
diff
changeset
|
457 } |
378
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
458 } |
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
459 |
382
82336b7c54f4
Per-repository UpdateConfigCommand completed. Access to system properties through SessionContext to ease alternation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
379
diff
changeset
|
460 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:
378
diff
changeset
|
461 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:
378
diff
changeset
|
462 final boolean runsOnWindows = runningOnWindows(); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
463 if (runsOnWindows) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
464 locations.add(System.getenv("USERPROFILE")); |
378
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
465 } |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
466 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:
378
diff
changeset
|
467 locations.remove(null); |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
468 for (String loc : locations) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
469 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:
378
diff
changeset
|
470 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:
378
diff
changeset
|
471 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:
378
diff
changeset
|
472 return rv; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
473 } |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
474 if (runsOnWindows) { |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
475 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:
378
diff
changeset
|
476 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:
378
diff
changeset
|
477 return rv; |
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
478 } |
378
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
479 } |
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
480 } |
379
fa2be7a05af6
Implement discovery of mercurial installation, use it to read/write configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
378
diff
changeset
|
481 // 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:
378
diff
changeset
|
482 return new File(System.getProperty("user.home"), ".hgrc"); |
378
9fb990c8a724
Investigate approaches to alter Mercurial configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
351
diff
changeset
|
483 } |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
484 |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
485 public RevlogStream createManifestStream() { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
486 File manifestFile = getFileFromStoreDir("00manifest.i"); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
487 return streamProvider.create(manifestFile); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
488 } |
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:
382
diff
changeset
|
489 |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
490 public RevlogStream createChangelogStream() { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
491 File chlogFile = getFileFromStoreDir("00changelog.i"); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
492 return streamProvider.create(chlogFile); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
493 } |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
494 |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
495 public RevlogStream resolveStoreFile(Path path) { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
496 return streamProvider.resolveStoreFile(path); |
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:
382
diff
changeset
|
497 } |
407
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
498 |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
499 /*package-local*/ RevlogStream createStoreFile(Path path) throws HgInvalidControlFileException { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
500 return streamProvider.createStoreFile(path); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
501 } |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
502 |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
503 // marker method |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
504 public static IllegalStateException notImplemented() { |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
505 return new IllegalStateException("Not implemented"); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
506 } |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
507 |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
504
diff
changeset
|
508 public static Internals getInstance(HgRepository repo) { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
504
diff
changeset
|
509 return HgInternals.getImplementationRepo(repo); |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
504
diff
changeset
|
510 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
504
diff
changeset
|
511 |
407
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
512 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:
388
diff
changeset
|
513 if (col == null) { |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
514 return String.valueOf(col); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
515 } |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
516 Iterator<T> it = col.iterator(); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
517 if (!it.hasNext()) { |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
518 return "[]"; |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
519 } |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
520 String v = String.valueOf(it.next()); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
521 StringBuilder sb = new StringBuilder(v); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
522 while (it.hasNext()) { |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
523 sb.append(separator); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
524 v = String.valueOf(it.next()); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
525 sb.append(v); |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
526 } |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
527 return sb; |
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
388
diff
changeset
|
528 } |
420
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
529 |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
530 /** |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
531 * 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:
419
diff
changeset
|
532 * Use if there's even subtle chance there might be loss |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
533 * (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:
419
diff
changeset
|
534 */ |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
535 public static int ltoi(long l) { |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
536 int i = (int) l; |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
537 assert ((long) i) == l : "Loss of data!"; |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
538 return i; |
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
539 } |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
540 |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
541 // 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:
584
diff
changeset
|
542 public interface ImplAccess { |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
543 public RevlogStream getStream(HgDataFile df); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
544 public RevlogStream getManifestStream(); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
545 public RevlogStream getChangelogStream(); |
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
546 } |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
547 } |