comparison mercurial/ui.py @ 41484:7f366dd3df1f

hg: raise Abort on invalid path Currently, some os.path functions when opening repositories may raise an uncaught TypeError or ValueError if the path is invalid. Let's catch these exceptions and turn them into an Abort for convenience. Differential Revision: https://phab.mercurial-scm.org/D5772
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 30 Jan 2019 17:22:07 -0800
parents 876494fd967d
children 97ab4cbb342e
comparison
equal deleted inserted replaced
41483:46ab0c6b28dc 41484:7f366dd3df1f
2049 def _isvalidlocalpath(self, path): 2049 def _isvalidlocalpath(self, path):
2050 """Returns True if the given path is a potentially valid repository. 2050 """Returns True if the given path is a potentially valid repository.
2051 This is its own function so that extensions can change the definition of 2051 This is its own function so that extensions can change the definition of
2052 'valid' in this case (like when pulling from a git repo into a hg 2052 'valid' in this case (like when pulling from a git repo into a hg
2053 one).""" 2053 one)."""
2054 return os.path.isdir(os.path.join(path, '.hg')) 2054 try:
2055 return os.path.isdir(os.path.join(path, '.hg'))
2056 # Python 2 may return TypeError. Python 3, ValueError.
2057 except (TypeError, ValueError):
2058 return False
2055 2059
2056 @property 2060 @property
2057 def suboptions(self): 2061 def suboptions(self):
2058 """Return sub-options and their values for this path. 2062 """Return sub-options and their values for this path.
2059 2063