Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgRepository.java @ 237:6e1373b54e9b
Allow access to working copy content through HgDataFile. Give access to repository's working dir
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 10 Jun 2011 04:35:21 +0200 |
parents | fd845a53f53d |
children | df9d2854d3d6 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRepository.java Thu Jun 09 06:13:43 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Fri Jun 10 04:35:21 2011 +0200 @@ -22,7 +22,6 @@ import java.io.IOException; import java.io.StringReader; import java.lang.ref.SoftReference; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -64,6 +63,7 @@ } private final File repoDir; // .hg folder + private final File workingDir; // .hg/../ private final String repoLocation; private final DataAccessProvider dataAccess; private final PathRewrite normalizePath; @@ -85,6 +85,7 @@ HgRepository(String repositoryPath) { repoDir = null; + workingDir = null; repoLocation = repositoryPath; dataAccess = null; dataPathHelper = repoPathHelper = null; @@ -96,6 +97,10 @@ assert repositoryPath != null; assert repositoryRoot != null; repoDir = repositoryRoot; + workingDir = repoDir.getParentFile(); + if (workingDir == null) { + throw new IllegalArgumentException(repoDir.toString()); + } repoLocation = repositoryPath; dataAccess = new DataAccessProvider(); final boolean runningOnWindows = System.getProperty("os.name").indexOf("Windows") != -1; @@ -230,7 +235,14 @@ return new Pair<Nodeid,Nodeid>(NULL == p[0] ? null : p[0], NULL == p[1] ? null : p[1]); } - // local to hide use of io.File. + /** + * @return location where user files (shall) reside + */ + public File getWorkingDir() { + return workingDir; + } + + // shall be of use only for internal classes /*package-local*/ File getRepositoryRoot() { return repoDir; } @@ -307,6 +319,10 @@ /*package-local*/ List<Filter> getFiltersFromWorkingDirToRepo(Path p) { return instantiateFilters(p, new Filter.Options(Filter.Direction.ToRepo)); } + + /*package-local*/ File getFile(HgDataFile dataFile) { + return new File(getWorkingDir(), dataFile.getPath().toString()); + } private List<Filter> instantiateFilters(Path p, Filter.Options opts) { List<Filter.Factory> factories = impl.getFilters(this, getConfigFile());