comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 628:6526d8adbc0f

Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 22 May 2013 15:52:31 +0200
parents 99ad1e3a4e4d
children ffce73efa2c2
comparison
equal deleted inserted replaced
627:5153eb73b18d 628:6526d8adbc0f
25 import java.nio.CharBuffer; 25 import java.nio.CharBuffer;
26 import java.util.ArrayList; 26 import java.util.ArrayList;
27 import java.util.Collections; 27 import java.util.Collections;
28 import java.util.List; 28 import java.util.List;
29 29
30 import org.tmatesoft.hg.core.HgIOException;
30 import org.tmatesoft.hg.core.Nodeid; 31 import org.tmatesoft.hg.core.Nodeid;
31 import org.tmatesoft.hg.core.SessionContext; 32 import org.tmatesoft.hg.core.SessionContext;
32 import org.tmatesoft.hg.internal.ConfigFile; 33 import org.tmatesoft.hg.internal.ConfigFile;
33 import org.tmatesoft.hg.internal.DirstateReader; 34 import org.tmatesoft.hg.internal.DirstateReader;
34 import org.tmatesoft.hg.internal.Filter; 35 import org.tmatesoft.hg.internal.Filter;
193 /** 194 /**
194 * Access snapshot of repository tags. 195 * Access snapshot of repository tags.
195 * 196 *
196 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 197 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
197 */ 198 */
198 public HgTags getTags() throws HgInvalidControlFileException { 199 public HgTags getTags() throws HgRuntimeException {
199 if (tags == null) { 200 if (tags == null) {
200 tags = new HgTags(impl); 201 tags = new HgTags(impl);
201 tags.read(); 202 tags.read();
202 } else { 203 } else {
203 tags.reloadIfChanged(); 204 tags.reloadIfChanged();
210 * If repository get changed, use this method to obtain an up-to-date state. 211 * If repository get changed, use this method to obtain an up-to-date state.
211 * 212 *
212 * @return branch manager instance, never <code>null</code> 213 * @return branch manager instance, never <code>null</code>
213 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 214 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
214 */ 215 */
215 public HgBranches getBranches() throws HgInvalidControlFileException { 216 public HgBranches getBranches() throws HgRuntimeException {
216 final ProgressSupport ps = ProgressSupport.Factory.get(null); 217 final ProgressSupport ps = ProgressSupport.Factory.get(null);
217 if (branches == null) { 218 if (branches == null) {
218 branches = new HgBranches(impl); 219 branches = new HgBranches(impl);
219 branches.collect(ps); 220 branches.collect(ps);
220 } else { 221 } else {
224 } 225 }
225 226
226 /** 227 /**
227 * Access state of the recent merge 228 * Access state of the recent merge
228 * @return merge state facility, never <code>null</code> 229 * @return merge state facility, never <code>null</code>
229 */ 230 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
230 public HgMergeState getMergeState() { 231 */
232 public HgMergeState getMergeState() throws HgRuntimeException {
231 if (mergeState == null) { 233 if (mergeState == null) {
232 mergeState = new HgMergeState(impl); 234 mergeState = new HgMergeState(impl);
235 mergeState.refresh();
233 } 236 }
234 return mergeState; 237 return mergeState;
235 } 238 }
236 239
237 public HgDataFile getFileNode(String path) { 240 public HgDataFile getFileNode(String path) {
303 public HgRepoConfig getConfiguration() /* XXX throws HgInvalidControlFileException? Description of the exception suggests it is only for files under ./hg/*/ { 306 public HgRepoConfig getConfiguration() /* XXX throws HgInvalidControlFileException? Description of the exception suggests it is only for files under ./hg/*/ {
304 if (repoConfig == null) { 307 if (repoConfig == null) {
305 try { 308 try {
306 ConfigFile configFile = impl.readConfiguration(); 309 ConfigFile configFile = impl.readConfiguration();
307 repoConfig = new HgRepoConfig(configFile); 310 repoConfig = new HgRepoConfig(configFile);
308 } catch (IOException ex) { 311 } catch (HgIOException ex) {
309 String m = "Errors while reading user configuration file"; 312 String m = "Errors while reading user configuration file";
310 getSessionContext().getLog().dump(getClass(), Warn, ex, m); 313 getSessionContext().getLog().dump(getClass(), Warn, ex, m);
311 return new HgRepoConfig(new ConfigFile(getSessionContext())); // empty config, do not cache, allow to try once again 314 return new HgRepoConfig(new ConfigFile(getSessionContext())); // empty config, do not cache, allow to try once again
312 //throw new HgInvalidControlFileException(m, ex, null); 315 //throw new HgInvalidControlFileException(m, ex, null);
313 } 316 }
422 /** 425 /**
423 * Access bookmarks-related functionality 426 * Access bookmarks-related functionality
424 * @return facility to manage bookmarks, never <code>null</code> 427 * @return facility to manage bookmarks, never <code>null</code>
425 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 428 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
426 */ 429 */
427 public HgBookmarks getBookmarks() throws HgInvalidControlFileException { 430 public HgBookmarks getBookmarks() throws HgRuntimeException {
428 if (bookmarks == null) { 431 if (bookmarks == null) {
429 bookmarks = new HgBookmarks(impl); 432 bookmarks = new HgBookmarks(impl);
430 bookmarks.read(); 433 bookmarks.read();
431 } else { 434 } else {
432 bookmarks.reloadIfChanged(); 435 bookmarks.reloadIfChanged();