comparison src/org/tmatesoft/hg/repo/HgDirstate.java @ 430:d280759c2a3f

branch information is not directly related to dirstate, clean API from this dependency
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 18:48:23 +0200
parents 9c9c442b5f2e
children 12f668401613
comparison
equal deleted inserted replaced
429:cd658b24a620 430:d280759c2a3f
62 /* map of canonicalized file names to their originals from dirstate file. 62 /* map of canonicalized file names to their originals from dirstate file.
63 * Note, only those canonical names that differ from their dirstate counterpart are recorded here 63 * Note, only those canonical names that differ from their dirstate counterpart are recorded here
64 */ 64 */
65 private Map<Path, Path> canonical2dirstateName; 65 private Map<Path, Path> canonical2dirstateName;
66 private Pair<Nodeid, Nodeid> parents; 66 private Pair<Nodeid, Nodeid> parents;
67 private String currentBranch;
68 67
69 // canonicalPath may be null if we don't need to check for names other than in dirstate 68 // canonicalPath may be null if we don't need to check for names other than in dirstate
70 /*package-local*/ HgDirstate(HgRepository hgRepo, File dirstate, PathPool pathPool, PathRewrite canonicalPath) { 69 /*package-local*/ HgDirstate(HgRepository hgRepo, File dirstate, PathPool pathPool, PathRewrite canonicalPath) {
71 repo = hgRepo; 70 repo = hgRepo;
72 dirstateFile = dirstate; // XXX decide whether file names shall be kept local to reader (see #branches()) or passed from outside 71 dirstateFile = dirstate; // XXX decide whether file names shall be kept local to reader (see #branches()) or passed from outside
190 da.done(); 189 da.done();
191 } 190 }
192 } 191 }
193 192
194 /** 193 /**
195 * FIXME move to a better place, e.g. WorkingCopy container that tracks both dirstate and branches (and, perhaps, undo, lastcommit and other similar information) 194 * TODO [post-1.0] it's really not a proper place for the method, need WorkingCopyContainer or similar
196 * @return branch associated with the working directory 195 * @return branch associated with the working directory
197 */ 196 */
198 public String branch() throws HgInvalidControlFileException { 197 /*package-local*/ static String readBranch(HgRepository repo, File branchFile) throws HgInvalidControlFileException {
199 // XXX is it really proper place for the method?
200 if (currentBranch == null) {
201 currentBranch = readBranch(repo);
202 }
203 return currentBranch;
204 }
205
206 /**
207 * XXX is it really proper place for the method?
208 * @return branch associated with the working directory
209 */
210 /*package-local*/ static String readBranch(HgRepository repo) throws HgInvalidControlFileException {
211 String branch = HgRepository.DEFAULT_BRANCH_NAME; 198 String branch = HgRepository.DEFAULT_BRANCH_NAME;
212 File branchFile = new File(repo.getRepositoryRoot(), "branch");
213 if (branchFile.exists()) { 199 if (branchFile.exists()) {
214 try { 200 try {
215 BufferedReader r = new BufferedReader(new FileReader(branchFile)); 201 BufferedReader r = new BufferedReader(new FileReader(branchFile));
216 String b = r.readLine(); 202 String b = r.readLine();
217 if (b != null) { 203 if (b != null) {