Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 284:7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 03 Sep 2011 13:12:13 +0200 |
parents | 35125450c804 |
children | 086a326f181f |
comparison
equal
deleted
inserted
replaced
283:7a8e1a305a78 | 284:7232b94f2ae3 |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import static org.tmatesoft.hg.core.Nodeid.NULL; | |
20 | |
21 import java.io.File; | 19 import java.io.File; |
22 import java.io.IOException; | 20 import java.io.IOException; |
23 import java.io.StringReader; | 21 import java.io.StringReader; |
24 import java.lang.ref.SoftReference; | 22 import java.lang.ref.SoftReference; |
25 import java.util.ArrayList; | 23 import java.util.ArrayList; |
38 import org.tmatesoft.hg.internal.RevlogStream; | 36 import org.tmatesoft.hg.internal.RevlogStream; |
39 import org.tmatesoft.hg.internal.SubrepoManager; | 37 import org.tmatesoft.hg.internal.SubrepoManager; |
40 import org.tmatesoft.hg.util.CancelledException; | 38 import org.tmatesoft.hg.util.CancelledException; |
41 import org.tmatesoft.hg.util.Pair; | 39 import org.tmatesoft.hg.util.Pair; |
42 import org.tmatesoft.hg.util.Path; | 40 import org.tmatesoft.hg.util.Path; |
41 import org.tmatesoft.hg.util.PathPool; | |
43 import org.tmatesoft.hg.util.PathRewrite; | 42 import org.tmatesoft.hg.util.PathRewrite; |
44 import org.tmatesoft.hg.util.ProgressSupport; | 43 import org.tmatesoft.hg.util.ProgressSupport; |
45 | 44 |
46 | 45 |
47 | 46 |
230 | 229 |
231 /* clients need to rewrite path from their FS to a repository-friendly paths, and, perhaps, vice versa*/ | 230 /* clients need to rewrite path from their FS to a repository-friendly paths, and, perhaps, vice versa*/ |
232 public PathRewrite getToRepoPathHelper() { | 231 public PathRewrite getToRepoPathHelper() { |
233 return normalizePath; | 232 return normalizePath; |
234 } | 233 } |
235 | 234 |
236 @Experimental(reason="return type and possible values (presently null, perhaps Nodeid.NULL) may get changed") | 235 /** |
236 * @return pair of values, {@link Pair#first()} and {@link Pair#second()} are respective parents, never <code>null</code>. | |
237 */ | |
237 public Pair<Nodeid,Nodeid> getWorkingCopyParents() { | 238 public Pair<Nodeid,Nodeid> getWorkingCopyParents() { |
238 Nodeid[] p = loadDirstate().parents(); | 239 return HgDirstate.readParents(this, new File(repoDir, "dirstate")); |
239 return new Pair<Nodeid,Nodeid>(NULL == p[0] ? null : p[0], NULL == p[1] ? null : p[1]); | |
240 } | 240 } |
241 | 241 |
242 /** | 242 /** |
243 * @return name of the branch associated with working directory, never <code>null</code>. | 243 * @return name of the branch associated with working directory, never <code>null</code>. |
244 */ | 244 */ |
245 public String getWorkingCopyBranchName() { | 245 public String getWorkingCopyBranchName() { |
246 return loadDirstate().branch(); | 246 return HgDirstate.readBranch(this); |
247 } | 247 } |
248 | 248 |
249 /** | 249 /** |
250 * @return location where user files (shall) reside | 250 * @return location where user files (shall) reside |
251 */ | 251 */ |
270 return repoDir; | 270 return repoDir; |
271 } | 271 } |
272 | 272 |
273 // 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) | 273 // 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) |
274 // XXX consider passing Path pool or factory to produce (shared) Path instead of Strings | 274 // XXX consider passing Path pool or factory to produce (shared) Path instead of Strings |
275 /*package-local*/ final HgDirstate loadDirstate() { | 275 /*package-local*/ final HgDirstate loadDirstate(PathPool pathPool) { |
276 return new HgDirstate(this, new File(repoDir, "dirstate")); | 276 return new HgDirstate(this, new File(repoDir, "dirstate"), pathPool); |
277 } | 277 } |
278 | 278 |
279 // package-local, see comment for loadDirstate | 279 // package-local, see comment for loadDirstate |
280 /*package-local*/ final HgIgnore getIgnore() { | 280 /*package-local*/ final HgIgnore getIgnore() { |
281 // TODO read config for additional locations | 281 // TODO read config for additional locations |