annotate src/org/tmatesoft/hg/repo/HgRepository.java @ 406:d56ea1a2537a

Less meaningless package descriptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 15 Mar 2012 16:51:46 +0100
parents 866fc3b597a0
children bb278ccf9866
rev   line source
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
1 /*
388
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
2 * Copyright (c) 2010-2012 TMate Software Ltd
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 68
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: 68
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 68
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: 68
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 97
diff changeset
15 * contact TMate Software at support@hg4j.com
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
17 package org.tmatesoft.hg.repo;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
18
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
19 import java.io.File;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
20 import java.io.IOException;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
21 import java.io.StringReader;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
22 import java.lang.ref.SoftReference;
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
23 import java.util.ArrayList;
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
24 import java.util.Collections;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
25 import java.util.HashMap;
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
26 import java.util.List;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 388
diff changeset
28 import org.tmatesoft.hg.core.HgException;
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
29 import org.tmatesoft.hg.core.HgInvalidControlFileException;
405
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
30 import org.tmatesoft.hg.core.HgInvalidRevisionException;
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 234
diff changeset
31 import org.tmatesoft.hg.core.Nodeid;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
32 import org.tmatesoft.hg.core.SessionContext;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
33 import org.tmatesoft.hg.internal.ByteArrayChannel;
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
34 import org.tmatesoft.hg.internal.ConfigFile;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
35 import org.tmatesoft.hg.internal.DataAccessProvider;
231
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
36 import org.tmatesoft.hg.internal.Experimental;
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
37 import org.tmatesoft.hg.internal.Filter;
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
38 import org.tmatesoft.hg.internal.RevlogStream;
239
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
39 import org.tmatesoft.hg.internal.SubrepoManager;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
40 import org.tmatesoft.hg.util.CancelledException;
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 234
diff changeset
41 import org.tmatesoft.hg.util.Pair;
133
4a948ec83980 core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 115
diff changeset
42 import org.tmatesoft.hg.util.Path;
284
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
43 import org.tmatesoft.hg.util.PathPool;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 55
diff changeset
44 import org.tmatesoft.hg.util.PathRewrite;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
45 import org.tmatesoft.hg.util.ProgressSupport;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 55
diff changeset
46
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
47
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
48
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 /**
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 55
diff changeset
50 * Shall be as state-less as possible, all the caching happens outside the repo, in commands/walkers
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
51 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
52 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
53 * @author TMate Software Ltd.
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
55 public final class HgRepository {
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56
405
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
57 // IMPORTANT: if new constants added, consider fixing HgInternals#wrongRevisionIndex and HgInvalidRevisionException#getMessage
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
58
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
59 /**
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
60 * Revision index constant to indicate most recent revision
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
61 */
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
62 public static final int TIP = -3; // XXX TIP_REVISION?
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
63
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
64 /**
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
65 * Revision index constant to indicate invalid revision index value.
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
66 * Primary use is default/uninitialized values where user input is expected and as return value where
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
67 * an exception (e.g. {@link HgInvalidRevisionException}) is not desired
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
68 */
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
69 public static final int BAD_REVISION = Integer.MIN_VALUE; // XXX INVALID_REVISION?
405
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
70
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
71 /**
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
72 * Revision index constant to indicate working copy
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
73 */
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
74 public static final int WORKING_COPY = -2; // XXX WORKING_COPY_REVISION?
252
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
75
405
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
76 /**
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
77 * Constant ({@value #NO_REVISION}) to indicate revision absence (e.g. missing parent in from {@link HgChangelog#parents(int, int[], byte[], byte[])} call)
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
78 * or a fictitious revision of an empty repository, to use as an argument (contrary to {@link #BAD_REVISION})
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
79 * e.g in a status operation to visit changes from the very beginning of a repository.
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
80 */
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
81 public static final int NO_REVISION = -1;
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
82
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
83 /**
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
84 * Name of the primary branch, "default".
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
85 */
252
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
86 public static final String DEFAULT_BRANCH_NAME = "default";
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
87
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
88 // temp aux marker method
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
89 public static IllegalStateException notImplemented() {
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
90 return new IllegalStateException("Not implemented");
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
91 }
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 145
diff changeset
92
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
93 private final File repoDir; // .hg folder
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
94 private final File workingDir; // .hg/../
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
95 private final String repoLocation;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
96 private final DataAccessProvider dataAccess;
142
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 141
diff changeset
97 private final PathRewrite normalizePath;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
98 private final PathRewrite dataPathHelper;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
99 private final PathRewrite repoPathHelper;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
100 private final SessionContext sessionContext;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
101
97
ee2c750b036d Changelog to HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
102 private HgChangelog changelog;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
103 private HgManifest manifest;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
104 private HgTags tags;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
105 private HgBranches branches;
231
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
106 private HgMergeState mergeState;
239
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
107 private SubrepoManager subRepos;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
108
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
109 // XXX perhaps, shall enable caching explicitly
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
110 private final HashMap<Path, SoftReference<RevlogStream>> streamsCache = new HashMap<Path, SoftReference<RevlogStream>>();
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
111
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: 367
diff changeset
112 private final org.tmatesoft.hg.internal.Internals impl;
91
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
113 private HgIgnore ignore;
331
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
114 private HgRepoConfig repoConfig;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
115
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
116 HgRepository(String repositoryPath) {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
117 repoDir = null;
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
118 workingDir = null;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
119 repoLocation = repositoryPath;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
120 dataAccess = null;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
121 dataPathHelper = repoPathHelper = null;
142
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 141
diff changeset
122 normalizePath = null;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
123 sessionContext = null;
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: 367
diff changeset
124 impl = null;
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
125 }
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
126
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
127 HgRepository(SessionContext ctx, String repositoryPath, File repositoryRoot) {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
128 assert ".hg".equals(repositoryRoot.getName()) && repositoryRoot.isDirectory();
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 145
diff changeset
129 assert repositoryPath != null;
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 145
diff changeset
130 assert repositoryRoot != null;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
131 assert ctx != null;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
132 repoDir = repositoryRoot;
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
133 workingDir = repoDir.getParentFile();
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
134 if (workingDir == null) {
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
135 throw new IllegalArgumentException(repoDir.toString());
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
136 }
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: 367
diff changeset
137 impl = new org.tmatesoft.hg.internal.Internals(ctx);
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 145
diff changeset
138 repoLocation = repositoryPath;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
139 sessionContext = ctx;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
140 dataAccess = new DataAccessProvider(ctx);
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
141 impl.parseRequires(this, new File(repoDir, "requires"));
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: 367
diff changeset
142 normalizePath = impl.buildNormalizePathRewrite();
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
143 dataPathHelper = impl.buildDataFilesHelper();
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
144 repoPathHelper = impl.buildRepositoryFilesHelper();
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
145 }
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
146
145
acc6151b1b7a toString for friendly debug
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
147 @Override
acc6151b1b7a toString for friendly debug
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
148 public String toString() {
acc6151b1b7a toString for friendly debug
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
149 return getClass().getSimpleName() + "[" + getLocation() + (isInvalid() ? "(BAD)" : "") + "]";
acc6151b1b7a toString for friendly debug
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
150 }
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
151
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
152 public String getLocation() {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
153 return repoLocation;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
154 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
155
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
156 public boolean isInvalid() {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
157 return repoDir == null || !repoDir.exists() || !repoDir.isDirectory();
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
158 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
159
97
ee2c750b036d Changelog to HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
160 public HgChangelog getChangelog() {
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: 367
diff changeset
161 if (changelog == null) {
292
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
162 CharSequence storagePath = repoPathHelper.rewrite("00changelog.i");
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: 197
diff changeset
163 RevlogStream content = resolve(Path.create(storagePath), true);
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: 367
diff changeset
164 changelog = new HgChangelog(this, content);
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
165 }
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: 367
diff changeset
166 return changelog;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
167 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
168
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
169 public HgManifest getManifest() {
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: 367
diff changeset
170 if (manifest == null) {
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: 197
diff changeset
171 RevlogStream content = resolve(Path.create(repoPathHelper.rewrite("00manifest.i")), true);
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: 367
diff changeset
172 manifest = new HgManifest(this, content);
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
173 }
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: 367
diff changeset
174 return manifest;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
175 }
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
176
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
177 public HgTags getTags() throws HgInvalidControlFileException {
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
178 if (tags == null) {
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
179 tags = new HgTags(this);
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
180 HgDataFile hgTags = getFileNode(".hgtags");
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
181 if (hgTags.exists()) {
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
182 for (int i = 0; i <= hgTags.getLastRevision(); i++) { // FIXME in fact, would be handy to have walk(start,end)
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
183 // method for data files as well, though it looks odd.
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
184 try {
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
185 ByteArrayChannel sink = new ByteArrayChannel();
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
186 hgTags.content(i, sink);
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
187 final String content = new String(sink.toArray(), "UTF8");
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
188 tags.readGlobal(new StringReader(content));
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
189 } catch (CancelledException ex) {
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
190 // IGNORE, can't happen, we did not configure cancellation
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
191 getContext().getLog().debug(getClass(), ex, null);
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 388
diff changeset
192 } catch (HgException ex) {
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
193 getContext().getLog().error(getClass(), ex, null);
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
194 // FIXME need to react
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
195 } catch (IOException ex) {
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
196 // UnsupportedEncodingException can't happen (UTF8)
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
197 // only from readGlobal. Need to reconsider exceptions thrown from there:
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
198 // BufferedReader wraps String and unlikely to throw IOException, perhaps, log is enough?
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
199 getContext().getLog().error(getClass(), ex, null);
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
200 // XXX need to decide what to do this. failure to read single revision shall not break complete cycle
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
201 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 231
diff changeset
202 }
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
203 }
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
204 File file2read = null;
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
205 try {
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
206 file2read = new File(getWorkingDir(), ".hgtags");
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
207 tags.readGlobal(file2read); // XXX replace with HgDataFile.workingCopy
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
208 file2read = new File(repoDir, "localtags");
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
209 tags.readLocal(file2read);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
210 } catch (IOException ex) {
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
211 getContext().getLog().error(getClass(), ex, null);
318
c3d2233ba842 Shall propagate errors to clients, not work around them silently
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
212 throw new HgInvalidControlFileException("Failed to read tags", ex, file2read);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
213 }
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
214 }
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
215 return tags;
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
216 }
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
217
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 348
diff changeset
218 public HgBranches getBranches() throws HgInvalidControlFileException {
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
219 if (branches == null) {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
220 branches = new HgBranches(this);
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
221 branches.collect(ProgressSupport.Factory.get(null));
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
222 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
223 return branches;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
224 }
231
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
225
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
226 @Experimental(reason="Perhaps, shall not cache instance, and provide loadMergeState as it may change often")
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
227 public HgMergeState getMergeState() {
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
228 if (mergeState == null) {
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
229 mergeState = new HgMergeState(this);
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
230 }
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
231 return mergeState;
1792b37650f2 Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 229
diff changeset
232 }
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
233
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
234 public HgDataFile getFileNode(String path) {
292
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
235 CharSequence nPath = normalizePath.rewrite(path);
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
236 CharSequence storagePath = dataPathHelper.rewrite(nPath);
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: 197
diff changeset
237 RevlogStream content = resolve(Path.create(storagePath), false);
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
238 Path p = Path.create(nPath);
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
239 if (content == null) {
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
240 return new HgDataFile(this, p);
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
241 }
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
242 return new HgDataFile(this, p, content);
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
243 }
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
244
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
245 public HgDataFile getFileNode(Path path) {
292
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
246 CharSequence storagePath = dataPathHelper.rewrite(path.toString());
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: 197
diff changeset
247 RevlogStream content = resolve(Path.create(storagePath), false);
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
248 // XXX no content when no file? or HgDataFile.exists() to detect that?
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
249 if (content == null) {
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
250 return new HgDataFile(this, path);
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 114
diff changeset
251 }
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
252 return new HgDataFile(this, path, content);
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
253 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
254
142
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 141
diff changeset
255 /* clients need to rewrite path from their FS to a repository-friendly paths, and, perhaps, vice versa*/
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 141
diff changeset
256 public PathRewrite getToRepoPathHelper() {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
257 return normalizePath;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
258 }
284
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
259
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
260 /**
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
261 * @return pair of values, {@link Pair#first()} and {@link Pair#second()} are respective parents, never <code>null</code>.
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
262 * @throws HgInvalidControlFileException if attempt to read information about working copy parents from dirstate failed
284
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
263 */
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
264 public Pair<Nodeid,Nodeid> getWorkingCopyParents() throws HgInvalidControlFileException {
284
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
265 return HgDirstate.readParents(this, new File(repoDir, "dirstate"));
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 234
diff changeset
266 }
252
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
267
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
268 /**
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
269 * @return name of the branch associated with working directory, never <code>null</code>.
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
270 * @throws HgInvalidControlFileException if attempt to read branch name failed.
252
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
271 */
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
272 public String getWorkingCopyBranchName() throws HgInvalidControlFileException {
284
7232b94f2ae3 HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
273 return HgDirstate.readBranch(this);
252
a6d19adc2636 HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 239
diff changeset
274 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
275
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
276 /**
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
277 * @return location where user files (shall) reside
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
278 */
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
279 public File getWorkingDir() {
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
280 return workingDir;
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
281 }
239
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
282
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
283 /**
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
284 * Provides access to sub-repositories defined in this repository. Enumerated sub-repositories are those directly
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
285 * known, not recursive collection of all nested sub-repositories.
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
286 * @return list of all known sub-repositories in this repository, or empty list if none found.
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
287 */
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
288 public List<HgSubrepoLocation> getSubrepositories() throws HgInvalidControlFileException {
239
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
289 if (subRepos == null) {
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
290 subRepos = new SubrepoManager(this);
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
291 subRepos.read();
239
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
292 }
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
293 return subRepos.all();
df9d2854d3d6 Initial access to subrepositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
294 }
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
295
331
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
296
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
297 public HgRepoConfig getConfiguration() /* XXX throws HgInvalidControlFileException? Description of the exception suggests it is only for files under ./hg/*/ {
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
298 if (repoConfig == null) {
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
299 try {
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
300 ConfigFile configFile = impl.readConfiguration(this, getRepositoryRoot());
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
301 repoConfig = new HgRepoConfig(configFile);
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
302 } catch (IOException ex) {
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
303 String m = "Errors while reading user configuration file";
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
304 getContext().getLog().warn(getClass(), ex, m);
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
305 return new HgRepoConfig(new ConfigFile()); // empty config, do not cache, allow to try once again
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
306 //throw new HgInvalidControlFileException(m, ex, null);
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
307 }
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
308 }
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
309 return repoConfig;
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
310 }
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
311
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
312 // shall be of use only for internal classes
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
313 /*package-local*/ File getRepositoryRoot() {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
314 return repoDir;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
315 }
337
f377f833b780 Issue 17: temporary code to nail down the problem
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 335
diff changeset
316
f377f833b780 Issue 17: temporary code to nail down the problem
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 335
diff changeset
317 // FIXME remove once NPE in HgWorkingCopyStatusCollector.areTheSame is solved
f377f833b780 Issue 17: temporary code to nail down the problem
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 335
diff changeset
318 /*package-local, debug*/String getStoragePath(HgDataFile df) {
f377f833b780 Issue 17: temporary code to nail down the problem
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 335
diff changeset
319 return dataPathHelper.rewrite(df.getPath().toString()).toString();
f377f833b780 Issue 17: temporary code to nail down the problem
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 335
diff changeset
320 }
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
321
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
322 // XXX package-local, unless there are cases when required from outside (guess, working dir/revision walkers may hide dirstate access and no public visibility needed)
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 252
diff changeset
323 // XXX consider passing Path pool or factory to produce (shared) Path instead of Strings
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
324 /*package-local*/ final HgDirstate loadDirstate(PathPool pathPool) throws HgInvalidControlFileException {
292
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
325 PathRewrite canonicalPath = null;
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: 367
diff changeset
326 if (!impl.isCaseSensitiveFileSystem()) {
292
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
327 canonicalPath = new PathRewrite() {
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
328
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
329 public CharSequence rewrite(CharSequence path) {
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
330 return path.toString().toLowerCase();
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
331 }
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
332 };
a415fe296a50 Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 289
diff changeset
333 }
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
334 HgDirstate ds = new HgDirstate(this, new File(repoDir, "dirstate"), pathPool, canonicalPath);
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
335 ds.read();
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
336 return ds;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
337 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
338
289
086a326f181f Provide public access to ignored files configuration to use in alternative file walkers
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
339 /**
086a326f181f Provide public access to ignored files configuration to use in alternative file walkers
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
340 * Access to configured set of ignored files.
086a326f181f Provide public access to ignored files configuration to use in alternative file walkers
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
341 * @see HgIgnore#isIgnored(Path)
086a326f181f Provide public access to ignored files configuration to use in alternative file walkers
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
342 */
335
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
343 public HgIgnore getIgnore() /*throws HgInvalidControlFileException */{
91
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
344 // TODO read config for additional locations
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
345 if (ignore == null) {
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
346 ignore = new HgIgnore();
335
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
347 File ignoreFile = new File(getWorkingDir(), ".hgignore");
91
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
348 try {
335
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
349 final List<String> errors = ignore.read(ignoreFile);
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
350 if (errors != null) {
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
351 getContext().getLog().warn(getClass(), "Syntax errors parsing .hgignore:\n%s", errors);
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
352 }
91
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
353 } catch (IOException ex) {
335
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
354 final String m = "Error reading .hgignore file";
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
355 getContext().getLog().warn(getClass(), ex, m);
3d41dc148d14 Do not fail with exception on syntax errors in .hgignore
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 331
diff changeset
356 // throw new HgInvalidControlFileException(m, ex, ignoreFile);
91
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
357 }
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
358 }
c2ce1cfaeb9e ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
359 return ignore;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
360 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
361
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
362 /*package-local*/ DataAccessProvider getDataAccess() {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
363 return dataAccess;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
364 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
365
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
366 /**
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
367 * Perhaps, should be separate interface, like ContentLookup
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
368 * path - repository storage path (i.e. one usually with .i or .d)
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
369 */
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: 197
diff changeset
370 /*package-local*/ RevlogStream resolve(Path path, boolean shallFakeNonExistent) {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
371 final SoftReference<RevlogStream> ref = streamsCache.get(path);
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
372 RevlogStream cached = ref == null ? null : ref.get();
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
373 if (cached != null) {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
374 return cached;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
375 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
376 File f = new File(repoDir, path.toString());
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
377 if (f.exists()) {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
378 RevlogStream s = new RevlogStream(dataAccess, f);
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: 367
diff changeset
379 if (impl.shallCacheRevlogs()) {
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
380 streamsCache.put(path, new SoftReference<RevlogStream>(s));
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: 367
diff changeset
381 }
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
382 return s;
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: 197
diff changeset
383 } else {
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: 197
diff changeset
384 if (shallFakeNonExistent) {
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: 197
diff changeset
385 try {
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: 197
diff changeset
386 File fake = File.createTempFile(f.getName(), null);
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: 197
diff changeset
387 fake.deleteOnExit();
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: 197
diff changeset
388 return new RevlogStream(dataAccess, fake);
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: 197
diff changeset
389 } catch (IOException ex) {
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
390 getContext().getLog().info(getClass(), ex, null);
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: 197
diff changeset
391 }
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: 197
diff changeset
392 }
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
393 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
394 return null; // XXX empty stream instead?
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
395 }
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
396
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
397 /*package-local*/ List<Filter> getFiltersFromRepoToWorkingDir(Path p) {
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
398 return instantiateFilters(p, new Filter.Options(Filter.Direction.FromRepo));
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
399 }
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
400
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
401 /*package-local*/ List<Filter> getFiltersFromWorkingDirToRepo(Path p) {
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
402 return instantiateFilters(p, new Filter.Options(Filter.Direction.ToRepo));
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
403 }
237
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
404
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
405 /*package-local*/ File getFile(HgDataFile dataFile) {
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
406 return new File(getWorkingDir(), dataFile.getPath().toString());
6e1373b54e9b Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
407 }
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
408
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
409 /*package-local*/ SessionContext getContext() {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
410 return sessionContext;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 292
diff changeset
411 }
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
412
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
413 private List<Filter> instantiateFilters(Path p, Filter.Options opts) {
331
a37ce7145c3f Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 318
diff changeset
414 List<Filter.Factory> factories = impl.getFilters(this);
114
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
415 if (factories.isEmpty()) {
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
416 return Collections.emptyList();
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
417 }
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
418 ArrayList<Filter> rv = new ArrayList<Filter>(factories.size());
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
419 for (Filter.Factory ff : factories) {
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
420 Filter f = ff.create(p, opts);
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
421 if (f != null) {
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
422 rv.add(f);
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
423 }
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
424 }
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
425 return rv;
46291ec605a0 Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
426 }
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
427 }