From f95a6cfc1275542c5d6eb94e317f77bfd498ff9c Mon Sep 17 00:00:00 2001 From: Pierre-Yves David Date: Sat, 25 Jun 2011 02:30:17 +0200 Subject: [PATCH] error: Add a hint argument to RepoError This use the same mechanism than Abort. Except clause stay distinct because RepoError add "!" at the end of the message. --- mercurial/dispatch.py | 2 ++ mercurial/error.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py index 417590b35b..b78209e226 100644 --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -125,6 +125,8 @@ def _runcatch(req): commands.help_(ui, 'shortlist') except error.RepoError, inst: ui.warn(_("abort: %s!\n") % inst) + if inst.hint: + ui.warn(_("(%s)\n") % inst.hint) except error.ResponseError, inst: ui.warn(_("abort: %s") % inst.args[0]) if not isinstance(inst.args[1], basestring): diff --git a/mercurial/error.py b/mercurial/error.py index cd3a93d71d..f68fbda7e8 100644 --- a/mercurial/error.py +++ b/mercurial/error.py @@ -43,7 +43,9 @@ class ParseError(Exception): 'Exception raised when parsing config files (msg[, pos])' class RepoError(Exception): - pass + def __init__(self, *args, **kw): + Exception.__init__(self, *args) + self.hint = kw.get('hint') class RepoLookupError(RepoError): pass