Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgInternals.java @ 490:b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 16 Aug 2012 17:08:34 +0200 |
parents | e31e85cf4d4c |
children | ba36f66c32b4 |
comparison
equal
deleted
inserted
replaced
489:9c0138cda59a | 490:b3c16d1aede0 |
---|---|
24 import java.io.Reader; | 24 import java.io.Reader; |
25 import java.net.InetAddress; | 25 import java.net.InetAddress; |
26 import java.net.UnknownHostException; | 26 import java.net.UnknownHostException; |
27 | 27 |
28 import org.tmatesoft.hg.core.Nodeid; | 28 import org.tmatesoft.hg.core.Nodeid; |
29 import org.tmatesoft.hg.core.SessionContext; | |
30 import org.tmatesoft.hg.internal.Experimental; | 29 import org.tmatesoft.hg.internal.Experimental; |
31 import org.tmatesoft.hg.internal.Internals; | 30 import org.tmatesoft.hg.internal.Internals; |
32 import org.tmatesoft.hg.internal.RelativePathRewrite; | 31 import org.tmatesoft.hg.internal.RelativePathRewrite; |
33 import org.tmatesoft.hg.internal.WinToNixPathRewrite; | 32 import org.tmatesoft.hg.internal.WinToNixPathRewrite; |
34 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; | 33 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; |
71 public CharSequence rewrite(CharSequence path) { | 70 public CharSequence rewrite(CharSequence path) { |
72 return path.toString().toLowerCase(); | 71 return path.toString().toLowerCase(); |
73 } | 72 } |
74 }; | 73 }; |
75 } | 74 } |
76 HgDirstate ds = new HgDirstate(repo, new File(repo.getRepositoryRoot(), "dirstate"), new Path.SimpleSource(), canonicalPath); | 75 HgDirstate ds = new HgDirstate(repo.getImplHelper(), new Path.SimpleSource(), canonicalPath); |
77 ds.read(repo.getImplHelper().buildFileNameEncodingHelper()); | 76 ds.read(); |
78 return ds; | 77 return ds; |
79 } | 78 } |
80 | 79 |
81 public Path[] checkKnown(HgDirstate dirstate, Path[] toCheck) { | 80 public Path[] checkKnown(HgDirstate dirstate, Path[] toCheck) { |
82 Path[] rv = new Path[toCheck.length]; | 81 Path[] rv = new Path[toCheck.length]; |
143 File repoRoot = repo.getWorkingDir(); | 142 File repoRoot = repo.getWorkingDir(); |
144 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), repo.getToRepoPathHelper())); | 143 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), repo.getToRepoPathHelper())); |
145 // Impl note: simple source is enough as files in the working dir are all unique | 144 // Impl note: simple source is enough as files in the working dir are all unique |
146 // even if they might get reused (i.e. after FileIterator#reset() and walking once again), | 145 // even if they might get reused (i.e. after FileIterator#reset() and walking once again), |
147 // path caching is better to be done in the code which knows that path are being reused | 146 // path caching is better to be done in the code which knows that path are being reused |
148 return new FileWalker(repo.getContext(), repoRoot, pathSrc, workindDirScope); | 147 return new FileWalker(repo.getSessionContext(), repoRoot, pathSrc, workindDirScope); |
149 } | 148 } |
150 | 149 |
151 // expose otherwise package-local information primarily to use in our own o.t.hg.core package | |
152 public static SessionContext getContext(HgRepository repo) { | |
153 // TODO SessionContext.Source and HgRepo to implement it | |
154 return repo.getContext(); | |
155 } | |
156 | |
157 | |
158 // Convenient check of revision index for validity (not all negative values are wrong as long as we use negative constants) | 150 // Convenient check of revision index for validity (not all negative values are wrong as long as we use negative constants) |
159 public static boolean wrongRevisionIndex(int rev) { | 151 public static boolean wrongRevisionIndex(int rev) { |
160 // TODO Another method to check,throw and expand TIP at once (check[Revision|Revlog]Index() | 152 // TODO Another method to check,throw and expand TIP at once (check[Revision|Revlog]Index() |
161 return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION && rev != NO_REVISION; | 153 return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION && rev != NO_REVISION; |
162 } | 154 } |