[PATCH 1 of 3] error: Add a hint argument to RepoError

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 24 19:34:01 CDT 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1308961817 -7200
# Branch stable
# Node ID 5da234809098bece1bd14df96cfe141249e11f58
# Parent  0c81948636f369748df584e1bba18ad31de1371e
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.

diff -r 0c81948636f3 -r 5da234809098 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Fri Jun 24 01:10:35 2011 +0200
+++ b/mercurial/dispatch.py	Sat Jun 25 02:30:17 2011 +0200
@@ -125,6 +125,8 @@
             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 -r 0c81948636f3 -r 5da234809098 mercurial/error.py
--- a/mercurial/error.py	Fri Jun 24 01:10:35 2011 +0200
+++ b/mercurial/error.py	Sat Jun 25 02:30:17 2011 +0200
@@ -43,7 +43,9 @@
     '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


More information about the Mercurial-devel mailing list