Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgRepository.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 | 48f993aa2f41 |
children | 12f668401613 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRepository.java Thu Mar 29 18:29:03 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Thu Mar 29 18:48:23 2012 +0200 @@ -116,6 +116,14 @@ private HgIgnore ignore; private HgRepoConfig repoConfig; + /* + * TODO [post-1.0] move to a better place, e.g. WorkingCopy container that tracks both dirstate and branches + * (and, perhaps, undo, lastcommit and other similar information), and is change listener so that we don't need to + * worry about this cached value become stale + */ + private String wcBranch; + + HgRepository(String repositoryPath) { repoDir = null; workingDir = null; @@ -273,7 +281,10 @@ * @throws HgInvalidControlFileException if attempt to read branch name failed. */ public String getWorkingCopyBranchName() throws HgInvalidControlFileException { - return HgDirstate.readBranch(this); + if (wcBranch == null) { + wcBranch = HgDirstate.readBranch(this, new File(repoDir, "branch")); + } + return wcBranch; } /**