[PATCH 6 of 9 paths v2] ui.paths: teach getpath() about required resolution

Yuya Nishihara yuya at tcha.org
Mon Mar 2 07:41:46 CST 2015


On Sun, 01 Mar 2015 13:50:45 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1423507525 28800
> #      Mon Feb 09 10:45:25 2015 -0800
> # Node ID b8d39c692feb69e2560a49abb1b9dcc984b3e1c8
> # Parent  0aaf05f23aae7fdc440412af2f9815daaa9c4123
> ui.paths: teach getpath() about required resolution
> 
> It is somewhat common for callers of ui.expandpath to manage their
> own flow control for cases where the specified location could not
> be resolved. Sometimes we get as far down as
> localrepository.__init__ before an exception is raised.
> 
> Here, we teach paths.getpath() how to raise exceptions in cases where
> paths could not be resolved. Consumers of this argument will come
> in subsequent patches.
> 
> The error messages are identical to messages that already exist.
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py

> @@ -999,9 +1000,15 @@ class paths(object):
>                  return self['default']
>              except KeyError:
>                  pass
>  
> -        return None
> +        if not require:
> +            return None
> +
> +        if default:
> +            raise util.Abort(_('default repository not configured!'),
> +                    hint=_('see the "path" section in "hg help config"'))
> +        raise RepoError(_('repository %s not found') % name)

Just a nitpick: it should be error.RepoError, though it seems a bit strange
to me that ui raises RepoError.

Regards,


More information about the Mercurial-devel mailing list