diff 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
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgDirstate.java	Thu Mar 29 18:29:03 2012 +0200
+++ b/src/org/tmatesoft/hg/repo/HgDirstate.java	Thu Mar 29 18:48:23 2012 +0200
@@ -64,7 +64,6 @@
 	 */
 	private Map<Path, Path> canonical2dirstateName; 
 	private Pair<Nodeid, Nodeid> parents;
-	private String currentBranch;
 	
 	// canonicalPath may be null if we don't need to check for names other than in dirstate
 	/*package-local*/ HgDirstate(HgRepository hgRepo, File dirstate, PathPool pathPool, PathRewrite canonicalPath) {
@@ -192,24 +191,11 @@
 	}
 	
 	/**
-	 * FIXME move to a better place, e.g. WorkingCopy container that tracks both dirstate and branches (and, perhaps, undo, lastcommit and other similar information)
+	 * TODO [post-1.0] it's really not a proper place for the method, need WorkingCopyContainer or similar
 	 * @return branch associated with the working directory
 	 */
-	public String branch() throws HgInvalidControlFileException {
-		// XXX is it really proper place for the method?
-		if (currentBranch == null) {
-			currentBranch = readBranch(repo);
-		}
-		return currentBranch;
-	}
-	
-	/**
-	 * XXX is it really proper place for the method?
-	 * @return branch associated with the working directory
-	 */
-	/*package-local*/ static String readBranch(HgRepository repo) throws HgInvalidControlFileException {
+	/*package-local*/ static String readBranch(HgRepository repo, File branchFile) throws HgInvalidControlFileException {
 		String branch = HgRepository.DEFAULT_BRANCH_NAME;
-		File branchFile = new File(repo.getRepositoryRoot(), "branch");
 		if (branchFile.exists()) {
 			try {
 				BufferedReader r = new BufferedReader(new FileReader(branchFile));