Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 526:2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 15 Jan 2013 17:07:19 +0100 |
parents | bf352ce2b97f |
children | 9edfd5a223b8 |
comparison
equal
deleted
inserted
replaced
525:0be5be8d57e9 | 526:2f9ed6bcefa2 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2012 TMate Software Ltd | 2 * Copyright (c) 2010-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
32 | 32 |
33 import org.tmatesoft.hg.core.Nodeid; | 33 import org.tmatesoft.hg.core.Nodeid; |
34 import org.tmatesoft.hg.core.SessionContext; | 34 import org.tmatesoft.hg.core.SessionContext; |
35 import org.tmatesoft.hg.internal.ByteArrayChannel; | 35 import org.tmatesoft.hg.internal.ByteArrayChannel; |
36 import org.tmatesoft.hg.internal.ConfigFile; | 36 import org.tmatesoft.hg.internal.ConfigFile; |
37 import org.tmatesoft.hg.internal.DirstateReader; | |
37 import org.tmatesoft.hg.internal.Experimental; | 38 import org.tmatesoft.hg.internal.Experimental; |
38 import org.tmatesoft.hg.internal.Filter; | 39 import org.tmatesoft.hg.internal.Filter; |
39 import org.tmatesoft.hg.internal.Internals; | 40 import org.tmatesoft.hg.internal.Internals; |
40 import org.tmatesoft.hg.internal.PropertyMarshal; | 41 import org.tmatesoft.hg.internal.PropertyMarshal; |
41 import org.tmatesoft.hg.internal.RevlogStream; | 42 import org.tmatesoft.hg.internal.RevlogStream; |
91 /** | 92 /** |
92 * Name of the primary branch, "default". | 93 * Name of the primary branch, "default". |
93 */ | 94 */ |
94 public static final String DEFAULT_BRANCH_NAME = "default"; | 95 public static final String DEFAULT_BRANCH_NAME = "default"; |
95 | 96 |
96 // temp aux marker method | |
97 public static IllegalStateException notImplemented() { | |
98 return new IllegalStateException("Not implemented"); | |
99 } | |
100 | |
101 private final File repoDir; // .hg folder | 97 private final File repoDir; // .hg folder |
102 private final File workingDir; // .hg/../ | 98 private final File workingDir; // .hg/../ |
103 private final String repoLocation; | 99 private final String repoLocation; |
104 /* | 100 /* |
105 * normalized slashes but otherwise regular file names | 101 * normalized slashes but otherwise regular file names |
297 /** | 293 /** |
298 * @return pair of values, {@link Pair#first()} and {@link Pair#second()} are respective parents, never <code>null</code>. | 294 * @return pair of values, {@link Pair#first()} and {@link Pair#second()} are respective parents, never <code>null</code>. |
299 * @throws HgInvalidControlFileException if attempt to read information about working copy parents from dirstate failed | 295 * @throws HgInvalidControlFileException if attempt to read information about working copy parents from dirstate failed |
300 */ | 296 */ |
301 public Pair<Nodeid,Nodeid> getWorkingCopyParents() throws HgInvalidControlFileException { | 297 public Pair<Nodeid,Nodeid> getWorkingCopyParents() throws HgInvalidControlFileException { |
302 return HgDirstate.readParents(impl); | 298 return DirstateReader.readParents(impl); |
303 } | 299 } |
304 | 300 |
305 /** | 301 /** |
306 * @return name of the branch associated with working directory, never <code>null</code>. | 302 * @return name of the branch associated with working directory, never <code>null</code>. |
307 * @throws HgInvalidControlFileException if attempt to read branch name failed. | 303 * @throws HgInvalidControlFileException if attempt to read branch name failed. |
308 */ | 304 */ |
309 public String getWorkingCopyBranchName() throws HgInvalidControlFileException { | 305 public String getWorkingCopyBranchName() throws HgInvalidControlFileException { |
310 if (wcBranch == null) { | 306 if (wcBranch == null) { |
311 wcBranch = HgDirstate.readBranch(impl); | 307 wcBranch = DirstateReader.readBranch(impl); |
312 } | 308 } |
313 return wcBranch; | 309 return wcBranch; |
314 } | 310 } |
315 | 311 |
316 /** | 312 /** |
348 } | 344 } |
349 } | 345 } |
350 return repoConfig; | 346 return repoConfig; |
351 } | 347 } |
352 | 348 |
353 // 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) | 349 // There seem to be no cases when access to HgDirstate is required from outside |
354 // XXX consider passing Path pool or factory to produce (shared) Path instead of Strings | 350 // (guess, working dir/revision walkers may hide dirstate access and no public visibility needed) |
355 /*package-local*/ final HgDirstate loadDirstate(Path.Source pathFactory) throws HgInvalidControlFileException { | 351 /*package-local*/ final HgDirstate loadDirstate(Path.Source pathFactory) throws HgInvalidControlFileException { |
356 PathRewrite canonicalPath = null; | 352 PathRewrite canonicalPath = null; |
357 if (!impl.isCaseSensitiveFileSystem()) { | 353 if (!impl.isCaseSensitiveFileSystem()) { |
358 canonicalPath = new PathRewrite() { | 354 canonicalPath = new PathRewrite() { |
359 | 355 |