# HG changeset patch # User Pierre-Yves David # Date 1616540698 -3600 # Node ID 395cf404e76a9aad0375d91959f63d6cd0427555 # Parent 1ecf082386b707d80d06caba6a9d3e75bdbe43b5 path: error out if the `path://` reference point to an unknown path Differential Revision: https://phab.mercurial-scm.org/D10265 diff -r 1ecf082386b7 -r 395cf404e76a mercurial/ui.py --- a/mercurial/ui.py Tue Mar 23 23:55:33 2021 +0100 +++ b/mercurial/ui.py Wed Mar 24 00:04:58 2021 +0100 @@ -2339,7 +2339,12 @@ def chain_path(self, ui, paths): if self.url.scheme == b'path': assert self.url.path is None - subpath = paths[self.url.host] + try: + subpath = paths[self.url.host] + except KeyError: + m = _('cannot use `%s`, "%s" is not a known path') + m %= (self.rawloc, self.url.host) + raise error.Abort(m) if subpath.raw_url.scheme == b'path': m = _('cannot use `%s`, "%s" is also define as a `path://`') m %= (self.rawloc, self.url.host) diff -r 1ecf082386b7 -r 395cf404e76a tests/test-paths.t --- a/tests/test-paths.t Tue Mar 23 23:55:33 2021 +0100 +++ b/tests/test-paths.t Wed Mar 24 00:04:58 2021 +0100 @@ -370,3 +370,18 @@ $ hg pull chain_path abort: cannot use `path://other_default`, "other_default" is also define as a `path://` [255] + +Test basic error cases +---------------------- + + $ cat << EOF > .hg/hgrc + > [paths] + > error-missing=path://unknown + > EOF + $ hg path + abort: cannot use `path://unknown`, "unknown" is not a known path + [255] + $ hg pull error-missing + abort: cannot use `path://unknown`, "unknown" is not a known path + [255] +