Mercurial > jhg
changeset 492:e4eaa23e3442
Leave path as close as possible to one supplied by user. No need to keep it as canonical
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Oct 2012 16:27:32 +0200 |
parents | 4a670f76e7d1 |
children | ba36f66c32b4 |
files | src/org/tmatesoft/hg/repo/HgLookup.java |
diffstat | 1 files changed, 14 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgLookup.java Tue Oct 16 21:07:27 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgLookup.java Thu Oct 18 16:27:32 2012 +0200 @@ -19,7 +19,6 @@ import static org.tmatesoft.hg.util.LogFacility.Severity.Warn; import java.io.File; -import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -58,28 +57,22 @@ // look up in specified location and above public HgRepository detect(File location) throws HgRepositoryNotFoundException { - try { - File dir = location.getAbsoluteFile(); - File repository; - do { - repository = new File(dir, ".hg"); - if (repository.exists() && repository.isDirectory()) { - break; - } - repository = null; - dir = dir.getParentFile(); - - } while(dir != null); - if (repository == null) { - throw new HgRepositoryNotFoundException(String.format("Can't locate .hg/ directory of Mercurial repository in %s nor in parent dirs", location)).setLocation(location.getPath()); + File dir = location.getAbsoluteFile(); + File repository; + do { + repository = new File(dir, ".hg"); + if (repository.exists() && repository.isDirectory()) { + break; } - String repoPath = repository.getParentFile().getCanonicalPath(); - return new HgRepository(getContext(), repoPath, repository); - } catch (IOException ex) { - HgRepositoryNotFoundException t = new HgRepositoryNotFoundException("Failed to access repository"); - t.setLocation(location.getPath()).initCause(ex); - throw t; + repository = null; + dir = dir.getParentFile(); + + } while(dir != null); + if (repository == null) { + throw new HgRepositoryNotFoundException(String.format("Can't locate .hg/ directory of Mercurial repository in %s nor in parent dirs", location)).setLocation(location.getPath()); } + String repoPath = repository.getParentFile().getAbsolutePath(); + return new HgRepository(getContext(), repoPath, repository); } public HgBundle loadBundle(File location) throws HgRepositoryNotFoundException {