comparison 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
comparison
equal deleted inserted replaced
429:cd658b24a620 430:d280759c2a3f
113 private final HashMap<Path, SoftReference<RevlogStream>> streamsCache = new HashMap<Path, SoftReference<RevlogStream>>(); 113 private final HashMap<Path, SoftReference<RevlogStream>> streamsCache = new HashMap<Path, SoftReference<RevlogStream>>();
114 114
115 private final org.tmatesoft.hg.internal.Internals impl; 115 private final org.tmatesoft.hg.internal.Internals impl;
116 private HgIgnore ignore; 116 private HgIgnore ignore;
117 private HgRepoConfig repoConfig; 117 private HgRepoConfig repoConfig;
118
119 /*
120 * TODO [post-1.0] move to a better place, e.g. WorkingCopy container that tracks both dirstate and branches
121 * (and, perhaps, undo, lastcommit and other similar information), and is change listener so that we don't need to
122 * worry about this cached value become stale
123 */
124 private String wcBranch;
125
118 126
119 HgRepository(String repositoryPath) { 127 HgRepository(String repositoryPath) {
120 repoDir = null; 128 repoDir = null;
121 workingDir = null; 129 workingDir = null;
122 repoLocation = repositoryPath; 130 repoLocation = repositoryPath;
271 /** 279 /**
272 * @return name of the branch associated with working directory, never <code>null</code>. 280 * @return name of the branch associated with working directory, never <code>null</code>.
273 * @throws HgInvalidControlFileException if attempt to read branch name failed. 281 * @throws HgInvalidControlFileException if attempt to read branch name failed.
274 */ 282 */
275 public String getWorkingCopyBranchName() throws HgInvalidControlFileException { 283 public String getWorkingCopyBranchName() throws HgInvalidControlFileException {
276 return HgDirstate.readBranch(this); 284 if (wcBranch == null) {
285 wcBranch = HgDirstate.readBranch(this, new File(repoDir, "branch"));
286 }
287 return wcBranch;
277 } 288 }
278 289
279 /** 290 /**
280 * @return location where user files (shall) reside 291 * @return location where user files (shall) reside
281 */ 292 */