# HG changeset patch # User Artem Tikhomirov # Date 1366207372 -7200 # Node ID f97e81d131909c8bbc695b8b3b6bd6ea71539a0e # Parent 5d7399ade999970658721efc06145f19b0203426 Throw exception if repository encountered is too old for Hg4J diff -r 5d7399ade999 -r f97e81d13190 src/org/tmatesoft/hg/repo/HgLookup.java --- a/src/org/tmatesoft/hg/repo/HgLookup.java Tue Apr 16 20:41:36 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/HgLookup.java Wed Apr 17 16:02:52 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2012 TMate Software Ltd + * Copyright (c) 2010-2013 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ import org.tmatesoft.hg.internal.ConfigFile; import org.tmatesoft.hg.internal.DataAccessProvider; import org.tmatesoft.hg.internal.Internals; +import org.tmatesoft.hg.internal.RequiresFile; import org.tmatesoft.hg.repo.HgRepoConfig.PathsSection; /** @@ -57,7 +58,13 @@ return detect(new File(location)); } - // look up in specified location and above + /** + * Look up repository in specified location and above + * + * @param location where to look for .hg directory, never null + * @return repository object, never null + * @throws HgRepositoryNotFoundException if no repository found, or repository version is not supported + */ public HgRepository detect(File location) throws HgRepositoryNotFoundException { File dir = location.getAbsoluteFile(); File repository; @@ -74,7 +81,12 @@ 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); + HgRepository rv = new HgRepository(getContext(), repoPath, repository); + int requiresFlags = rv.getImplHelper().getRequiresFlags(); + if ((requiresFlags & RequiresFile.REVLOGV1) == 0) { + throw new HgRepositoryNotFoundException(String.format("%s: repository version is not supported (Mercurial <0.9?)", repoPath)).setLocation(location.getPath()); + } + return rv; } public HgBundle loadBundle(File location) throws HgRepositoryNotFoundException {