# HG changeset patch # User Valentin Gatien-Baron # Date 1533432706 14400 # Node ID ac0a8716001209da5912bd27f019c24ed10209be # Parent d85b0d81112b54d60efa8a73576f445e1875ddb4 localrepo: better error when a repo exists but we lack permissions Claiming "repository foo not found" when the repository does exist causes confusion regularly ("where is the typo?"). Differential Revision: https://phab.mercurial-scm.org/D4122 diff -r d85b0d81112b -r ac0a87160012 mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Aug 06 11:32:16 2018 -0700 +++ b/mercurial/localrepo.py Sat Aug 04 21:31:46 2018 -0400 @@ -495,6 +495,11 @@ ' dummy changelog to prevent using the old repo layout' ) else: + try: + self.vfs.stat() + except OSError as inst: + if inst.errno != errno.ENOENT: + raise raise error.RepoError(_("repository %s not found") % path) elif create: raise error.RepoError(_("repository %s already exists") % path) diff -r d85b0d81112b -r ac0a87160012 tests/test-clone.t --- a/tests/test-clone.t Mon Aug 06 11:32:16 2018 -0700 +++ b/tests/test-clone.t Sat Aug 04 21:31:46 2018 -0400 @@ -642,7 +642,7 @@ $ mkdir a $ chmod 000 a $ hg clone a b - abort: repository a not found! + abort: Permission denied: '$TESTTMP/fail/a/.hg' [255] Inaccessible destination @@ -665,7 +665,7 @@ $ mkfifo a $ hg clone a b - abort: repository a not found! + abort: $ENOTDIR$: '$TESTTMP/fail/a/.hg' [255] $ rm a