# HG changeset patch # User Marcin Kuzminski # Date 2017-08-12 11:35:26 # Node ID 78bfa6d764db554a67dc185552231b57809af902 # Parent 7dbc2fc037314adbc1180b883332931419d18235 svn: simplify the repositroy existing check. - Checking using internals of SVN can be expensive - we can do a shorter much faster checks by simply searching for format file for svn repo diff --git a/vcsserver/svn.py b/vcsserver/svn.py --- a/vcsserver/svn.py +++ b/vcsserver/svn.py @@ -17,6 +17,7 @@ from __future__ import absolute_import +import os from urllib2 import URLError import logging import posixpath as vcspath @@ -89,6 +90,8 @@ class SubversionFactory(RepoFactory): repo = svn.repos.create(path, "", "", None, fs_config) else: repo = svn.repos.open(path) + + log.debug('Got SVN object: %s', repo) return repo def repo(self, wire, create=False, compatible_version=None): @@ -138,6 +141,14 @@ class SvnRemote(object): return True def is_path_valid_repository(self, wire, path): + + # NOTE(marcink): short circuit the check for SVN repo + # the repos.open might be expensive to check, but we have one cheap + # pre condition that we can use, to check for 'format' file + + if not os.path.isfile(os.path.join(path, 'format')): + return False + try: svn.repos.open(path) except svn.core.SubversionException: