comparison src/org/tmatesoft/hg/core/HgRepoFacade.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents 981f9f50bb6c
children 12f668401613
comparison
equal deleted inserted replaced
422:5d1cc7366d04 423:9c9c442b5f2e
1 /* 1 /*
2 * Copyright (c) 2011 TMate Software Ltd 2 * Copyright (c) 2011-2012 TMate Software Ltd
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License. 6 * the Free Software Foundation; version 2 of the License.
7 * 7 *
64 return !repo.isInvalid(); 64 return !repo.isInvalid();
65 } 65 }
66 66
67 /** 67 /**
68 * Tries to find repository starting from the current working directory. 68 * Tries to find repository starting from the current working directory.
69 *
69 * @return <code>true</code> if found valid repository 70 * @return <code>true</code> if found valid repository
70 * @throws HgInvalidFileException in case of errors during repository initialization 71 * @throws HgRepositoryNotFoundException if no repository found in working directory
71 */ 72 */
72 public boolean init() throws HgInvalidFileException { 73 public boolean init() throws HgRepositoryNotFoundException {
73 repo = new HgLookup(context).detectFromWorkingDir(); 74 repo = new HgLookup(context).detectFromWorkingDir();
74 return repo != null && !repo.isInvalid(); 75 return repo != null && !repo.isInvalid();
75 } 76 }
76 77
77 /** 78 /**
78 * Looks up Mercurial repository starting from specified location and up to filesystem root. 79 * Looks up Mercurial repository starting from specified location and up to filesystem root.
79 * 80 *
80 * @param repoLocation path to any folder within structure of a Mercurial repository. 81 * @param repoLocation path to any folder within structure of a Mercurial repository.
81 * @return <code>true</code> if found valid repository 82 * @return <code>true</code> if found valid repository
82 * @throws HgInvalidFileException if there are errors accessing specified location 83 * @throws HgRepositoryNotFoundException if there's no repository at specified location
83 * @throws IllegalArgumentException if argument is <code>null</code> 84 * @throws IllegalArgumentException if argument is <code>null</code>
84 */ 85 */
85 public boolean initFrom(File repoLocation) throws HgInvalidFileException { 86 public boolean initFrom(File repoLocation) throws HgRepositoryNotFoundException {
86 if (repoLocation == null) { 87 if (repoLocation == null) {
87 throw new IllegalArgumentException(); 88 throw new IllegalArgumentException();
88 } 89 }
89 repo = new HgLookup(context).detect(repoLocation); 90 repo = new HgLookup(context).detect(repoLocation);
90 return repo != null && !repo.isInvalid(); 91 return repo != null && !repo.isInvalid();